Skip to content

Commit b1f72f2

Browse files
committed
Add support multiple font styles
1 parent 8b3a0bf commit b1f72f2

9 files changed

Lines changed: 212 additions & 70 deletions

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ Where `[ICON NAME]` is replaced by the icon name, for example:
7777
<i class="si si-simpleicons si--color"></i>
7878
```
7979

80+
Or use the squared font, all font will rendered in the same-sized square:
81+
82+
```html
83+
<i class="si-squared si-simpleicons"></i>
84+
<i class="si-squared si-simpleicons si--color"></i>
85+
```
86+
8087
In this example we use the `<i>` tag, but any inline HTML tag should work as you expect.
8188

8289
## Custom Builds

package-lock.json

Lines changed: 20 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"semver": "7.7.1",
4848
"serve": "14.2.4",
4949
"simple-icons": "14.15.0",
50+
"svg-path-bbox": "2.1.0",
5051
"svg2ttf": "6.0.3",
5152
"svgpath": "2.6.0",
5253
"ttf2eot": "3.1.0",

preview/assets/script.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
document.addEventListener('DOMContentLoaded', () => {
22
const $body = document.querySelector('body');
3-
const $icons = document.getElementsByClassName('si');
3+
const $icons = document.getElementsByTagName('i');
44
const $backgroundModeButton = document.querySelector('.background-mode');
55
const $iconsColorButton = document.querySelector('.icons-color');
6+
const $iconsStyleButton = document.querySelector('.icons-style');
67

78
// Background dark/light mode toggler
89
$backgroundModeButton.addEventListener('click', () => {
@@ -26,4 +27,27 @@ document.addEventListener('DOMContentLoaded', () => {
2627
$icons[i].classList.toggle('si--color');
2728
}
2829
});
30+
31+
// Icons style toggle
32+
$iconsStyleButton.addEventListener('click', () => {
33+
const isSquared = $icons[0].classList.contains('si-squared');
34+
if (isSquared) {
35+
$iconsStyleButton.innerText = 'Regular';
36+
} else {
37+
$iconsStyleButton.innerText = 'Squared';
38+
}
39+
40+
for (let i = 0; i < $icons.length; i++) {
41+
if ($icons[i].classList.contains('style-immutable')) {
42+
continue;
43+
}
44+
if (isSquared) {
45+
$icons[i].classList.remove('si-squared');
46+
$icons[i].classList.add('si');
47+
} else {
48+
$icons[i].classList.remove('si');
49+
$icons[i].classList.add('si-squared');
50+
}
51+
}
52+
});
2953
});

preview/assets/style.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ body.dark {
1919
cursor: pointer;
2020
}
2121

22-
i.si {
22+
i.si,
23+
i.si-squared {
2324
display: inline-block;
2425
cursor: help;
2526
}
@@ -28,7 +29,8 @@ p.grid {
2829
font-size: 32px;
2930
}
3031

31-
p.grid i.si {
32+
p.grid i.si,
33+
p.grid i.si-squared {
3234
margin: 0 4px;
3335
padding: 4px;
3436
border: 1px dashed gray;

preview/html/testpage.pug

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ body
1515
.buttons-list
1616
button.background-mode Dark background
1717
button.icons-color Colorless icons
18+
button.icons-style Squared
1819

1920
p.grid
2021
each icon in icons
@@ -24,3 +25,7 @@ body
2425
| An icon like #[i.si.si--color.si-github(title='Github')] inside a paragraph.
2526
p.paragraph
2627
| An icon like #[em #[i.si.si--color.si-github(title='Github')]] in italics inside a paragraph.
28+
p.paragraph
29+
| The wide icon in regular style #[i.si.si--color.si-go.style-immutable(title='Go')] in a paragraph.
30+
p.paragraph
31+
| The wide icon in squared style #[i.si-squared.si--color.si-go.style-immutable(title='Go')] in a paragraph.

0 commit comments

Comments
 (0)