Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
9 changes: 9 additions & 0 deletions .changeset/little-sheep-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@hashicorp/design-system-components": minor
---

`CodeBlock` - Updated focus ring colors in interactive elements to fix a11y color contrast issues

`CodeEditor` - Updated focus ring colors in interactive elements to fix a11y color contrast issues

`SideNav` - Updated focus ring colors in interactive elements to fix a11y color contrast issues
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ export const HDS_CODE_EDITOR_COLOR_FOREGROUND_CRITICAL = '#EF3016';
export const HDS_CODE_EDITOR_COLOR_SURFACE_PRIMARY = '#0D0E12';
export const HDS_CODE_EDITOR_COLOR_SURFACE_FAINT = '#15181e';
export const HDS_CODE_EDITOR_COLOR_SURFACE_INTERACTIVE_ACTIVE = '#2B303C';
export const HDS_CODE_EDITOR_COLOR_FOCUS_ACTION_INTERNAL = '#9BC7FD';
export const HDS_CODE_EDITOR_COLOR_FOCUS_ACTION_EXTERNAL = '#0D69F2';
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
HDS_CODE_EDITOR_COLOR_SURFACE_INTERACTIVE_ACTIVE,
HDS_CODE_EDITOR_COLOR_FOREGROUND_CRITICAL,
HDS_CODE_EDITOR_COLOR_FOREGROUND_FAINT,
HDS_CODE_EDITOR_COLOR_FOCUS_ACTION_INTERNAL,
HDS_CODE_EDITOR_COLOR_FOCUS_ACTION_EXTERNAL,
} from '../palettes/hds-dark-palette.ts';

const CLOSE_BUTTON_SELECTOR = '.cm-panel.cm-panel-lint button[name="close"]';
Expand Down Expand Up @@ -125,8 +127,8 @@ const hdsDark = EditorView.theme(
'.cm-panel.cm-panel-lint ul:focus li.cm-diagnostic[aria-selected]': {
background: 'none',
backgroundColor: 'var(--token-color-palette-neutral-700)',
border: `4px solid var(--token-color-focus-critical-external)`,
boxShadow: `inset 0 0 0 1px var(--token-color-focus-critical-internal)`,
border: `4px solid ${HDS_CODE_EDITOR_COLOR_FOCUS_ACTION_EXTERNAL}`,
boxShadow: `inset 0 0 0 1px ${HDS_CODE_EDITOR_COLOR_FOCUS_ACTION_INTERNAL}`,
color: 'var(--token-color-foreground-high-contrast)',
},
'.cm-panels-bottom .cm-panel.cm-panel-lint': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ $hds-code-block-code-padding: 16px;
&.mock-focus,
&:focus-visible {
background-color: var(--hds-code-block-color-surface-faint);
border-color: var(--hds-code-block-color-focus-action-internal);

&::before {
border-color: var(--hds-code-block-color-focus-action-external);
}
}

&.hds-copy-button--status-success {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
// lines of code - highlighted ----
--hds-code-block-color-line-highlight: rgba(0, 74, 222, 20%);
--hds-code-block-color-line-highlight-border: #1555d4;
// Copy Button
--hds-code-block-color-focus-action-internal: #9bc7fd;
--hds-code-block-color-focus-action-external: #0d69f2;

// Syntax highlighting tokens:
// general ----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@
&:focus,
&:hover {
background-color: var(--hds-code-editor-color-surface-primary);
border-color: var(--hds-code-editor-color-focus-action-internal);

&::before {
border-color: var(--hds-code-editor-color-focus-action-external);
}

.hds-button__icon {
color: var(--hds-code-editor-color-foreground-primary);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@
--hds-code-editor-color-surface-faint: #15181e;
--hds-code-editor-color-surface-primary: #0d0e12;
--hds-code-editor-color-surface-interactive-active: #2b303c;
--hds-code-editor-color-focus-action-internal: #9bc7fd;
--hds-code-editor-color-focus-action-external: #0d69f2;
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@

// <a>/<button> element (via Hds::Interactive)
.hds-side-nav__list-item-link {
// Override token used in focus ring mixin
--token-focus-ring-action-box-shadow: var(--hds-app-sidenav-focus-ring-action-box-shadow);
display: flex;
gap: var(--token-side-nav-body-list-item-content-spacing-horizontal);
align-items: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@

&:focus-visible,
&.mock-focus {
border-color: var(--token-color-focus-action-internal);
outline: 3px solid var(--token-color-focus-action-external);
border-color: var(--hds-app-sidenav-color-focus-action-internal);
outline: 3px solid var(--hds-app-sidenav-color-focus-action-external);

&::before,
&::after {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// SIDE-NAV - VARS
//

@use "../../mixins/interactive-dark-theme" as *;

// LOCAL VARIABLES
// we use `hds-app` as prefix to distinguish them from the normal tokens
// notice: they may be overwritten at consumer-level side if needed by re-defining the variables in a container element
Expand All @@ -24,6 +26,10 @@
--hds-app-sidenav-animation-easing: cubic-bezier(0.65, 0, 0.35, 1);
// toggle-button
--hds-app-sidenav-toggle-button-width: 24px;
// focus ring
--hds-app-sidenav-color-focus-action-internal: #{$hds-interactive-dark-theme-color-focus-action-internal};
--hds-app-sidenav-color-focus-action-external: #{$hds-interactive-dark-theme-color-focus-action-external};
--hds-app-sidenav-focus-ring-action-box-shadow: #{$hds-interactive-dark-theme-focus-ring-action-box-shadow};
}

// reduced motion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@
@use "../mixins/focus-ring" as *;
@use "../mixins/button" as *;

$hds-interactive-dark-theme-color-focus-action-internal: #bcc7fd;
$hds-interactive-dark-theme-color-focus-action-external: #0d69f2;
$hds-interactive-dark-theme-focus-ring-action-box-shadow:
inset 0 0 0 1px #{$hds-interactive-dark-theme-color-focus-action-internal},
0 0 0 3px #{$hds-interactive-dark-theme-color-focus-action-external};

// Used to apply dark theme to interactive elements such as Button & Dropdown
@mixin hds-interactive-dark-theme($add-visible-border: true, $is-within-side-nav: false) {
// Override token used in focus ring mixin
--token-focus-ring-action-box-shadow: #{$hds-interactive-dark-theme-focus-ring-action-box-shadow};

// Default:
border: 1px solid transparent;
cursor: pointer;
Expand Down Expand Up @@ -55,20 +64,19 @@
background-color: var(--token-color-palette-neutral-700);

@if ($add-visible-border) {
border-color: var(--token-color-focus-action-internal);
border-color: $hds-interactive-dark-theme-color-focus-action-internal;
}

// focus ring:
&::before {
color: var(--token-color-foreground-high-contrast);
border: none;
box-shadow: var(--token-focus-ring-action-box-shadow);
}
}

// override style removing the focus style
&:focus:focus:not(:focus-visible)::before {
box-shadow: var(--token-focus-ring-action-box-shadow);
box-shadow: $hds-interactive-dark-theme-focus-ring-action-box-shadow;
}

// Active:
Expand Down