Skip to content

Commit 244b214

Browse files
authored
refactor(icon): provide possibility for overwrites (#398)
for font-size of the icons from the outside.
1 parent bd98a9a commit 244b214

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

source/_patterns/00-base/icons/_icons.helpers.scss

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
&::#{$position} {
1010
--icon-font-family: "#{"icons-" + $size + "-" + $style}",
1111
"missing-icons" !important;
12-
--icon-font-size: #{to-rem($pxValue: $size)};
12+
13+
font-size: var(
14+
--icon-font-size-#{$position},
15+
var(--icon-font-size, #{to-rem($pxValue: $size)})
16+
);
1317

1418
@if $position == "before" {
1519
margin-inline-end: var(--icon-margin-after, #{$icon-content-space});
@@ -30,8 +34,6 @@
3034
/*** icon - partial ***/
3135
// * use !important to prevent issues with browser extensions that change fonts
3236
font-family: var(--icon-font-family) !important;
33-
34-
font-size: var(--icon-font-size);
3537
font-style: normal;
3638
font-variant: normal;
3739

source/_patterns/00-base/icons/_icons.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,22 @@ In case of the need to display only the icon and hide the text next to it, use t
9494
.is-icon-text-replace
9595
```
9696

97+
###### Tweaking icons `font-size`
98+
99+
If you'd like to control the icons `font-size` any further (defining sizes in between all of the `data-icon-variant` declarations, like e.g. having an icon `font-size` of `23px` instead of `24px` when defining `data-icon-variant="24-outline"`), you could set set one of the CSS variables `--icon-font-size-before` or `--icon-font-size-after` (in this case `--icon-font-size-before: 23px`).
100+
101+
```html
102+
<a
103+
href="#"
104+
data-icon="alarm"
105+
data-icon-variant="24-outline"
106+
style="--icon-font-size-before: 23px"
107+
>Alarm</a
108+
>
109+
```
110+
111+
#### Further tweaking
112+
97113
### SVG files
98114

99115
As mentioned above we're even also providing all of the icon sources (`svg` files) within this package in the folder `node_modules/@db-ui/core/dist/icons/`.

source/_patterns/00-base/icons/_icons.placeholder.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
// * use !important to prevent issues with browser extensions that change fonts
1111
font-family: var(--icon-font-family) !important;
1212

13-
font-size: var(--icon-font-size);
14-
1513
// * Better Font Rendering ===========
1614
-webkit-font-smoothing: antialiased;
1715
-moz-osx-font-smoothing: grayscale;

source/_patterns/00-base/icons/icons.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,21 @@
1212
&::before {
1313
@extend %icon;
1414
margin-inline-end: var(--icon-margin-after, #{$icon-content-space});
15+
font-size: var(
16+
--icon-font-size-before,
17+
var(--icon-font-size, #{to-rem($pxValue: $icon-size)})
18+
);
1519
}
1620
}
1721

1822
[data-icon-after] {
1923
&::after {
2024
@extend %icon;
2125
margin-inline-start: var(--icon-margin-before, #{$icon-content-space});
26+
font-size: var(
27+
--icon-font-size-after,
28+
var(--icon-font-size, #{to-rem($pxValue: $icon-size)})
29+
);
2230
}
2331
}
2432

0 commit comments

Comments
 (0)