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: add high contrast themes #29010

Merged
merged 31 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f5df2a3
feat(high-contrast): add separate text and background step color vari…
mapsandapps Jan 9, 2024
c2d2bf4
feat(high-contrast): define high contrast theme files and tokens (#28…
liamdebeasi Jan 9, 2024
84480c4
fix(themes): switch the order of the legacy and modern step color var…
brandyscarney Jan 11, 2024
d6addeb
feat(toast): high contrast support for button text (#28804)
sean-perkins Jan 11, 2024
0ddf41b
feat(themes): include additional step variables for light and dark th…
brandyscarney Jan 22, 2024
0fec614
Merge remote-tracking branch 'origin/feature-8.0' into FW-5747
liamdebeasi Jan 29, 2024
09b76b5
fix: remove default light mode tokens (#28911)
liamdebeasi Jan 29, 2024
7d1aea2
refactor(datetime-button): migrate step color usage (#28908)
thetaPC Jan 30, 2024
578f760
refactor(datetime): migrate step color usage (#28910)
thetaPC Jan 30, 2024
5a2b1e6
fix(range): use new step color tokens (#28905)
amandaejohnston Jan 30, 2024
e8a9bff
refactor(input): update to use correct step tokens (#28922)
thetaPC Jan 30, 2024
7be84d2
refactor(action-sheet): use new step color tokens (#28906)
amandaejohnston Jan 30, 2024
0316833
refactor(alert): use correct color step tokens (#28923)
amandaejohnston Jan 30, 2024
34651fa
refactor(picker): update to use new step token (#28927)
brandyscarney Jan 30, 2024
868de29
refactor(segment-button): update to use new step token (#28925)
brandyscarney Jan 31, 2024
e49abc5
refactor(toast): use the correct step color tokens for background and…
brandyscarney Jan 31, 2024
374cab4
refactor(modal): update to use new step token (#28926)
brandyscarney Jan 31, 2024
a4352e5
refactor(textarea): update to use correct step tokens (#28921)
thetaPC Jan 31, 2024
35e8bf4
refactor(breadcrumb): use new step color tokens (#28930)
mapsandapps Jan 31, 2024
0b46a02
refactor(refresher): use new step color tokens (#28941)
mapsandapps Jan 31, 2024
c487dac
refactor: remove legacy tokens from dark theme (#28942)
liamdebeasi Feb 1, 2024
4d8aff0
feat(theming): add a global --ion-placeholder-opacity variable (#28944)
brandyscarney Feb 1, 2024
c147895
feat: add high contrast implementation (#28956)
liamdebeasi Feb 6, 2024
7acf13c
fix(high-contrast): apply styles to new selector
liamdebeasi Feb 6, 2024
fe9dca5
refactor: make color changes according to design doc
liamdebeasi Feb 9, 2024
c9aa703
Merge remote-tracking branch 'origin/feature-8.0' into FW-5747
liamdebeasi Feb 9, 2024
ec480aa
Merge branch 'feature-8.0' into FW-5747
liamdebeasi Feb 12, 2024
2366591
Merge branch 'feature-8.0' into FW-5747
liamdebeasi Feb 13, 2024
b5c8366
Merge branch 'feature-8.0' into FW-5747
liamdebeasi Feb 13, 2024
c7c7842
Update core/src/css/themes/high-contrast.scss
liamdebeasi Feb 13, 2024
33c479b
Merge branch 'feature-8.0' into FW-5747
liamdebeasi Feb 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/.stylelintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ ignoreFiles:
- src/themes/ionic.mixins.scss
- src/themes/ionic.functions.color.scss
- src/themes/ionic.functions.string.scss
- src/themes/ionic.theme.default.scss
- src/css/themes/*.scss

indentation: 2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ $action-sheet-ios-button-background: linear-gradien
$action-sheet-ios-button-background-activated: $text-color !default;

/// @prop - Background color of the selected action sheet button
$action-sheet-ios-button-background-selected: var(--ion-color-step-150, $background-color) !default;
$action-sheet-ios-button-background-selected: var(--ion-color-step-150, var(--ion-background-color-step-150, $background-color)) !default;

/// @prop - Destructive text color of the action sheet button
$action-sheet-ios-button-destructive-text-color: ion-color(danger, base) !default;
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/alert/alert.md.vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ $alert-md-radio-border-style: solid !default;
$alert-md-radio-border-radius: 50% !default;

/// @prop - Border color of the alert radio when off
$alert-md-radio-border-color-off: $text-color-step-450 !default;
$alert-md-radio-border-color-off: $background-color-step-550 !default;

/// @prop - Border color of the alert radio when on
$alert-md-radio-border-color-on: $alert-md-button-text-color !default;
Expand Down Expand Up @@ -280,7 +280,7 @@ $alert-md-checkbox-border-style: solid !default;
$alert-md-checkbox-border-radius: 2px !default;

/// @prop - Border color of the checkbox in the alert when off
$alert-md-checkbox-border-color-off: $text-color-step-450 !default;
$alert-md-checkbox-border-color-off: $background-color-step-550 !default;

/// @prop - Border color of the checkbox in the alert when on
$alert-md-checkbox-border-color-on: $alert-md-button-text-color !default;
Expand Down
14 changes: 7 additions & 7 deletions core/src/components/breadcrumb/breadcrumb.ios.vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
// --------------------------------------------------

/// @prop - Color of the breadcrumb
$breadcrumb-ios-color: var(--ion-color-step-850, #2d4665) !default;
$breadcrumb-ios-color: var(--ion-color-step-850, var(--ion-text-color-step-150, #2d4665)) !default;

/// @prop - Color of the active breadcrumb
$breadcrumb-ios-color-active: var(--ion-text-color, #03060b) !default;

/// @prop - Background color of the focused breadcrumb
$breadcrumb-ios-background-focused: var(--ion-color-step-50, rgba(233, 237, 243, 0.7)) !default;
$breadcrumb-ios-background-focused: var(--ion-color-step-50, var(--ion-background-color-step-50, rgba(233, 237, 243, 0.7))) !default;

/// @prop - Color of the breadcrumb icon
$breadcrumb-ios-icon-color: var(--ion-color-step-400, #92a0b3) !default;
$breadcrumb-ios-icon-color: var(--ion-color-step-400, var(--ion-text-color-step-600, #92a0b3)) !default;

/// @prop - Color of the breadcrumb icon when active
$breadcrumb-ios-icon-color-active: var(--ion-color-step-850, #242d39) !default;
$breadcrumb-ios-icon-color-active: var(--ion-color-step-850, var(--ion-text-color-step-150, #242d39)) !default;

/// @prop - Color of the breadcrumb icon when focused
$breadcrumb-ios-icon-color-focused: var(--ion-color-step-750, #445b78) !default;
$breadcrumb-ios-icon-color-focused: var(--ion-color-step-750, var(--ion-text-color-step-250, #445b78)) !default;

/// @prop - Color of the breadcrumb separator
$breadcrumb-ios-separator-color: $breadcrumb-separator-color !default;
Expand All @@ -28,7 +28,7 @@ $breadcrumb-ios-separator-color: $breadcrumb-separator-color !
$breadcrumb-ios-indicator-color: $breadcrumb-ios-separator-color !default;

/// @prop - Background color of the breadcrumb indicator
$breadcrumb-ios-indicator-background: var(--ion-color-step-100, #e9edf3) !default;
$breadcrumb-ios-indicator-background: var(--ion-color-step-100, var(--ion-background-color-step-100, #e9edf3)) !default;

/// @prop - Background color of the breadcrumb indicator when focused
$breadcrumb-ios-indicator-background-focused: var(--ion-color-step-150, #d9e0ea) !default;
$breadcrumb-ios-indicator-background-focused: var(--ion-color-step-150, var(--ion-background-color-step-150, #d9e0ea)) !default;
14 changes: 7 additions & 7 deletions core/src/components/breadcrumb/breadcrumb.md.vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
// --------------------------------------------------

/// @prop - Color of the breadcrumb
$breadcrumb-md-color: var(--ion-color-step-600, #677483) !default;
$breadcrumb-md-color: var(--ion-color-step-600, var(--ion-text-color-step-400, #677483)) !default;

/// @prop - Color of the active breadcrumb
$breadcrumb-md-color-active: var(--ion-text-color, #03060b) !default;

/// @prop - Color of the focused breadcrumb
$breadcrumb-md-color-focused: var(--ion-color-step-800, #35404e) !default;
$breadcrumb-md-color-focused: var(--ion-color-step-800, var(--ion-text-color-step-200, #35404e)) !default;

/// @prop - Background color of the focused breadcrumb
$breadcrumb-md-background-focused: var(--ion-color-step-50, #fff) !default;
$breadcrumb-md-background-focused: var(--ion-color-step-50, var(--ion-background-color-step-50, #fff)) !default;

/// @prop - Color of the breadcrumb icon
$breadcrumb-md-icon-color: var(--ion-color-step-550, #7d8894) !default;
$breadcrumb-md-icon-color: var(--ion-color-step-550, var(--ion-text-color-step-450, #7d8894)) !default;

/// @prop - Color of the breadcrumb icon when active
$breadcrumb-md-icon-color-active: var(--ion-color-step-850, #222d3a) !default;
$breadcrumb-md-icon-color-active: var(--ion-color-step-850, var(--ion-text-color-step-150, #222d3a)) !default;

/// @prop - Margin top of the breadcrumb separator
$breadcrumb-md-separator-margin-top: -1px !default;
Expand All @@ -40,7 +40,7 @@ $breadcrumb-md-separator-color: $breadcrumb-separator-color
$breadcrumb-md-indicator-color: $breadcrumb-md-separator-color !default;

/// @prop - Background color of the breadcrumb indicator
$breadcrumb-md-indicator-background: var(--ion-color-step-100, #eef1f3) !default;
$breadcrumb-md-indicator-background: var(--ion-color-step-100, var(--ion-background-color-step-100, #eef1f3)) !default;

/// @prop - Background color of the breadcrumb indicator when focused
$breadcrumb-md-indicator-background-focused: var(--ion-color-step-150, #dfe5e8) !default;
$breadcrumb-md-indicator-background-focused: var(--ion-color-step-150, var(--ion-background-color-step-150, #dfe5e8)) !default;
2 changes: 1 addition & 1 deletion core/src/components/breadcrumb/breadcrumb.vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ $breadcrumb-baseline-font-size: 16px !default;
$breadcrumb-font-size: dynamic-font($breadcrumb-baseline-font-size) !default;

/// @prop - Color of the breadcrumb separator
$breadcrumb-separator-color: var(--ion-color-step-550, #73849a) !default;
$breadcrumb-separator-color: var(--ion-color-step-550, var(--ion-text-color-step-450, #73849a)) !default;
2 changes: 1 addition & 1 deletion core/src/components/datetime-button/datetime-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

border: none;

background: var(--ion-color-step-300, #edeef0);
background: var(--ion-color-step-300, var(--ion-background-color-step-300, #edeef0));

color: $text-color;

Expand Down
2 changes: 1 addition & 1 deletion core/src/components/datetime/datetime.md.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@import "../../themes/ionic.globals.md";

:host {
--background: var(--ion-color-step-100, #ffffff);
--background: var(--ion-color-step-100, var(--ion-background-color-step-100, #ffffff));
--title-color: #{current-color(contrast)};
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/components/datetime/datetime.scss
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@

border: none;

background: var(--ion-color-step-300, #edeef0);
background: var(--ion-color-step-300, var(--ion-background-color-step-300, #edeef0));

color: $text-color;

Expand Down
4 changes: 2 additions & 2 deletions core/src/components/input/input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@
.input-bottom .helper-text {
display: block;

color: #{$background-color-step-550};
color: #{$text-color-step-450};
}

:host(.ion-touched.ion-invalid) .input-bottom .error-text {
Expand All @@ -424,7 +424,7 @@
*/
@include margin-horizontal(auto, null);

color: #{$background-color-step-550};
color: #{$text-color-step-450};

white-space: nowrap;

Expand Down
2 changes: 1 addition & 1 deletion core/src/components/item/item.ios.vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $item-ios-paragraph-margin-start: $item-ios-paragraph-margin-end !def
$item-ios-paragraph-font-size: dynamic-font(14px) !default;

/// @prop - Color of the item paragraph
$item-ios-paragraph-text-color: rgba($text-color-rgb, .4) !default;
$item-ios-paragraph-text-color: var(--ion-text-color-step-550, #a3a3a3) !default;

/// @prop - Width of the avatar in the item
$item-ios-avatar-width: 36px !default;
Expand Down
2 changes: 1 addition & 1 deletion core/src/components/modal/modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ ion-backdrop {

border: 0;

background: var(--ion-color-step-350, #c0c0be);
background: var(--ion-color-step-350, var(--ion-background-color-step-350, #c0c0be));

cursor: pointer;

Expand Down
2 changes: 1 addition & 1 deletion core/src/components/picker/picker.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
}

:host .picker-highlight {
background: var(--highlight-background, var(--ion-color-step-150, #eeeeef));
background: var(--highlight-background, var(--ion-color-step-150, var(--ion-background-color-step-150, #eeeeef)));
}
2 changes: 1 addition & 1 deletion core/src/components/range/range.ios.vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ $range-ios-hit-height: $range-ios-slider-height !default;
$range-ios-bar-height: 4px !default;

/// @prop - Background of the range bar
$range-ios-bar-background-color: var(--ion-color-step-900, #e6e6e6) !default;
$range-ios-bar-background-color: var(--ion-color-step-900, var(--ion-background-color-step-900, #e6e6e6)) !default;

/// @prop - Border radius of the range bar
$range-ios-bar-border-radius: 2px !default;
Expand Down
2 changes: 1 addition & 1 deletion core/src/components/refresher/refresher.ios.vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $refresher-ios-icon-color: $text-color !default;
$refresher-ios-text-color: $text-color !default;

/// @prop - Color of the native refresher spinner
$refresher-ios-native-spinner-color: var(--ion-color-step-450, #747577) !default;
$refresher-ios-native-spinner-color: var(--ion-color-step-450, var(--ion-background-color-step-450, #747577)) !default;

/// @prop - Width of the native refresher spinner
$refresher-ios-native-spinner-width: 32px !default;
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/refresher/refresher.md.vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ $refresher-md-text-color: $text-color !default;
$refresher-md-native-spinner-color: #{ion-color(primary, base)} !default;

/// @prop - Border of the native refresher spinner
$refresher-md-native-spinner-border: 1px solid var(--ion-color-step-200, #ececec) !default;
$refresher-md-native-spinner-border: 1px solid var(--ion-color-step-200, var(--ion-background-color-step-200, #ececec)) !default;

/// @prop - Background of the native refresher spinner
$refresher-md-native-spinner-background: var(--ion-color-step-250, #ffffff) !default;
$refresher-md-native-spinner-background: var(--ion-color-step-250, var(--ion-background-color-step-250, #ffffff)) !default;

/// @prop - Box shadow of the native refresher spinner
$refresher-md-native-spinner-box-shadow: 0px 1px 6px rgba(0, 0, 0, 0.1) !default;
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $segment-button-ios-background-checked: $segment-button-ios-backgr
$segment-button-ios-color: $text-color !default;

/// @prop - Background of the checked segment button indicator
$segment-button-ios-indicator-color: var(--ion-color-step-350, $background-color) !default;
$segment-button-ios-indicator-color: var(--ion-color-step-350, var(--ion-background-color-step-350, $background-color)) !default;

/// @prop - Margin of the segment button
$segment-button-ios-margin: 2px !default;
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/textarea/textarea.scss
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@
.textarea-bottom .helper-text {
display: block;

color: #{$background-color-step-550};
color: #{$text-color-step-450};
}

:host(.ion-touched.ion-invalid) .textarea-bottom .error-text {
Expand All @@ -456,7 +456,7 @@
*/
@include margin-horizontal(auto, null);

color: #{$background-color-step-550};
color: #{$text-color-step-450};

white-space: nowrap;

Expand Down
45 changes: 45 additions & 0 deletions core/src/components/toast/test/a11y/toast.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,48 @@ configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
});
});
});

/**
* High contrast mode tests
*/
configs({ directions: ['ltr'], themes: ['high-contrast-dark', 'high-contrast'] }).forEach(
({ title, config, screenshot }) => {
test.describe(title('toast: high contrast: buttons'), () => {
test.beforeEach(async ({ page }) => {
await page.setContent(
`
<ion-toast is-open="true" header="Testing" message="Hello world"></ion-toast>
<script>
const toast = document.querySelector('ion-toast');
toast.buttons = [
{ text: 'Cancel', role: 'cancel' },
{ text: 'OK' }
];
</script>
`,
config
);
});

test('should not have visual regressions', async ({ page }) => {
const toast = page.locator('ion-toast');

await expect(toast).toBeVisible();

const toastWrapper = toast.locator('.toast-wrapper');
await expect(toastWrapper).toHaveScreenshot(screenshot(`toast-high-contrast-buttons`));
});

test('should pass AAA guidelines', async ({ page }) => {
const ionToastDidPresent = await page.spyOnEvent('ionToastDidPresent');

await ionToastDidPresent.next();

const results = await new AxeBuilder({ page })
.options({ rules: { 'color-contrast-enhanced': { enabled: true } } })
.analyze();
expect(results.violations).toEqual([]);
});
});
}
);
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions core/src/components/toast/toast.md.vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// --------------------------------------------------

/// @prop - Background of the toast
$toast-md-background: $text-color-step-200 !default;
$toast-md-background: $background-color-step-800 !default;

/// @prop - Box shadow of the toast
$toast-md-box-shadow: 0 3px 5px -1px rgba(0, 0, 0, 0.2), 0 6px 10px 0 rgba(0, 0, 0, 0.14),
Expand All @@ -14,7 +14,7 @@ $toast-md-box-shadow: 0 3px 5px -1px rgba(0, 0, 0, 0.2), 0 6px 10px 0 rgba(0, 0,
$toast-md-font-size: dynamic-font(14px) !default;

/// @prop - Color of the toast
$toast-md-color: $background-color-step-50 !default;
$toast-md-color: $text-color-step-950 !default;

/// @prop - Border radius of the toast wrapper
$toast-md-border-radius: 4px !default;
Expand Down Expand Up @@ -77,7 +77,7 @@ $toast-md-button-opacity-hover: 0.08 !default;
$toast-md-button-background-color-hover: ion-color(primary, base, $toast-md-button-opacity-hover) !default;

/// @prop - Text color of the cancel toast button
$toast-md-button-cancel-text-color: $background-color-step-100 !default;
$toast-md-button-cancel-text-color: $text-color-step-900 !default;

/// @prop - Background color of the cancel toast button on hover
$toast-md-button-cancel-background-color-hover: rgba($background-color-rgb, $toast-md-button-opacity-hover) !default;
Expand Down