Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(icons): prevent the textual representation from being announced #2040

12 changes: 10 additions & 2 deletions packages/foundations/scss/icons/_icon-helpers.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ $default-icon-font-size: var(--db-icon-font-size, #{$default-icon-size-rem});
@return 32;
}

@mixin icon-content($icon) {
content: $icon;
// Hiding icon from screenreaders, https://www.w3.org/TR/css-content-3/#alt
@supports (content: ""/"") {
content: $icon / "";
}
}

@mixin to-filled-icon($position: "before") {
@if $position == "before" {
--db-icon-font-family: "db-ux-filled";
Expand All @@ -60,7 +68,7 @@ $default-icon-font-size: var(--db-icon-font-size, #{$default-icon-size-rem});
}
@if $position == "after" {
--db-icon-after: "#{$icon}";
content: $default-icon-content-after;
@include icon-content($default-icon-content-after);
margin-inline-start: $default-icon-margin-start;
}
}
Expand Down Expand Up @@ -105,11 +113,11 @@ $default-icon-font-size: var(--db-icon-font-size, #{$default-icon-size-rem});
}

%icon {
@include icon-content($default-icon-content); // TODO: ONLY FOR data-icon
// Hiding icon from screenreaders
-webkit-alt: "";
alt: "";

content: $default-icon-content; // TODO: ONLY FOR data-icon
color: var(--db-current-icon-color, inherit);

display: inline-block;
Expand Down
4 changes: 3 additions & 1 deletion packages/foundations/scss/icons/include.scss
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@
[data-icon-after] {
&::after {
@extend %icon !optional;
content: icon-helpers.$default-icon-content-after;
@include icon-helpers.icon-content(
icon-helpers.$default-icon-content-after
);
margin-inline-start: icon-helpers.$default-icon-margin-start;
}
}
Expand Down
Loading