Skip to content

Commit

Permalink
Merge pull request #3241 from mi6/fix/3234-slotted-footer-link-wrong-…
Browse files Browse the repository at this point in the history
…colour

Fix/3234 slotted footer link wrong colour
  • Loading branch information
GCHQ-Developer-847 authored Feb 24, 2025
2 parents 9db9933 + 3c512ef commit 2629dd2
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 20 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 8 additions & 6 deletions packages/react/src/component-tests/IcFooter/IcFooterTestData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export const Default = () => {
<IcFooterLink slot="link" href="/">
Components
</IcFooterLink>
<IcFooterLink slot="link" href="/">
Patterns
<IcFooterLink slot="link">
<a href="/">Patterns</a>
</IcFooterLink>
</IcFooter>
);
Expand All @@ -38,7 +38,7 @@ export const GroupedLinks = () => {
return (
<IcFooter
groupLinks
description="The ICDS is maintained by the Design Practice Team. If you've got a question or want to feedback,
description="The ICDS is maintained by the Design Practice Team. If you've got a question or want to feedback,
please get in touch."
>
<IcFooterLinkGroup slot="link" label="Grouped heading">
Expand Down Expand Up @@ -369,7 +369,7 @@ export const WithClassificationBanner = () => {
<IcClassificationBanner classification="official" />
<IcFooter
aligned="full-width"
description="The ICDS is maintained by the Design Practice Team. If you've got a question or want to feedback,
description="The ICDS is maintained by the Design Practice Team. If you've got a question or want to feedback,
please get in touch."
caption="All content is available under the Open Government Licence v3.0, except source code and code examples which are available under the MIT Licence."
style={{ position: "fixed", bottom: "0", left: "0", right: "0" }}
Expand Down Expand Up @@ -467,7 +467,7 @@ export const Brand = () => {
<IcFooter
aligned="full-width"
group-links
description="The ICDS is maintained by the Design Practice Team. If you've got a question or want to feedback,
description="The ICDS is maintained by the Design Practice Team. If you've got a question or want to feedback,
please get in touch."
caption="All content is available under the Open Government Licence v3.0, except source code and code examples which are available under the MIT Licence."
style={{ position: "fixed", bottom: "0", left: "0", right: "0" }}
Expand All @@ -494,7 +494,9 @@ export const Brand = () => {
<IcFooterLink href="/">Styles</IcFooterLink>
<IcFooterLink href="/">Components</IcFooterLink>
<IcFooterLink href="/">Patterns</IcFooterLink>
<IcFooterLink href="/">Design toolkit</IcFooterLink>
<IcFooterLink>
<a href="/">Design toolkit</a>
</IcFooterLink>
</IcFooterLinkGroup>
<div
slot="logo"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
LongWordAppTitle,
SimpleTopNav,
Brand,
BrandWithSlottedNavItems,
ThemeDark,
TopNavWithNavItems,
TopNavWithSearch,
Expand Down Expand Up @@ -362,6 +363,17 @@ describe("IcTopNavigation desktop visual regression tests", () => {
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.019),
});
});

it("should render with different brand color with slotted navigation items", () => {
mount(<BrandWithSlottedNavItems />);
cy.checkHydrated(TOP_NAV_SELECTOR);

cy.checkA11yWithWait();
cy.compareSnapshot({
name: "/brand-slotted-navigation-items",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD),
});
});
});

describe("IcTopNavigation mobile visual regression tests", () => {
Expand Down Expand Up @@ -595,7 +607,7 @@ describe("IcTopNavigation desktop visual regression tests in high contrast mode"

cy.compareSnapshot({
name: "/slotted-navigation-items-high-contrast",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD + 0.045),
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD),
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,11 @@ export const WithNavItems = (): ReactElement => {

export const WithSlottedNavItems = (): ReactElement => {
return (
<IcTopNavigation appTitle="ApplicationName" status="alpha" version="v0.0.7">
<IcTopNavigation status="alpha" version="v0.0.7">
<ReusableAppIcon />
<a href="/" slot="app-title">
ApplicationName
</a>
<IcSearchBar slot="search" label="Search" placeholder="Search" />
<IcNavigationButton label="Button One" slot="buttons">
<ReusableIcon />
Expand Down Expand Up @@ -333,6 +336,33 @@ export const Brand = (): ReactElement => {
);
};

export const BrandWithSlottedNavItems = (): ReactElement => {
return (
<div>
<IcTheme brandColor="rgb(255, 201, 60)" />
<IcTopNavigation status="alpha" version="v0.0.7">
<ReusableAppIcon />
<a href="/" slot="app-title">
ApplicationName
</a>
<IcSearchBar slot="search" label="Search" placeholder="Search" />
<IcNavigationButton label="Button One" slot="buttons">
<ReusableIcon />
</IcNavigationButton>
<IcNavigationItem slot="navigation">
<a href="/">One</a>
</IcNavigationItem>
<IcNavigationItem slot="navigation">
<a href="/">Two</a>
</IcNavigationItem>
<IcNavigationItem slot="navigation">
<a href="/">Three</a>
</IcNavigationItem>
</IcTopNavigation>
</div>
);
};

export const ThemeDark = (): ReactElement => {
return (
<IcTopNavigation
Expand Down
6 changes: 3 additions & 3 deletions packages/react/src/stories/ic-footer.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export const WithClassificationBanner = {
<IcClassificationBanner classification="official" />
<IcFooter
aligned="full-width"
description="The ICDS is maintained by the Design Practice Team. If you've got a question or want to feedback,
description="The ICDS is maintained by the Design Practice Team. If you've got a question or want to feedback,
please get in touch."
caption="All content is available under the Open Government Licence v3.0, except source code and code examples which are available under the MIT Licence."
style={{ position: "fixed", bottom: "0", left: "0", right: "0" }}
Expand Down Expand Up @@ -318,12 +318,12 @@ export const WithReactRouter = {
style={{ bottom: "0", left: "0", right: "0" }}
>
<IcFooterLink slot="link">
<NavLink to="/" style={{ color: "var(--ic-brand-text-color)" }}>
<NavLink to="/">
Home
</NavLink>
</IcFooterLink>
<IcFooterLink slot="link">
<NavLink to="/daily-tippers" style={{ color: "var(--ic-brand-text-color)" }}>
<NavLink to="/daily-tippers">
Daily Tippers test
</NavLink>
</IcFooterLink>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ exports[`ic-footer-link-group should render small: footer-link-group-small 1`] =
</mock:shadow-root>
<ic-footer-link class="footer-link footer-link-light footer-link-ungrouped-small" href="/" role="listitem">
<mock:shadow-root>
<ic-link href="/">
<ic-link class="footer-link" href="/">
<slot></slot>
</ic-link>
</mock:shadow-root>
Expand All @@ -60,7 +60,7 @@ exports[`ic-footer-link-group should render with links: footer-link-group-with-l
</mock:shadow-root>
<ic-footer-link class="footer-link footer-link-light footer-link-ungrouped-sparse" href="/" role="listitem">
<mock:shadow-root>
<ic-link href="/">
<ic-link class="footer-link" href="/">
<slot></slot>
</ic-link>
</mock:shadow-root>
Expand Down Expand Up @@ -99,7 +99,7 @@ exports[`ic-footer-link-group should render within footer: footer-link-group-in-
</mock:shadow-root>
<ic-footer-link class="footer-link footer-link-light footer-link-ungrouped-sparse" href="/" role="listitem">
<mock:shadow-root>
<ic-link href="/">
<ic-link class="footer-link" href="/">
<slot></slot>
</ic-link>
</mock:shadow-root>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export class FooterLink {
role="listitem"
>
<ic-link
class="footer-link"
href={href}
hreflang={hreflang}
referrerpolicy={referrerpolicy}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`ic-footer-link should render small with grouped links: small-footer-link-with-grouped-links 1`] = `
<ic-footer-link class="footer-link footer-link-grouped-small footer-link-light" href="/" role="listitem">
<mock:shadow-root>
<ic-link href="/">
<ic-link class="footer-link" href="/">
<slot></slot>
</ic-link>
</mock:shadow-root>
Expand All @@ -14,7 +14,7 @@ exports[`ic-footer-link should render small with grouped links: small-footer-lin
exports[`ic-footer-link should render: footer-link 1`] = `
<ic-footer-link class="footer-link footer-link-light footer-link-ungrouped-sparse" href="/" role="listitem">
<mock:shadow-root>
<ic-link href="/">
<ic-link class="footer-link" href="/">
<slot></slot>
</ic-link>
</mock:shadow-root>
Expand Down
6 changes: 6 additions & 0 deletions packages/web-components/src/components/ic-link/ic-link.css
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,9 @@
:host(.breadcrumb-link.current-page) .link:visited {
color: var(--ic-color-text-primary);
}

/* Footer link */

:host(.footer-link) ::slotted(a) {
color: var(--ic-footer-link) !important;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@

--ic-button-secondary-text-monochrome: var(--ic-brand-text-color);
--ic-button-secondary-border-monochrome: var(--ic-brand-text-color);
--navigation-link-colour: var(--ic-top-navigation-text);
}

:host(.dark) {
color: var(--ic-color-text-primary-light);
--ic-typography-color: var(--ic-color-text-primary-light);
--ic-top-navigation-logo: var(--ic-color-icon-neutral);
--ic-top-navigation-icon: var(--ic-color-icon-neutral);
--ic-top-navigation-icon-and-label: var(--ic-color-text-primary-light);
--ic-top-navigation-theme: var(--ic-color-icon-neutral);
--ic-top-navigation-status-tag: var(--ic-color-background-primary-dark);
--ic-top-navigation-status-tag-text: var(--ic-color-brand-text);
--ic-top-navigation-status-tag-secondary: var(--ic-state-layer-darken-10);
--ic-top-navigation-title-hover: var(--ic-action-dark-bg-hover);
--ic-top-navigation-title-pressed: var(--ic-action-dark-bg-pressed);
--navigation-link-colour: var(--ic-color-text-primary-light);
}

:host ::slotted(ic-navigation-item) {
--navigation-link-colour: var(--ic-top-navigation-text);
}

:host(.dark) ::slotted(ic-navigation-button) {
--ic-button-icon-monochrome: var(--ic-color-text-primary-light);
}
Expand Down

0 comments on commit 2629dd2

Please sign in to comment.