Skip to content

Commit 5f24dfc

Browse files
committed
feat(css): new card layouts
1 parent 5dd1d5f commit 5f24dfc

7 files changed

+97
-10
lines changed

_includes/archive-cards.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
<article>
22
<a href="{{ post.url | relative_url l}}">
33
<div class="cards">
4-
{% if post.feature_img %}
5-
<img src="{{ post.feature_img | relative_url }}" alt="{{ post.feature_alt }}">
4+
{% if post.header.overlay_image %}
5+
<div class="card__header" style="background-image: url('{{ post.header.overlay_image | relative_url }}');">
6+
{% if post.feature_img %}
7+
<img src="{{ post.feature_img | relative_url }}" alt="{{ post.feature_alt }}">
8+
{% endif %}
9+
</div>
10+
{% else %}
11+
<div class="card__header card__header-color-{{ color_counter }}">
12+
</div>
613
{% endif %}
7-
814
<div class="card__bkg">
9-
<h3 class="card-title">{{ post.title | markdownify | strip_html }}</h3>
15+
<div class="card__title-container">
16+
<h3 class="card-title">{{ post.title | markdownify | strip_html }}</h3>
17+
</div>
1018
</div>
1119
<div class="card-excerpt">
1220
<p>{{ post.excerpt }}</p>

_layouts/posts_gallery.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,25 @@
1515
{% endfor %}
1616
</ul>
1717

18+
{% assign color_counter = 0 %} <!-- Initialize the counter once, outside the loop -->
19+
{% assign color_max = 4 %} <!-- Set the max number of colors -->
20+
21+
1822
{% assign entries_layout = page.entries_layout | default: 'list' %}
1923
{% assign postsByYear = site.posts | where_exp: "item", "item.hidden != true" | group_by_exp: 'post', 'post.date | date: "%Y"' %}
2024
{% for year in postsByYear %}
2125
<section id="{{ year.name }}" class="taxonomy__section">
2226
<h2 class="archive__subtitle">{{ year.name }}</h2>
2327
<div class="blog__grid">
2428
{% for post in year.items %}
25-
{% include archive-cards.html %}
29+
{% unless post.header.overlay_image %}
30+
{% assign color_counter = color_counter | plus: 1 %}
31+
{% if color_counter == color_max %}
32+
<!-- Reset the counter -->
33+
{% assign color_counter = 0 %}
34+
{% endif %}
35+
{% endunless %}
36+
{% include archive-cards.html color_counter=color_counter %}
2637
{% endfor %}
2738
</div>
2839
<a href="#page-title" class="back-to-top">{{ site.data.ui-text[site.locale].back_to_top | default: 'Back to Top' }} &uarr;</a>

_pages/blog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ excerpt: "Here we will both post updates about pyOpenSci and also highlight cont
77
header:
88
overlay_color: "#666"
99
overlay_filter: 0.6
10+
overlay_image: images/headers/pyopensci-learn-header.png
1011
author_profile: false
1112
---
1213

_posts/events/2024-04-29-create-your-first-python-package-pyopensci-online-workshop.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ categories:
1111
- events
1212
classes: wide
1313
toc: true
14+
type: "event"
1415
comments: true
1516
---
1617

_posts/events/2024-06-25-create-your-first-python-package-scipy-2024.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ categories:
1111
- events
1212
classes: wide
1313
toc: true
14+
type: "event"
1415
comments: true
1516
---
1617

_posts/events/2024-07-25-pyopensci-fall-festival.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ categories:
1414
- events
1515
classes: wide
1616
toc: true
17+
type: "event"
1718
comments: true
1819
---
1920

_sass/minimal-mistakes/_pyos-grid.scss

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
// Create colormap for cards
2+
$colors: (
3+
color-0: #bb82b0,
4+
color-1: #6b5b95,
5+
color-2: #bab3d4,
6+
color-3: #81c0aa
7+
);
8+
9+
@mixin generate-color-styles($color-map) {
10+
@each $name, $color in $color-map {
11+
.card__header-#{$name} {
12+
background-color: $color;
13+
14+
&::before {
15+
background: rgba(0, 0, 0, 0.4)!important;
16+
}
17+
}
18+
.cards:hover .card__header-#{$name} {
19+
background-color: lighten($color, 15%) !important; // Lighten the color by 40%
20+
}
21+
}
22+
}
23+
24+
25+
26+
// Include the mixin
27+
@include generate-color-styles($colors);
28+
29+
130
.clearfix::after {
231
content: "";
332
display: table;
@@ -59,7 +88,6 @@
5988

6089
.card-excerpt p {
6190
font-size: 1.1em;
62-
6391
}
6492

6593
.card__bkg {
@@ -107,14 +135,20 @@
107135
top: 0px;
108136
position: relative;
109137
max-width: 362px;
110-
background-color: #f1f0f1;;
138+
background-color: #fcfbf5;;
111139
border-radius: 4px;
112-
// padding: 32px 24px;
113140
text-decoration: none;
114141
z-index: 0;
115142
overflow: hidden;
116143
border: 1px solid #f2f8f9;
117144
font-size: .8em;
145+
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
146+
transition: transform 0.3s ease, box-shadow 0.3s ease;
147+
148+
&:hover {
149+
transform: scale(1.05); // Slightly enlarge the card
150+
box-shadow: 0 8px 12px rgba(0, 0, 0, 0.4); // Enhanced shadow on hover
151+
}
118152

119153
&.highlight div {
120154
padding:0;
@@ -127,6 +161,7 @@
127161
&:before {
128162
background-color: #fff;
129163
}
164+
130165
&:hover {
131166
cursor:default;
132167
}
@@ -144,7 +179,6 @@
144179
margin-top: 0;
145180
margin-bottom: 0;
146181
border-bottom: none;
147-
148182
}
149183
}
150184
}
@@ -200,11 +234,41 @@
200234

201235

202236

203-
/* Blog grid styles*/
237+
/* Blog & event grid styles*/
204238

205239
.blog__grid .cards {
206240
padding: 0 !important;
207241

242+
.card__header {
243+
position: relative;
244+
background-size: cover;
245+
background-position: center;
246+
overflow: hidden;
247+
248+
&::before {
249+
content: '';
250+
position: absolute;
251+
top: 0;
252+
left: 0;
253+
right: 0;
254+
bottom: 0;
255+
background: rgba(0, 0, 0, 0.6); // Initial overlay color (faded)
256+
transition: background 0.3s ease; // Smooth transition effect
257+
}
258+
}
259+
// Changed hover selector to target .cards instead of .card__header
260+
&:hover .card__header::before {
261+
background: rgba(0, 0, 0, 0.2); // Darker overlay on hover
262+
263+
}
264+
265+
.card__title-container {
266+
min-height: 60px; /* Set a minimum height to standardize the title area */
267+
display: flex;
268+
align-items: center; /* Vertically center the title */
269+
padding: 0 15px; /* Padding around the title */
270+
}
271+
208272
.card-excerpt{
209273
font-size: .8em;
210274
padding: 0 1.3em;

0 commit comments

Comments
 (0)