Skip to content

Commit 146ee54

Browse files
authored
Merge pull request #49 from Mazizova/people-initials-placeholder
Show initials placeholder for People without a photo
2 parents 8a60c06 + f8f7c51 commit 146ee54

4 files changed

Lines changed: 73 additions & 15 deletions

File tree

‎assets/scss/_light-theme.scss‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,17 @@
320320
.resource-single-img {
321321
border-color: #dde3ed;
322322
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
323+
324+
&--placeholder {
325+
background: #f1f5f9;
326+
color: #0272a5;
327+
box-shadow: none;
328+
}
329+
}
330+
331+
.resource-card-image--placeholder {
332+
background: #f1f5f9;
333+
color: #0272a5;
323334
}
324335

325336
.resource-tag {

‎assets/scss/_resources.scss‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,21 @@
428428
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
429429
border-radius: 3px;
430430
}
431+
432+
&--placeholder {
433+
width: 100%;
434+
height: auto;
435+
aspect-ratio: 1 / 1;
436+
display: flex;
437+
align-items: center;
438+
justify-content: center;
439+
background: $accent-glow;
440+
color: $accent;
441+
font-size: 2.25rem;
442+
font-weight: 600;
443+
letter-spacing: 0.02em;
444+
box-shadow: none;
445+
}
431446
}
432447

433448
.resource-card-body {
@@ -1106,6 +1121,19 @@ body.sheet-open {
11061121
border: 1px solid $dark-border;
11071122
display: block;
11081123
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
1124+
1125+
&--placeholder {
1126+
aspect-ratio: 1 / 1;
1127+
display: flex;
1128+
align-items: center;
1129+
justify-content: center;
1130+
background: $accent-glow;
1131+
color: $accent;
1132+
font-size: 3rem;
1133+
font-weight: 600;
1134+
letter-spacing: 0.02em;
1135+
box-shadow: none;
1136+
}
11091137
}
11101138

11111139
.resource-csv-btn {

‎layouts/resources/list.html‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,14 @@ <h1 class="resources-section-title">{{ .Title }}</h1>
261261
{{ range (index $page.Params $fp) }}{{ $chips = $chips | append (dict "value" . "path" $fp) }}{{ end }}
262262
{{ end }}
263263
{{ end }}
264-
<div class="resource-card{{ if $images }} resource-card--has-image{{ end }}"
264+
{{ $isPerson := in .Params.subcategories "People" }}
265+
{{ $imgRes := "" }}
266+
{{ with $images }}
267+
{{ $imgFile := index . 0 }}
268+
{{ $imgRes = $pageRes.Get $imgFile }}
269+
{{ if not $imgRes }}{{ $imgRes = resources.Get (strings.TrimPrefix "/" $imgFile) }}{{ end }}
270+
{{ end }}
271+
<div class="resource-card{{ if or $imgRes $isPerson }} resource-card--has-image{{ end }}"
265272
data-url="{{ $pageURL }}"
266273
data-title="{{ .Title }}"
267274
data-description="{{ .Description }}"
@@ -270,16 +277,17 @@ <h1 class="resources-section-title">{{ .Title }}</h1>
270277
data-format="{{ .Params.format }}"
271278
data-location="{{ $loc := slice }}{{ with .Params.city }}{{ $loc = $loc | append . }}{{ end }}{{ range .Params.countries }}{{ $loc = $loc | append . }}{{ end }}{{ delimit $loc ", " }}"
272279
>
273-
{{ with $images }}
274-
{{ $imgFile := index . 0 }}
275-
{{ $imgRes := $pageRes.Get $imgFile }}
276-
{{ if not $imgRes }}{{ $imgRes = resources.Get (strings.TrimPrefix "/" $imgFile) }}{{ end }}
277-
{{ with $imgRes }}
278-
{{ $thumb := .Fit "320x480 jpg" }}
280+
{{ if $imgRes }}
281+
{{ $thumb := $imgRes.Fit "320x480 jpg" }}
279282
<a href="{{ $pageURL }}" class="resource-card-image-wrap resource-card-image-wrap--portrait">
280283
<img src="{{ $thumb.RelPermalink }}" alt="{{ $pageTitle }}" class="resource-card-image" loading="lazy" width="{{ $thumb.Width }}" height="{{ $thumb.Height }}">
281284
</a>
282-
{{ end }}
285+
{{ else if $isPerson }}
286+
{{ $initials := "" }}
287+
{{ range split $pageTitle " " }}{{ $initials = printf "%s%s" $initials (substr . 0 1) }}{{ end }}
288+
<a href="{{ $pageURL }}" class="resource-card-image-wrap resource-card-image-wrap--portrait">
289+
<div class="resource-card-image resource-card-image--placeholder" aria-hidden="true">{{ $initials }}</div>
290+
</a>
283291
{{ end }}
284292
<div class="resource-card-body">
285293
<h2 class="resource-card-title">{{ .Title }}</h2>

‎layouts/resources/single.html‎

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,30 @@
88
<span>{{ .Title }}</span>
99
</nav>
1010

11-
<div class="resource-single-layout{{ with .Params.images }} resource-single-layout--with-image{{ end }}">
12-
13-
{{/* Image column — leaf bundle first, fallback to global assets */}}
11+
{{/* People without a photo still get the image column — an initials
12+
placeholder — so the layout doesn't collapse to full-width just
13+
because a photo wasn't available (e.g. no public LinkedIn photo). */}}
14+
{{ $isPerson := in .Params.subcategories "People" }}
15+
{{ $imgRes := "" }}
1416
{{ with .Params.images }}
1517
{{ $imgFile := index . 0 }}
16-
{{ $imgRes := $.Resources.Get $imgFile }}
18+
{{ $imgRes = $.Resources.Get $imgFile }}
1719
{{ if not $imgRes }}{{ $imgRes = resources.Get (strings.TrimPrefix "/" $imgFile) }}{{ end }}
18-
{{ with $imgRes }}
20+
{{ end }}
21+
22+
<div class="resource-single-layout{{ if or $imgRes $isPerson }} resource-single-layout--with-image{{ end }}">
23+
24+
{{ if $imgRes }}
1925
<div class="resource-single-image-col">
20-
{{ $img := .Fit "600x900 jpg" }}
26+
{{ $img := $imgRes.Fit "600x900 jpg" }}
2127
<img src="{{ $img.RelPermalink }}" alt="" class="resource-single-img" loading="lazy" width="{{ $img.Width }}" height="{{ $img.Height }}">
2228
</div>
23-
{{ end }}
29+
{{ else if $isPerson }}
30+
{{ $initials := "" }}
31+
{{ range split $.Title " " }}{{ $initials = printf "%s%s" $initials (substr . 0 1) }}{{ end }}
32+
<div class="resource-single-image-col">
33+
<div class="resource-single-img resource-single-img--placeholder" aria-hidden="true">{{ $initials }}</div>
34+
</div>
2435
{{ end }}
2536

2637
{{/* Content column */}}

0 commit comments

Comments
 (0)