Skip to content

Commit

Permalink
HDS-3373 Add conditionals to dark theme mixin for sidenav
Browse files Browse the repository at this point in the history
  • Loading branch information
KristinLBradley committed Jun 25, 2024
1 parent 87dcaa2 commit e3c5b21
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
// "home-link"

.hds-side-nav__home-link {
@include hds-interactive-dark-theme($add-visible-border: false);
@include hds-interactive-dark-theme($add-visible-border: false, $is-within-side-nav: true);
display: block;
width: 100%;
height: 100%;
Expand All @@ -62,7 +62,7 @@
.hds-side-nav__dropdown { // ⬅︎ add this class name to the `Hds::Dropdown` component to apply the style overrides
.hds-dropdown-toggle-icon,
.hds-dropdown-toggle-button {
@include hds-interactive-dark-theme();
@include hds-interactive-dark-theme($add-visible-border: true, $is-within-side-nav: true);
}
}

Expand Down
43 changes: 34 additions & 9 deletions packages/components/src/styles/mixins/_interactive-dark-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,23 @@

@use "../mixins/focus-ring" as *;

// TODO: Deprecate SideNav specific dark theme tokens in favor of general dark theme tokens

// Used to apply dark theme to interactive elements such as Button & Dropdown
@mixin hds-interactive-dark-theme($add-visible-border: true) {
color: var(--token-color-palette-neutral-0);
background-color: var(--token-color-palette-neutral-700);
@mixin hds-interactive-dark-theme($add-visible-border: true, $is-within-side-nav: false) {
@if $is-within-side-nav {
// sidenav specific dark theme tokens
color: var(--token-side-nav-color-foreground-strong);
background-color: transparent; // test
border-radius: var(--token-side-nav-body-list-item-border-radius);
} @else {
// general dark theme tokens
color: var(--token-color-palette-neutral-0);
background-color: var(--token-color-palette-neutral-700);
border-radius: var(--token-form-control-border-radius);
}

border: 1px solid transparent;
border-radius: var(--token-side-nav-body-list-item-border-radius);
cursor: pointer;

@if ($add-visible-border) {
Expand All @@ -37,19 +48,33 @@

&:hover,
&.mock-hover {
color: var(--token-color-palette-neutral-0); // to avoid overrides by specificity (eg. `a:hover`)
background-color: var(--token-color-palette-neutral-600);

@if $is-within-side-nav {
// sidenav specific dark theme tokens
color: var(--token-side-nav-color-foreground-strong); // to avoid overrides by specificity (eg. `a:hover`)
background-color: var(--token-side-nav-color-surface-interactive-hover);
} @else {
// general dark theme tokens
color: var(--token-color-palette-neutral-0); // to avoid overrides by specificity (eg. `a:hover`)
background-color: var(--token-color-palette-neutral-600);
}

@if ($add-visible-border) {
border-color: var(--token-color-palette-neutral-500);
}
}

&:active,
&.mock-active {
color: var(--token-color-palette-neutral-0); // to avoid overrides by specificity (eg. `a:hover`)
@if $is-within-side-nav {
// sidenav specific dark theme tokens
color: var(--token-side-nav-color-foreground-strong); // to avoid overrides by specificity (eg. `a:hover`)
background-color: var(--token-side-nav-color-surface-interactive-active);
} @else {
// general dark theme tokens
color: var(--token-color-palette-neutral-0); // to avoid overrides by specificity (eg. `a:hover`)
background-color: var(--token-color-palette-neutral-500);

}

@if ($add-visible-border) {
border-color: var(--token-color-palette-neutral-400);
}
Expand Down

0 comments on commit e3c5b21

Please sign in to comment.