Skip to content

Commit

Permalink
Merge pull request #2942 from mi6/2910-ic-badge-dark-mode-info-varian…
Browse files Browse the repository at this point in the history
…t-icons-are-showing-as-the-wrong-colour

2910 ic badge dark mode info variant icons are showing as the wrong colour
  • Loading branch information
GCHQ-Developer-847 authored Jan 2, 2025
2 parents d6cfe91 + 0e65b33 commit 0756606
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 2 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions packages/react/src/component-tests/IcBadge/IcBadge.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
PositionNear,
PositionInline,
ThemeDark,
ThemeDarkIcon,
} from "./IcBadgeTestData";
import { setThresholdBasedOnEnv } from "../../../cypress/utils/helpers";

Expand Down Expand Up @@ -196,6 +197,18 @@ describe("IcBadge visual regression and a11y tests", () => {
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD),
});
});

it("should render badge with dark theme and icon", () => {
mount(<ThemeDarkIcon />);

cy.checkHydrated(IC_BADGE_SELECTOR);

cy.checkA11yWithWait();
cy.compareSnapshot({
name: "theme-dark-icon",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD),
});
});
});

describe.skip("IcBadge visual regression tests in high contrast mode", () => {
Expand Down
73 changes: 73 additions & 0 deletions packages/react/src/component-tests/IcBadge/IcBadgeTestData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -381,3 +381,76 @@ export const ThemeDark = (): ReactElement => {
</div>
);
};

export const ThemeDarkIcon = (): ReactElement => {
return (
<div style={{ backgroundColor: "black", padding: "16px" }}>
<IcButton
variant="secondary"
theme="dark"
monochrome
style={{ marginRight: "16px" }}
>
<IcBadge type="icon" slot="badge" theme="dark">
<ReusableSlottedIcon />
</IcBadge>
Neutral
</IcButton>
<IcButton
variant="secondary"
theme="dark"
monochrome
style={{ marginRight: "16px" }}
>
<IcBadge type="icon" slot="badge" theme="dark" variant="light">
<ReusableSlottedIcon />
</IcBadge>
Light
</IcButton>
<IcButton
variant="secondary"
theme="dark"
monochrome
style={{ marginRight: "16px" }}
>
<IcBadge type="icon" slot="badge" theme="dark" variant="error">
<ReusableSlottedIcon />
</IcBadge>
Error
</IcButton>
<IcButton
variant="secondary"
theme="dark"
monochrome
style={{ marginRight: "16px" }}
>
<IcBadge type="icon" slot="badge" theme="dark" variant="success">
<ReusableSlottedIcon />
</IcBadge>
Success
</IcButton>
<IcButton
variant="secondary"
theme="dark"
monochrome
style={{ marginRight: "16px" }}
>
<IcBadge type="icon" slot="badge" theme="dark" variant="warning">
<ReusableSlottedIcon />
</IcBadge>
Warning
</IcButton>
<IcButton
variant="secondary"
theme="dark"
monochrome
style={{ marginRight: "16px" }}
>
<IcBadge type="icon" slot="badge" theme="dark" variant="info">
<ReusableSlottedIcon />
</IcBadge>
Info
</IcButton>
</div>
);
};
4 changes: 2 additions & 2 deletions packages/web-components/src/global/color-mode.css
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,7 @@ ic-theme,

/* Badge */
--ic-badge-text: var(--ic-color-text-inverse);
--ic-badge-icon: var(--ic-color-icon-inverted);
--ic-badge-icon: var(--ic-color-icon-neutral);
--ic-badge-warning-text: var(--ic-color-text-inverse);
--ic-badge-warning-icon: var(--ic-color-icon-neutral);
--ic-badge-text-monochrome: var(--ic-color-text-primary);
Expand Down Expand Up @@ -3073,7 +3073,7 @@ ic-theme,

/* Badge */
--ic-badge-text: var(--ic-color-text-inverse);
--ic-badge-icon: var(--ic-color-icon-inverted);
--ic-badge-icon: var(--ic-color-icon-neutral);
--ic-badge-warning-text: var(--ic-color-text-inverse);
--ic-badge-warning-icon: var(--ic-color-icon-neutral);
--ic-badge-text-monochrome: var(--ic-color-text-primary);
Expand Down

0 comments on commit 0756606

Please sign in to comment.