Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable color contrast and fix issues with components #2647

Merged
merged 26 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7a157bb
feat: enable color contrast and fix issues with components
nmerget May 15, 2024
84604e3
fix: issue with axe and force colors
nmerget May 17, 2024
0fc6de5
chore: update snapshots for high contrast
nmerget May 17, 2024
516251d
chore: add icon colors for button
nmerget May 17, 2024
be7ffcb
Merge branch 'main' into feat-color-contrast
nmerget May 17, 2024
e8c4ca3
fix: reverted changes for icon in contrast mode
nmerget May 21, 2024
d7fa8a7
Merge branch 'main' into feat-color-contrast
nmerget May 21, 2024
ce3d1e8
chore: update from main
nmerget Jun 26, 2024
bac4904
chore: update snapshots
nmerget Jun 27, 2024
a887a6e
Merge branch 'main' of github.com:db-ui/mono into feat-color-contrast
nmerget Jun 27, 2024
fabce38
chore: update snapshots
nmerget Jun 27, 2024
36d1ee5
chore: update from main
nmerget Jul 12, 2024
ce60817
fix: issues with color contrast and current-color
nmerget Jul 12, 2024
74eb025
chore: update snapshots
nmerget Jul 12, 2024
df5c535
Merge branch 'main' into feat-color-contrast
nmerget Jul 15, 2024
4d84498
Merge branch 'main' of github.com:db-ui/mono into feat-color-contrast
nmerget Jul 16, 2024
3ce286c
Merge branch 'main' into feat-color-contrast
nmerget Jul 16, 2024
3f05ac6
fix: issue with contrast color for switch
nmerget Jul 16, 2024
f13b1b1
chore: update snapshots
nmerget Jul 17, 2024
a04bd34
Merge branch 'main' into feat-color-contrast
nmerget Jul 17, 2024
3bd69ba
Merge branch 'main' into feat-color-contrast
mfranzke Jul 17, 2024
544ad1a
Merge branch 'main' into feat-color-contrast
mfranzke Jul 17, 2024
bd775f6
refactor: updated screenshots
mfranzke Jul 17, 2024
834eec0
Merge branch 'main' into feat-color-contrast
nmerget Jul 17, 2024
696def8
Merge branch 'main' into feat-color-contrast
nmerget Jul 17, 2024
97598a7
Merge branch 'main' into feat-color-contrast
mfranzke Jul 17, 2024
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 .xo-config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ module.exports = {
'import/no-extraneous-dependencies': 0 // foundation and component.css are inside this repo
}
},
{
files: ['./showcases/e2e/**'],
rules: {
'@typescript-eslint/no-loop-func': 0 // this is fine for playwright testing
}
},
{
files: ['./**/*.spec.ts'],
rules: {
Expand Down
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
nmerget marked this conversation as resolved.
Show resolved Hide resolved
nmerget marked this conversation as resolved.
Show resolved Hide resolved
17 changes: 17 additions & 0 deletions packages/components/src/components/checkbox/checkbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,22 @@
&:indeterminate {
@include icons.set-icon("minus");
}

@media (forced-colors: active) {
&:indeterminate,
&:checked {
--db-check-element-border-color: #{colors.$db-current-color-on-bg-enabled};

border-width: form-components.$check-border-size;

&::before {
align-content: center;
font-size: calc(
var(--db-icon-font-size) - 2 * #{form-components.$check-border-size}
);
padding: #{form-components.$check-border-size};
}
}
}
}
}
8 changes: 7 additions & 1 deletion packages/components/src/components/switch/switch.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,13 @@ $checked-active-transition-size: calc(

// thumb
&::before {
content: "";
content: "O";
nmerget marked this conversation as resolved.
Show resolved Hide resolved
text-align: center;
align-content: center;
aspect-ratio: 1;
block-size: $switch-inactive-thumb-size;
background-color: colors.$db-current-color-on-bg-enabled;
color: colors.$db-current-color-on-bg-enabled;
border-radius: variables.$db-border-radius-full;
transform: translateX(var(--thumb-offset-x));
margin-inline-end: calc(
Expand Down Expand Up @@ -119,6 +122,7 @@ $checked-active-transition-size: calc(
&::before {
block-size: $switch-active-thumb-size;
background-color: colors.$db-current-color-bg-lvl-1-enabled;
color: colors.$db-current-color-bg-lvl-1-enabled;
margin: 0;
}
}
Expand Down Expand Up @@ -182,11 +186,13 @@ $checked-active-transition-size: calc(

&::before {
background-color: colors.$db-current-color-on-contrast-enabled;
color: colors.$db-current-color-on-contrast-enabled;
}
}

&::before {
background-color: colors.$db-current-color-on-contrast-enabled;
color: colors.$db-current-color-on-contrast-enabled;
block-size: $switch-active-thumb-size;
margin: 0;
}
Expand Down
8 changes: 8 additions & 0 deletions packages/components/src/styles/_db-puls.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,21 @@
&::after {
block-size: variables.$db-border-height-xs;
inline-size: 100%;

@media (forced-colors: active) {
border: calc(#{variables.$db-border-height-xs} - 1px) solid;
}
}
}

@mixin show-db-puls-vertical() {
&::after {
block-size: 100%;
inline-size: variables.$db-border-height-xs;

@media (forced-colors: active) {
border: calc(#{variables.$db-border-height-xs} - 1px) solid;
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions packages/components/src/styles/_form-components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ $input-types: "button", "checkbox", "color", "date", "datetime-local", "email",
"file", "hidden", "image", "month", "number", "password", "radio", "range",
"reset", "search", "submit", "tel", "text", "time", "url", "week";

$check-border-size: min(#{variables.$db-border-height-2xs}, 2px);

%dropdown-icon {
@include icons.set-icon("chevron_down", "after");

Expand Down Expand Up @@ -364,6 +366,7 @@ $input-valid-types: "color", "date", "datetime-local", "email", "file", "hidden"
1
) - 1px
);
color: colors.$db-current-color-on-bg-enabled;
}

&::before {
Expand Down Expand Up @@ -464,8 +467,7 @@ $input-valid-types: "color", "date", "datetime-local", "email", "file", "hidden"
place-content: center center;
appearance: none;
aspect-ratio: 1;
border: min(#{variables.$db-border-height-2xs}, 2px) solid
var(--db-check-element-border-color, currentColor);
border: #{$check-border-size} solid var(--db-check-element-border-color, currentColor);
block-size: $font-size-height;

// TODO: probably extract this to an overwrite or external file
Expand Down
6 changes: 6 additions & 0 deletions packages/foundations/scss/helpers/_divider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,10 @@
inset-block: 0;
}
}

@media (forced-colors: active) {
// border is the better implementation, but border height changes in windows based on pixel density
// we use it as a fallback for color contrast
border: variables.$db-border-height-3xs solid var(--db-divider-bg-color);
}
}
14 changes: 13 additions & 1 deletion showcases/e2e/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
await preScreenShot(page);
}

await expect(page).toHaveScreenshot(

Check failure on line 94 in showcases/e2e/default.ts

View workflow job for this annotation

GitHub Actions / test-showcase-angular / 🧪🎭 - angular-showcase:2/6

[chromium-highContrast] › default.ts:57:2 › DBTag › should match screenshot

1) [chromium-highContrast] › default.ts:57:2 › DBTag › should match screenshot ─────────────────── Error: Screenshot comparison failed: 2867 pixels (ratio 0.01 of all image pixels) are different. Expected: /__w/mono/mono/__snapshots__/tag/showcase/chromium-highContrast/regular/neutral-bg-lvl-1/DBTag-should-match-screenshot.png Received: /__w/mono/mono/showcases/angular-showcase/test-results/tag-showcase-tag-DBTag-should-match-screenshot-chromium-highContrast/regular-neutral-bg-lvl-1-actual.png Diff: /__w/mono/mono/showcases/angular-showcase/test-results/tag-showcase-tag-DBTag-should-match-screenshot-chromium-highContrast/regular-neutral-bg-lvl-1-diff.png Call log: - expect.toHaveScreenshot(regular/neutral-bg-lvl-1.png) with timeout 10000ms - verifying given screenshot expectation - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - 2867 pixels (ratio 0.01 of all image pixels) are different. - waiting 100ms before taking screenshot - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - captured a stable screenshot - 2867 pixels (ratio 0.01 of all image pixels) are different. 92 | } 93 | > 94 | await expect(page).toHaveScreenshot( | ^ 95 | [density, `neutral-bg-lvl-1.png`], 96 | config 97 | ); at /__w/mono/mono/showcases/e2e/default.ts:94:22

Check failure on line 94 in showcases/e2e/default.ts

View workflow job for this annotation

GitHub Actions / test-showcase-angular / 🧪🎭 - angular-showcase:2/6

[chromium-highContrast] › default.ts:57:2 › DBTag › should match screenshot

1) [chromium-highContrast] › default.ts:57:2 › DBTag › should match screenshot ─────────────────── Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Screenshot comparison failed: 2867 pixels (ratio 0.01 of all image pixels) are different. Expected: /__w/mono/mono/__snapshots__/tag/showcase/chromium-highContrast/regular/neutral-bg-lvl-1/DBTag-should-match-screenshot.png Received: /__w/mono/mono/showcases/angular-showcase/test-results/tag-showcase-tag-DBTag-should-match-screenshot-chromium-highContrast-retry1/regular-neutral-bg-lvl-1-actual.png Diff: /__w/mono/mono/showcases/angular-showcase/test-results/tag-showcase-tag-DBTag-should-match-screenshot-chromium-highContrast-retry1/regular-neutral-bg-lvl-1-diff.png Call log: - expect.toHaveScreenshot(regular/neutral-bg-lvl-1.png) with timeout 10000ms - verifying given screenshot expectation - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - 2867 pixels (ratio 0.01 of all image pixels) are different. - waiting 100ms before taking screenshot - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - captured a stable screenshot - 2867 pixels (ratio 0.01 of all image pixels) are different. 92 | } 93 | > 94 | await expect(page).toHaveScreenshot( | ^ 95 | [density, `neutral-bg-lvl-1.png`], 96 | config 97 | ); at /__w/mono/mono/showcases/e2e/default.ts:94:22

Check failure on line 94 in showcases/e2e/default.ts

View workflow job for this annotation

GitHub Actions / test-showcase-vue / 🧪🎭 - vue-showcase:2/6

[chromium-highContrast] › default.ts:57:2 › DBTag › should match screenshot

1) [chromium-highContrast] › default.ts:57:2 › DBTag › should match screenshot ─────────────────── Error: Screenshot comparison failed: 2867 pixels (ratio 0.01 of all image pixels) are different. Expected: /__w/mono/mono/__snapshots__/tag/showcase/chromium-highContrast/regular/neutral-bg-lvl-1/DBTag-should-match-screenshot.png Received: /__w/mono/mono/showcases/vue-showcase/test-results/tag-showcase-tag-DBTag-should-match-screenshot-chromium-highContrast/regular-neutral-bg-lvl-1-actual.png Diff: /__w/mono/mono/showcases/vue-showcase/test-results/tag-showcase-tag-DBTag-should-match-screenshot-chromium-highContrast/regular-neutral-bg-lvl-1-diff.png Call log: - expect.toHaveScreenshot(regular/neutral-bg-lvl-1.png) with timeout 10000ms - verifying given screenshot expectation - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - 2867 pixels (ratio 0.01 of all image pixels) are different. - waiting 100ms before taking screenshot - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - captured a stable screenshot - 2867 pixels (ratio 0.01 of all image pixels) are different. 92 | } 93 | > 94 | await expect(page).toHaveScreenshot( | ^ 95 | [density, `neutral-bg-lvl-1.png`], 96 | config 97 | ); at /__w/mono/mono/showcases/e2e/default.ts:94:22

Check failure on line 94 in showcases/e2e/default.ts

View workflow job for this annotation

GitHub Actions / test-showcase-vue / 🧪🎭 - vue-showcase:2/6

[chromium-highContrast] › default.ts:57:2 › DBTag › should match screenshot

1) [chromium-highContrast] › default.ts:57:2 › DBTag › should match screenshot ─────────────────── Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Screenshot comparison failed: 2867 pixels (ratio 0.01 of all image pixels) are different. Expected: /__w/mono/mono/__snapshots__/tag/showcase/chromium-highContrast/regular/neutral-bg-lvl-1/DBTag-should-match-screenshot.png Received: /__w/mono/mono/showcases/vue-showcase/test-results/tag-showcase-tag-DBTag-should-match-screenshot-chromium-highContrast-retry1/regular-neutral-bg-lvl-1-actual.png Diff: /__w/mono/mono/showcases/vue-showcase/test-results/tag-showcase-tag-DBTag-should-match-screenshot-chromium-highContrast-retry1/regular-neutral-bg-lvl-1-diff.png Call log: - expect.toHaveScreenshot(regular/neutral-bg-lvl-1.png) with timeout 10000ms - verifying given screenshot expectation - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - 2867 pixels (ratio 0.01 of all image pixels) are different. - waiting 100ms before taking screenshot - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - captured a stable screenshot - 2867 pixels (ratio 0.01 of all image pixels) are different. 92 | } 93 | > 94 | await expect(page).toHaveScreenshot( | ^ 95 | [density, `neutral-bg-lvl-1.png`], 96 | config 97 | ); at /__w/mono/mono/showcases/e2e/default.ts:94:22

Check failure on line 94 in showcases/e2e/default.ts

View workflow job for this annotation

GitHub Actions / test-showcase-react / 🧪🎭 - react-showcase:2/6

[chromium-highContrast] › default.ts:57:2 › DBTag › should match screenshot

1) [chromium-highContrast] › default.ts:57:2 › DBTag › should match screenshot ─────────────────── Error: Screenshot comparison failed: 2867 pixels (ratio 0.01 of all image pixels) are different. Expected: /__w/mono/mono/__snapshots__/tag/showcase/chromium-highContrast/regular/neutral-bg-lvl-1/DBTag-should-match-screenshot.png Received: /__w/mono/mono/showcases/react-showcase/test-results/tag-showcase-tag-DBTag-should-match-screenshot-chromium-highContrast/regular-neutral-bg-lvl-1-actual.png Diff: /__w/mono/mono/showcases/react-showcase/test-results/tag-showcase-tag-DBTag-should-match-screenshot-chromium-highContrast/regular-neutral-bg-lvl-1-diff.png Call log: - expect.toHaveScreenshot(regular/neutral-bg-lvl-1.png) with timeout 10000ms - verifying given screenshot expectation - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - 2867 pixels (ratio 0.01 of all image pixels) are different. - waiting 100ms before taking screenshot - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - captured a stable screenshot - 2867 pixels (ratio 0.01 of all image pixels) are different. 92 | } 93 | > 94 | await expect(page).toHaveScreenshot( | ^ 95 | [density, `neutral-bg-lvl-1.png`], 96 | config 97 | ); at /__w/mono/mono/showcases/e2e/default.ts:94:22

Check failure on line 94 in showcases/e2e/default.ts

View workflow job for this annotation

GitHub Actions / test-showcase-react / 🧪🎭 - react-showcase:2/6

[chromium-highContrast] › default.ts:57:2 › DBTag › should match screenshot

1) [chromium-highContrast] › default.ts:57:2 › DBTag › should match screenshot ─────────────────── Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Screenshot comparison failed: 2867 pixels (ratio 0.01 of all image pixels) are different. Expected: /__w/mono/mono/__snapshots__/tag/showcase/chromium-highContrast/regular/neutral-bg-lvl-1/DBTag-should-match-screenshot.png Received: /__w/mono/mono/showcases/react-showcase/test-results/tag-showcase-tag-DBTag-should-match-screenshot-chromium-highContrast-retry1/regular-neutral-bg-lvl-1-actual.png Diff: /__w/mono/mono/showcases/react-showcase/test-results/tag-showcase-tag-DBTag-should-match-screenshot-chromium-highContrast-retry1/regular-neutral-bg-lvl-1-diff.png Call log: - expect.toHaveScreenshot(regular/neutral-bg-lvl-1.png) with timeout 10000ms - verifying given screenshot expectation - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - 2867 pixels (ratio 0.01 of all image pixels) are different. - waiting 100ms before taking screenshot - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - captured a stable screenshot - 2867 pixels (ratio 0.01 of all image pixels) are different. 92 | } 93 | > 94 | await expect(page).toHaveScreenshot( | ^ 95 | [density, `neutral-bg-lvl-1.png`], 96 | config 97 | ); at /__w/mono/mono/showcases/e2e/default.ts:94:22
[density, `neutral-bg-lvl-1.png`],
config
);
Expand All @@ -100,13 +100,25 @@
for (const color of COLORS) {
test(`should not have any A11y issues for color ${color}`, async ({
page
}) => {
}, { project }) => {
if (skipA11y) {
test.skip();
}

await gotoPage(page, path, color, fixedHeight);

// This is a workaround for axe for browsers using forcedColors
// see https://github.com/dequelabs/axe-core-npm/issues/1067
await page.evaluate(($project) => {
if ($project.use.contextOptions?.forcedColors === 'active') {
const style = document.createElement('style');
document.head.append(style);
const textColor =
$project.use.colorScheme === 'dark' ? '#fff' : '#000';
style.textContent = `* {-webkit-text-stroke-color:${textColor}!important;-webkit-text-fill-color:${textColor}!important;}`;
}
}, project);

if (preA11y) {
await preA11y(page);
}
Expand Down
11 changes: 8 additions & 3 deletions showcases/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,26 @@ const config: PlaywrightTestConfig = {
...devices['Desktop Chrome']
}
},

{
name: 'chromium-highContrast',
use: {
browserName: 'chromium',
colorScheme: 'dark',
contextOptions: { forcedColors: 'active' }
}
},
{
name: 'firefox',
use: {
...devices['Desktop Firefox']
}
},

{
name: 'webkit',
use: {
...devices['Desktop Safari']
}
},

/* Test against mobile viewports. */
{
name: 'mobile_chrome',
Expand Down
Loading