Skip to content

Commit

Permalink
Add support multiple font styles
Browse files Browse the repository at this point in the history
  • Loading branch information
LitoMore committed Dec 28, 2024
1 parent b8c397e commit 9d85bcd
Show file tree
Hide file tree
Showing 9 changed files with 209 additions and 67 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ Where `[ICON NAME]` is replaced by the icon name, for example:
<i class="si si-simpleicons si--color"></i>
```

Or use the squared font, all font will rendered in the same-sized square:

```html
<i class="si-squared si-simpleicons"></i>
<i class="si-squared si-simpleicons si--color"></i>
```

In this example we use the `<i>` tag, but any inline HTML tag should work as you expect.

[latest-release]: https://github.com/simple-icons/simple-icons-font/releases/latest
Expand Down
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"semver": "7.6.2",
"serve": "14.2.3",
"simple-icons": "14.0.0",
"svg-path-bbox": "2.1.0",
"svg2ttf": "6.0.3",
"svgpath": "2.6.0",
"ttf2eot": "3.1.0",
Expand Down
26 changes: 25 additions & 1 deletion preview/assets/script.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
document.addEventListener('DOMContentLoaded', () => {
const $body = document.querySelector('body');
const $icons = document.getElementsByClassName('si');
const $icons = document.getElementsByTagName('i');
const $backgroundModeButton = document.querySelector('.background-mode');
const $iconsColorButton = document.querySelector('.icons-color');
const $iconsStyleButton = document.querySelector('.icons-style');

// Background dark/light mode toggler
$backgroundModeButton.addEventListener('click', () => {
Expand All @@ -26,4 +27,27 @@ document.addEventListener('DOMContentLoaded', () => {
$icons[i].classList.toggle('si--color');
}
});

// Icons style toggle
$iconsStyleButton.addEventListener('click', () => {
const isSquared = $icons[0].classList.contains('si-squared');
if (isSquared) {
$iconsStyleButton.innerText = 'Regular';
} else {
$iconsStyleButton.innerText = 'Squared';
}

for (let i = 0; i < $icons.length; i++) {
if ($icons[i].classList.contains('style-immutable')) {
continue;
}
if (isSquared) {
$icons[i].classList.remove('si-squared');
$icons[i].classList.add('si');
} else {
$icons[i].classList.remove('si');
$icons[i].classList.add('si-squared');
}
}
});
});
6 changes: 4 additions & 2 deletions preview/assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ body.dark {
cursor: pointer;
}

i.si {
i.si,
i.si-squared {
display: inline-block;
cursor: help;
}
Expand All @@ -28,7 +29,8 @@ p.grid {
font-size: 32px;
}

p.grid i.si {
p.grid i.si,
p.grid i.si-squared {
margin: 0 4px;
padding: 4px;
border: 1px dashed gray;
Expand Down
5 changes: 5 additions & 0 deletions preview/html/testpage.pug
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ body
.buttons-list
button.background-mode Dark background
button.icons-color Colorless icons
button.icons-style Squared

p.grid
each icon in icons
Expand All @@ -24,3 +25,7 @@ body
| An icon like #[i.si.si--color.si-github(title='Github')] inside a paragraph.
p.paragraph
| An icon like #[em #[i.si.si--color.si-github(title='Github')]] in italics inside a paragraph.
p.paragraph
| The wide icon in regular style #[i.si.si--color.si-go.style-immutable(title='Go')] in a paragraph.
p.paragraph
| The wide icon in squared style #[i.si-squared.si--color.si-go.style-immutable(title='Go')] in a paragraph.
Loading

0 comments on commit 9d85bcd

Please sign in to comment.