Skip to content

Commit 310596a

Browse files
authored
feat: Use fontsource instead of restribution of fonts and icons (#96)
## Description Use fontsource to install the fonts via npm instead of manually redistributing the fonts and icons. The benefit is that fonts can receive updates and icons don't have to be uploaded manually. To use icons, you have to find out the name of the icon (https://fonts.google.com/icons). Then, there are two different ways: - As partial in html templates: ```go {{ partial "icon" "<icon-name>" }} ``` - As shortcode in markdown templates: ```go {{< icon <icon-name> >}} ``` The only disadvantage is the size of 270kB, but it's lazy-loaded and we have all icons. It might be good to add the shortcut to the contribution wiki after the PR has been merged. For the Roboto font, the improvement is even more significant (esp. for Chrome users). It recognizes the font as actual Roboto font and loads it from chrome resources, reducing the size of ~300kB to ~200 bytes. TODO: - [ ] Change outlined to rounded icons
1 parent 0b742ba commit 310596a

32 files changed

+135
-144
lines changed

assets/sass/anchorlink.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
flex-wrap: wrap;
44
}
55

6+
.a-anchorlink::before {
7+
content: "";
8+
display: block;
9+
width: 100%;
10+
margin: 2rem 0;
11+
background-image: url("/intersector.svg");
12+
background-position: center;
13+
background-repeat: no-repeat;
14+
height: 2.4rem;
15+
opacity: 50%;
16+
}
17+
618
.a-anchorlink__link {
719
display: inline-flex;
820
width: 3.2rem;
@@ -12,6 +24,7 @@
1224
margin-left: .8rem;
1325
border-radius: var(--border-radius-s);
1426
opacity: .8;
27+
text-decoration: none;
1528

1629
&:hover,
1730
&:focus {

assets/sass/expander.scss

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,17 @@ details > summary::-webkit-details-marker {
3434
}
3535

3636
summary::before {
37-
content: url($icon-add);
38-
font-weight: normal;
39-
width: 2.4rem;
40-
height: 2.4rem;
41-
margin-right: .8rem;
42-
text-decoration: none;
37+
content: "add";
4338
position: absolute;
4439
left: 1.2rem;
40+
font-size: 2.4rem;
41+
@extend .material-symbols-rounded
4542
}
4643

4744
details[open] > summary::before {
48-
content: url($icon-remove);
45+
content: "remove";
46+
font-size: 2.4rem;
47+
@extend .material-symbols-rounded
4948
}
5049

5150
details[open] > summary {

assets/sass/fonts.scss

Lines changed: 76 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,91 @@
1+
/* roboto-latin-100-normal */
12
@font-face {
2-
font-family: "Roboto";
3+
font-family: 'Roboto';
34
font-style: normal;
4-
font-weight: 100 700;
5-
src: url(/fonts/Roboto-VariableFont_wdth,wght.ttf) format('woff2');
65
font-display: swap;
6+
font-weight: 100;
7+
src: url(@fontsource/roboto/files/roboto-latin-100-normal.woff2) format('woff2'), url(@fontsource/roboto/files/roboto-latin-100-normal.woff) format('woff');
8+
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
79
}
810

11+
/* roboto-latin-400-normal */
912
@font-face {
10-
font-family: "Roboto";
13+
font-family: 'Roboto';
14+
font-style: normal;
15+
font-display: swap;
16+
font-weight: 400;
17+
src: url(@fontsource/roboto/files/roboto-latin-400-normal.woff2) format('woff2'), url(@fontsource/roboto/files/roboto-latin-400-normal.woff) format('woff');
18+
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
19+
}
20+
21+
/* roboto-latin-700-normal */
22+
@font-face {
23+
font-family: 'Roboto';
24+
font-style: normal;
25+
font-display: swap;
26+
font-weight: 700;
27+
src: url(@fontsource/roboto/files/roboto-latin-700-normal.woff2) format('woff2'), url(@fontsource/roboto/files/roboto-latin-700-normal.woff) format('woff');
28+
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
29+
}
30+
31+
/* roboto-latin-100-italic */
32+
@font-face {
33+
font-family: 'Roboto';
34+
font-style: italic;
35+
font-display: swap;
36+
font-weight: 100;
37+
src: url(@fontsource/roboto/files/roboto-latin-100-italic.woff2) format('woff2'), url(@fontsource/roboto/files/roboto-latin-100-italic.woff) format('woff');
38+
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
39+
}
40+
41+
/* roboto-latin-400-italic */
42+
@font-face {
43+
font-family: 'Roboto';
1144
font-style: italic;
12-
font-weight: 100 700;
13-
src: url(/fonts/Roboto-Italic-VariableFont_wdth,wght.ttf) format('woff2');
1445
font-display: swap;
46+
font-weight: 400;
47+
src: url(@fontsource/roboto/files/roboto-latin-400-italic.woff2) format('woff2'), url(@fontsource/roboto/files/roboto-latin-400-italic.woff) format('woff');
48+
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
49+
}
50+
51+
/* roboto-latin-700-italic */
52+
@font-face {
53+
font-family: 'Roboto';
54+
font-style: italic;
55+
font-display: swap;
56+
font-weight: 700;
57+
src: url(@fontsource/roboto/files/roboto-latin-700-italic.woff2) format('woff2'), url(@fontsource/roboto/files/roboto-latin-700-italic.woff) format('woff');
58+
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
59+
}
60+
61+
/* material-symbols-rounded-latin-400-normal */
62+
@font-face {
63+
font-family: 'Material Symbols Rounded';
64+
font-style: normal;
65+
font-display: swap;
66+
font-weight: 400;
67+
src: url(@fontsource/material-symbols-rounded/files/material-symbols-rounded-latin-400-normal.woff2) format('woff2'), url(@fontsource/material-symbols-rounded/files/material-symbols-rounded-latin-400-normal.woff) format('woff');
68+
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
1569
}
1670

1771
body {
1872
font-family: "Roboto",Arial,Helvetica,sans-serif;
1973
word-wrap: break-word;
2074
hyphens: auto;
2175
}
76+
77+
.material-symbols-rounded {
78+
font-family: "Material Symbols Rounded";
79+
font-weight: normal;
80+
font-style: normal;
81+
display: inline-block;
82+
font-size: 20px;
83+
line-height: 1;
84+
text-transform: none;
85+
letter-spacing: normal;
86+
word-wrap: normal;
87+
white-space: nowrap;
88+
direction: ltr;
89+
vertical-align: text-bottom;
90+
text-decoration: none;
91+
}

assets/sass/main.scss

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
$icon-add: '{{(resources.Get "svg/default/add.svg" | fingerprint "md5").RelPermalink}}';
2-
$icon-remove: '{{(resources.Get "svg/default/remove.svg" | fingerprint "md5").RelPermalink}}';
3-
41
@import "_variables.scss";
52
@import "node_modules/bootstrap/scss/bootstrap.scss";
63
@import "styles.scss";

assets/sass/navigation.scss

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,12 @@
137137
}
138138
}
139139

140-
.o-header__expand-button svg,
141-
.o-nav__menu-button svg,
142-
.o-nav__close-button svg {
140+
.o-header__expand-button > .material-symbols-rounded,
141+
.o-nav__menu-button > .material-symbols-rounded,
142+
.o-nav__close-button > .material-symbols-rounded {
143143
margin-left: .8rem;
144144
align-self: center;
145+
text-decoration: none;
145146
}
146147

147148
.o-header__expand-button:has(~ .o-header__item-countries--open) svg {

assets/sass/styles.scss

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,4 @@ img {
167167
padding: 2rem;
168168
border-radius: var(--border-radius-l);
169169
margin-bottom: 2.4rem;
170-
171-
.content span:not(:first-of-type)::before {
172-
content: "";
173-
display: block;
174-
width: 100%;
175-
margin: 2rem 0;
176-
background-image: url("/intersector.svg");
177-
background-position: center;
178-
background-repeat: no-repeat;
179-
height: 2.4rem;
180-
opacity: 50%;
181-
}
182170
}

assets/svg/default/add.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

assets/svg/default/arrow_back.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

assets/svg/default/arrow_outward.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

assets/svg/default/close.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)