Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/good-years-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@frontify/fondue-components": patch
"@frontify/fondue": patch
---

fix(Button): icon hover state colors
167 changes: 53 additions & 114 deletions packages/components/src/components/Button/styles/button.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,48 @@
@use '../../../utilities/transitions.module.scss';
@use '../../../utilities/sizeToken.module.scss';

// Icon colors for a variant, applied from within the variant's own selector
@mixin icon-colors($text-color, $text-hover, $text-active, $icon-color, $icon-hover, $icon-active) {
& svg {

Check warning on line 9 in packages/components/src/components/Button/styles/button.module.scss

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Missing scoping root

See more on https://sonarcloud.io/project/issues?id=Frontify_arcade&issues=AZ_GdRbk1Yt1fFEnnAM1&open=AZ_GdRbk1Yt1fFEnnAM1&pullRequest=2816
@if $icon-color {
color: var(--color-#{$icon-color});
} @else {
color: var(--color-#{$text-color});
}

line-height: 0;
}

@if $icon-hover {
&:hover svg {

Check warning on line 20 in packages/components/src/components/Button/styles/button.module.scss

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Missing scoping root

See more on https://sonarcloud.io/project/issues?id=Frontify_arcade&issues=AZ_GdRbk1Yt1fFEnnAM2&open=AZ_GdRbk1Yt1fFEnnAM2&pullRequest=2816
color: var(--color-#{$icon-hover});
}
} @else if $text-hover {
&:hover svg {

Check warning on line 24 in packages/components/src/components/Button/styles/button.module.scss

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Missing scoping root

See more on https://sonarcloud.io/project/issues?id=Frontify_arcade&issues=AZ_GdRbk1Yt1fFEnnAM3&open=AZ_GdRbk1Yt1fFEnnAM3&pullRequest=2816
color: var(--color-#{$text-hover});
}
}

@if $icon-active {
&:active svg {

Check warning on line 30 in packages/components/src/components/Button/styles/button.module.scss

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Missing scoping root

See more on https://sonarcloud.io/project/issues?id=Frontify_arcade&issues=AZ_GdRbk1Yt1fFEnnAM4&open=AZ_GdRbk1Yt1fFEnnAM4&pullRequest=2816
color: var(--color-#{$icon-active});
}
} @else if $text-active {
&:active svg {

Check warning on line 34 in packages/components/src/components/Button/styles/button.module.scss

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Missing scoping root

See more on https://sonarcloud.io/project/issues?id=Frontify_arcade&issues=AZ_GdRbk1Yt1fFEnnAM5&open=AZ_GdRbk1Yt1fFEnnAM5&pullRequest=2816
color: var(--color-#{$text-active});
}
}

// Forced colors mode support
@media (forced-colors: active) {
& svg,

Check warning on line 41 in packages/components/src/components/Button/styles/button.module.scss

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Missing scoping root

See more on https://sonarcloud.io/project/issues?id=Frontify_arcade&issues=AZ_GdRbk1Yt1fFEnnAM6&open=AZ_GdRbk1Yt1fFEnnAM6&pullRequest=2816
&:hover svg,

Check warning on line 42 in packages/components/src/components/Button/styles/button.module.scss

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Missing scoping root

See more on https://sonarcloud.io/project/issues?id=Frontify_arcade&issues=AZ_GdRbk1Yt1fFEnnAM7&open=AZ_GdRbk1Yt1fFEnnAM7&pullRequest=2816
&:active svg {

Check warning on line 43 in packages/components/src/components/Button/styles/button.module.scss

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Missing scoping root

See more on https://sonarcloud.io/project/issues?id=Frontify_arcade&issues=AZ_GdRbk1Yt1fFEnnAM8&open=AZ_GdRbk1Yt1fFEnnAM8&pullRequest=2816
color: CanvasText;
}
}
}

// Mixin for button variants
@mixin variant(
$variant,
Expand Down Expand Up @@ -44,48 +86,7 @@
}

// Icon styles
& svg {
@if $icon-color {
color: var(--color-#{$icon-color});
} @else {
color: var(--color-#{$text-color});
}

@if $icon-hover {
.root:hover & {
color: var(--color-#{$icon-hover});
}
} @else if $text-hover {
.root:hover & {
color: var(--color-#{$text-hover});
}
}

@if $icon-active {
.root:active & {
color: var(--color-#{$icon-active});
}
} @else if $text-active {
.root:active & {
color: var(--color-#{$text-active});
}
}

line-height: 0;

// Forced colors mode support
@media (forced-colors: active) {
color: CanvasText;

.root:hover & {
color: CanvasText;
}

.root:active & {
color: CanvasText;
}
}
}
@include icon-colors($text-color, $text-hover, $text-active, $icon-color, $icon-hover, $icon-active);
}
}

Expand Down Expand Up @@ -127,48 +128,7 @@
}

// Icon styles
& svg {
@if $icon-color {
color: var(--color-#{$icon-color});
} @else {
color: var(--color-#{$text-color});
}

@if $icon-hover {
.root:hover & {
color: var(--color-#{$icon-hover});
}
} @else if $text-hover {
.root:hover & {
color: var(--color-#{$text-hover});
}
}

@if $icon-active {
.root:active & {
color: var(--color-#{$icon-active});
}
} @else if $text-active {
.root:active & {
color: var(--color-#{$text-active});
}
}

line-height: 0;

// Forced colors mode support
@media (forced-colors: active) {
color: CanvasText;

.root:hover & {
color: CanvasText;
}

.root:active & {
color: CanvasText;
}
}
}
@include icon-colors($text-color, $text-hover, $text-active, $icon-color, $icon-hover, $icon-active);
}
}

Expand Down Expand Up @@ -273,10 +233,7 @@
'container-error-active',
'container-error-on-error-container',
'container-error-on-error-container',
'container-error-on-error-container',
'container-error-on-error-container',
'button-negative-icon-hover',
'button-negative-icon-pressed'
'container-error-on-error-container'
);

// Negative variant - weak emphasis
Expand Down Expand Up @@ -372,32 +329,14 @@
color: var(--color-container-highlight-on-highlight-container);
}

& svg {
color: var(--color-highlight-default);

.root:hover & {
color: var(--color-container-highlight-on-highlight-container);
}

.root:active & {
color: var(--color-container-highlight-on-highlight-container);
}

line-height: 0;

// Forced colors mode support
@media (forced-colors: active) {
color: CanvasText;

.root:hover & {
color: CanvasText;
}

.root:active & {
color: CanvasText;
}
}
}
@include icon-colors(
'highlight-default',
'container-highlight-on-highlight-container',
'container-highlight-on-highlight-container',
null,
null,
null
);
}

// Loud variant - strong emphasis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ test('should display correct clearIcon colors in different hover states', async
await clearButton.hover();
const clearButtonHoveredColor = await clearIcon.evaluate((el) => getComputedStyle(el).getPropertyValue('color'));
console.log(clearButtonHoveredColor);
expect(clearButtonHoveredColor).toBe('rgb(17, 17, 16)');
expect(clearButtonHoveredColor).toBe('rgb(53, 53, 51)');
});

test('should strip leading # when typing hex value', async ({ mount }) => {
Expand Down