Skip to content

Commit 04764e5

Browse files
committed
refactor: Switch from web components for icons to partials to support showing icons without JS
Signed-off-by: Felicitas Pojtinger <felicitas@pojtinger.com>
1 parent 971a6ba commit 04764e5

15 files changed

Lines changed: 76 additions & 121 deletions

assets/js/event-detail-modal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ customElements.define(
151151
className: "pf-v6-c-button pf-m-link pf-m-inline pf-m-small",
152152
});
153153
mapLink.innerHTML =
154-
'View on map <span class="pf-v6-c-button__icon pf-m-end"><icon-external></icon-external></span>';
154+
'View on map <span class="pf-v6-c-button__icon pf-m-end"><i class="fa-solid fa-arrow-up-right-from-square" aria-hidden="true"></i></span>';
155155
$("map-link").append(mapLink);
156156
} else {
157157
$("map-br").remove();

assets/js/icons.js

Lines changed: 0 additions & 44 deletions
This file was deleted.

assets/js/luma-next-event.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ template.innerHTML = `
3333
<a data-slot="rsvp" target="_blank" rel="noopener"
3434
class="pf-v6-c-button pf-m-link pf-m-inline">
3535
<span class="pf-v6-c-button__text">RSVP on Luma</span>
36-
<span class="pf-v6-c-button__icon pf-m-end"><icon-external></icon-external></span>
36+
<span class="pf-v6-c-button__icon pf-m-end"><i class="fa-solid fa-arrow-up-right-from-square" aria-hidden="true"></i></span>
3737
</a>
3838
</div>
3939
</div>

assets/js/luma-upcoming-events.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ rowTemplate.innerHTML = `
2222
Details
2323
</button>
2424
<a data-slot="rsvp" target="_blank" rel="noopener" class="pf-v6-c-button pf-m-link pf-m-inline pf-m-small">
25-
RSVP<span class="pf-v6-c-button__icon pf-m-end"><icon-external></icon-external></span>
25+
RSVP<span class="pf-v6-c-button__icon pf-m-end"><i class="fa-solid fa-arrow-up-right-from-square" aria-hidden="true"></i></span>
2626
</a>
2727
</div>
2828
</td>
@@ -81,7 +81,7 @@ customElements.define(
8181
const api = this.getAttribute("api");
8282
const lumaUrl = this.getAttribute("luma") ?? "https://luma.com/vanlug";
8383
const rssUrl = `${api}/events/feed?calendar=${encodeURIComponent(cal)}`;
84-
const subscribeLinks = `<br>Stay updated via <a href="${lumaUrl}" target="_blank" rel="noopener">Luma<icon-external></icon-external></a> or <a href="${rssUrl}" target="_blank" rel="noopener">RSS<icon-custom data-icon="fa-solid fa-rss"></icon-custom></a>.`;
84+
const subscribeLinks = `<br>Stay updated via <a href="${lumaUrl}" target="_blank" rel="noopener">Luma<span style="display: inline; white-space: nowrap;">&#8288;<i class="fa-solid fa-arrow-up-right-from-square pf-v6-u-ml-xs" aria-hidden="true"></i></span></a> or <a href="${rssUrl}" target="_blank" rel="noopener">RSS<span style="display: inline; white-space: nowrap;">&#8288;<i class="fa-solid fa-rss pf-v6-u-ml-xs" aria-hidden="true"></i></span></a>.`;
8585

8686
try {
8787
const { entries } = await fetch(

assets/js/main.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import "./theme.js";
22
import "./sidebar.js";
3-
import "./icons.js";
43
import "./event-detail-modal.js";
54
import "./luma-next-event.js";
65
import "./luma-upcoming-events.js";

data/content.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,4 @@ footer:
112112
body: "VanLUG is 100% volunteer-run. All Board of Directors and Executives volunteer their time and effort for free. Donations go toward maintaining our website, Discourse platform, network infrastructure, and expenses related to our in-person meetings. Any amount helps. Thank you for sharing your resources."
113113
cta: Donate via PayPal
114114
land_acknowledgment: "VanLUG acknowledges that we meet, learn, and collaborate on the shared territories of many Indigenous Peoples, including the q̓ic̓əy̓ (Katzie), q̓ʷɑ:n̓ƛ̓ən̓ (Kwantlen), kʷikʷəƛ̓əm (Kwikwetlem), máthxwi (Matsqui), xʷməθkʷəy̓əm (Musqueam), qiqéyt (Qayqayt), Semiahmoo, Sḵwx̱wú7mesh Úxwumixw (Squamish), scəw̓aθən məsteyəxʷ (Tsawwassen), and səlilwətaɬ (Tsleil-Waututh). We respect the diverse and distinct histories, languages, and cultures of First Nations, Métis, and Inuit."
115-
nonprofit: 'VanLUG is a registered non-profit organization with the <a href="https://www2.gov.bc.ca/gov/content/employment-business/business/not-for-profit-organizations" target="_blank" rel="noreferrer noopener">BC Provincial Government<icon-external></icon-external></a>, incorporated on March 29, 1999. Run entirely by volunteers, we''ve been bringing Linux and open-source enthusiasts together in Vancouver for over 25 years.'
115+
nonprofit: 'VanLUG is a registered non-profit organization with the <a href="https://www2.gov.bc.ca/gov/content/employment-business/business/not-for-profit-organizations" target="_blank" rel="noreferrer noopener">BC Provincial Government<span style="display: inline; white-space: nowrap;">&#8288;<i class="fa-solid fa-arrow-up-right-from-square pf-v6-u-ml-xs" aria-hidden="true"></i></span></a>, incorporated on March 29, 1999. Run entirely by volunteers, we''ve been bringing Linux and open-source enthusiasts together in Vancouver for over 25 years.'

layouts/_partials/footer.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,13 @@
5050
href="{{ .Site.Data.site.source }}"
5151
target="_blank"
5252
rel="noopener"
53-
>source code<icon-external></icon-external>
54-
</a>
53+
>source code{{ partial "icon" "external" }}</a>
5554
on GitHub, licensed under
5655
<a
5756
href="{{ .Site.Data.site.source }}/blob/main/LICENSE"
5857
target="_blank"
5958
rel="noopener"
60-
>AGPL-3.0-or-later<icon-external></icon-external></a
59+
>AGPL-3.0-or-later{{ partial "icon" "external" }}</a
6160
>. See our <a href="{{ "/terms/" | relURL }}">terms</a> and
6261
<a href="{{ "/privacy/" | relURL }}">privacy policy</a>.</small
6362
>

layouts/_partials/icon.html

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,27 @@
1-
{{- with . -}}{{ printf `<icon-custom data-icon="%s"></icon-custom>` . | safeHTML }}{{- end -}}
1+
{{- $map := dict
2+
"discourse" "fa-brands fa-discourse"
3+
"signal" "fa-brands fa-signal-messenger"
4+
"mastodon" "fa-brands fa-mastodon"
5+
"bluesky" "fa-brands fa-bluesky"
6+
"linkedin" "fa-brands fa-linkedin"
7+
"paypal" "fa-brands fa-paypal"
8+
"github" "fa-brands fa-github"
9+
"globe" "fa-solid fa-globe"
10+
"external" "fa-solid fa-arrow-up-right-from-square"
11+
"email" "fa-solid fa-envelope"
12+
"rss" "fa-solid fa-rss"
13+
-}}
14+
{{- $name := "" -}}
15+
{{- $inButton := false -}}
16+
{{- if reflect.IsMap . -}}
17+
{{- $name = .icon -}}
18+
{{- $inButton = .inButton | default false -}}
19+
{{- else -}}
20+
{{- $name = . -}}
21+
{{- end -}}
22+
{{- $fa := index $map $name | default $name -}}
23+
{{- if $inButton -}}
24+
<i class="{{ $fa }}" aria-hidden="true"></i>
25+
{{- else -}}
26+
<span style="display: inline; white-space: nowrap;">&#8288;<i class="{{ $fa }} pf-v6-u-ml-xs" aria-hidden="true"></i></span>
27+
{{- end -}}

layouts/_partials/mastodon-feed.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ <h3>Latest posts</h3>
4848
href="{{ .Site.Data.links.socials.mastodon.url }}"
4949
target="_blank"
5050
rel="noopener"
51-
>See all posts<icon-external></icon-external></a
51+
>See all posts{{ partial "icon" "external" }}</a
5252
>, or subscribe via
5353
<a
5454
href="{{ .Site.Data.links.feed.mastodon }}"
5555
target="_blank"
5656
rel="noopener"
57-
>RSS<icon-custom data-icon="fa-solid fa-rss"></icon-custom></a
57+
>RSS{{ partial "icon" "rss" }}</a
5858
>.
5959
</p>
6060
</div>

layouts/_partials/section-about.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,17 @@ <h3>{{ .Site.Data.board.year }} Board of Directors</h3>
4545
<p>
4646
{{ .Site.Data.content.about.board.preamble | default "As a registered non-profit society in British Columbia, VanLUG is governed by a volunteer Board of Directors. Elections are held annually at our AGM. New volunteers are always welcome." }}
4747
<a href="{{ .Site.Data.links.socials.email.url }}"
48-
>Get in touch<icon-email></icon-email
49-
></a>
48+
>Get in touch{{ partial "icon" "email" }}</a>
5049
if you'd like to help.
5150
</p>
5251
</div>
5352

54-
{{ $prevRole := "" }}
53+
{{ $directorSeen := false }}
5554
{{ range $i, $member := .Site.Data.board.bios }}
56-
{{ if and (ne $i 0) (ne $member.role $prevRole) }}
55+
{{ if and (not $directorSeen) (eq $member.role "Director-at-large") (ne $i 0) }}
5756
<hr class="pf-v6-c-divider" />
5857
{{ end }}
59-
{{ $prevRole = $member.role }}
58+
{{ if eq $member.role "Director-at-large" }}{{ $directorSeen = true }}{{ end }}
6059
<div class="pf-v6-c-card pf-m-compact">
6160
<div class="pf-v6-c-card__title">
6261
<div class="pf-v6-c-card__title-text">
@@ -83,7 +82,7 @@ <h3>{{ .Site.Data.board.year }} Board of Directors</h3>
8382
href="{{ .url }}"
8483
target="_blank"
8584
rel="noreferrer noopener"
86-
>{{ .label }}{{ with .icon }}{{ printf "<%s></%s>" . . | safeHTML }}{{ else }}<icon-external></icon-external>{{ end }}</a>
85+
>{{ .label }}{{ partial "icon" ((.icon | default "icon-external") | strings.TrimPrefix "icon-") }}</a>
8786
{{ end }}
8887
</div>
8988
{{ end }}

0 commit comments

Comments
 (0)