Skip to content

Commit 9425808

Browse files
committed
Apply simple icons
1 parent 90ac59a commit 9425808

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { siMastodon, siLinkedin, siGithub } from 'simple-icons';
2+
3+
const ICONS = {
4+
mastodon: siMastodon,
5+
linkedin: siLinkedin,
6+
github: siGithub,
7+
};
8+
9+
async function applyBrandsIcons() {
10+
const elements = document.querySelectorAll('[data-simple-icon]');
11+
12+
elements.forEach(element => {
13+
const attribute = element.getAttribute('data-simple-icon').toLowerCase();
14+
const icon = ICONS[attribute];
15+
16+
if (icon) {
17+
const svgDoc = new DOMParser().parseFromString(icon.svg, 'image/svg+xml');
18+
const svgElement = svgDoc.querySelector('svg');
19+
const existingClasses = element.getAttribute('class');
20+
21+
if (existingClasses) {
22+
svgElement.setAttribute('class', existingClasses);
23+
}
24+
svgElement.setAttribute('fill', 'var(--svgfill)');
25+
element.replaceWith(svgElement);
26+
}
27+
});
28+
}
29+
30+
document.addEventListener('DOMContentLoaded', applyBrandsIcons);

themes/opentermsarchive/layouts/partials/footer.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@
7676
{{ $languageSwitcherJs := resources.Get "js/languageSwitcher.js" | js.Build }}
7777
<script src="{{ $languageSwitcherJs.RelPermalink }}"></script>
7878

79+
{{ $brandsJs := resources.Get "js/brands.js" | js.Build }}
80+
<script src="{{ $brandsJs.RelPermalink }}"></script>
81+
7982
{{ $headerJs := resources.Get "js/header.js" | js.Build }}
8083
<script src="{{ $headerJs.RelPermalink }}"></script>
8184

0 commit comments

Comments
 (0)