feat: rename dark/high-contrast themes to palettes (#29149)

Issue number: Internal

---------

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->

Ionic Framework currently plans to offer dark and high contrast "themes"
in v8. However this naming nomenclature conflicts with a significant new
feature that the team is working on towards v9+.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- Migrates previous dark and high contrast "themes" to "palettes"
- Updates test infrastructure to import from the new stylesheet
locations

## Does this introduce a breaking change?

- [x] Yes
- [ ] No

<!--
  If this introduces a breaking change:
1. Describe the impact and migration path for existing applications
below.
  2. Update the BREAKING.md file with the breaking change.
3. Add "BREAKING CHANGE: [...]" to the commit description when merging.
See
https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#footer
for more information.
-->

Developers that have updated to the Ionic v8 beta and have implemented
the dark and high contrast themes, will need to update the import path:

```diff
-@import '@ionic/angular/css/themes/dark.always.css';
+@import '@ionic/angular/css/palettes/dark.always.css';
```


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->

Blocked by: https://github.com/ionic-team/ionic-framework/pull/29148.
Review that first.

Documentation PR: https://github.com/ionic-team/ionic-docs/pull/3521

---------

Co-authored-by: Liam DeBeasi <liamdebeasi@users.noreply.github.com>
This commit is contained in:
Sean Perkins
2024-03-18 14:45:47 -04:00
committed by GitHub
parent 5577d3866f
commit 761e1b47dd
22 changed files with 147 additions and 175 deletions

View File

@ -0,0 +1,13 @@
@import "./dark";
:root {
@include dark-base-palette();
}
:root.ios {
@include dark-ios-palette();
}
:root.md {
@include dark-md-palette();
}

View File

@ -0,0 +1,13 @@
@import "./dark";
.ion-palette-dark {
@include dark-base-palette();
}
.ion-palette-dark.ios {
@include dark-ios-palette();
}
.ion-palette-dark.md {
@include dark-md-palette();
}

View File

@ -1,4 +1,4 @@
@mixin dark-base-theme() {
@mixin dark-base-palette() {
& {
--ion-color-primary: #4d8dff;
--ion-color-primary-rgb: 77, 141, 255;
@ -6,56 +6,48 @@
--ion-color-primary-contrast-rgb: 0, 0, 0;
--ion-color-primary-shade: #447ce0;
--ion-color-primary-tint: #5f98ff;
--ion-color-secondary: #62bdff;
--ion-color-secondary-rgb: 98, 189, 255;
--ion-color-secondary-contrast: #000000;
--ion-color-secondary-contrast-rgb: 0, 0, 0;
--ion-color-secondary-shade: #56a6e0;
--ion-color-secondary-tint: #72c4ff;
--ion-color-tertiary: #8482fb;
--ion-color-tertiary-rgb: 132, 130, 251;
--ion-color-tertiary-contrast: #000000;
--ion-color-tertiary-contrast-rgb: 0, 0, 0;
--ion-color-tertiary-shade: #7472dd;
--ion-color-tertiary-tint: #908ffb;
--ion-color-success: #2dd55b;
--ion-color-success-rgb: 45, 213, 91;
--ion-color-success-contrast: #000000;
--ion-color-success-contrast-rgb: 0, 0, 0;
--ion-color-success-shade: #28bb50;
--ion-color-success-tint: #42d96b;
--ion-color-warning: #ffce31;
--ion-color-warning-rgb: 255, 206, 49;
--ion-color-warning-contrast: #000000;
--ion-color-warning-contrast-rgb: 0, 0, 0;
--ion-color-warning-shade: #e0b52b;
--ion-color-warning-tint: #ffd346;
--ion-color-danger: #f56570;
--ion-color-danger-rgb: 245, 101, 112;
--ion-color-danger-contrast: #000000;
--ion-color-danger-contrast-rgb: 0, 0, 0;
--ion-color-danger-shade: #d85963;
--ion-color-danger-tint: #f6747e;
--ion-color-dark: #f4f5f8;
--ion-color-dark-rgb: 244, 245, 248;
--ion-color-dark-contrast: #000000;
--ion-color-dark-contrast-rgb: 0, 0, 0;
--ion-color-dark-shade: #d7d8da;
--ion-color-dark-tint: #f5f6f9;
--ion-color-medium: #989aa2;
--ion-color-medium-rgb: 152, 154, 162;
--ion-color-medium-contrast: #000000;
--ion-color-medium-contrast-rgb: 0, 0, 0;
--ion-color-medium-shade: #86888f;
--ion-color-medium-tint: #a2a4ab;
--ion-color-light: #222428;
--ion-color-light-rgb: 34, 36, 40;
--ion-color-light-contrast: #ffffff;
@ -65,14 +57,12 @@
}
}
@mixin dark-ios-theme() {
@mixin dark-ios-palette() {
& {
--ion-background-color: #000000;
--ion-background-color-rgb: 0, 0, 0;
--ion-text-color: #ffffff;
--ion-text-color-rgb: 255, 255, 255;
--ion-background-color-step-50: #0d0d0d;
--ion-background-color-step-100: #1a1a1a;
--ion-background-color-step-150: #262626;
@ -92,7 +82,6 @@
--ion-background-color-step-850: #d9d9d9;
--ion-background-color-step-900: #e6e6e6;
--ion-background-color-step-950: #f2f2f2;
--ion-text-color-step-50: #f2f2f2;
--ion-text-color-step-100: #e6e6e6;
--ion-text-color-step-150: #d9d9d9;
@ -112,7 +101,6 @@
--ion-text-color-step-850: #262626;
--ion-text-color-step-900: #1a1a1a;
--ion-text-color-step-950: #0d0d0d;
--ion-item-background: #000000;
--ion-card-background: #1c1c1d;
}
@ -124,16 +112,13 @@
}
}
@mixin dark-md-theme() {
@mixin dark-md-palette() {
& {
--ion-background-color: #121212;
--ion-background-color-rgb: 18, 18, 18;
--ion-text-color: #ffffff;
--ion-text-color-rgb: 255, 255, 255;
--ion-border-color: #222222;
--ion-background-color-step-50: #1e1e1e;
--ion-background-color-step-100: #2a2a2a;
--ion-background-color-step-150: #363636;
@ -153,7 +138,6 @@
--ion-background-color-step-850: #dbdbdb;
--ion-background-color-step-900: #e7e7e7;
--ion-background-color-step-950: #f3f3f3;
--ion-text-color-step-50: #f3f3f3;
--ion-text-color-step-100: #e7e7e7;
--ion-text-color-step-150: #dbdbdb;
@ -173,7 +157,6 @@
--ion-text-color-step-850: #363636;
--ion-text-color-step-900: #2a2a2a;
--ion-text-color-step-950: #1e1e1e;
--ion-item-background: #1e1e1e;
--ion-toolbar-background: #1f1f1f;
--ion-tab-bar-background: #1f1f1f;

View File

@ -2,14 +2,14 @@
@media (prefers-color-scheme: dark) {
:root {
@include dark-base-theme();
@include dark-base-palette();
}
:root.ios {
@include dark-ios-theme();
@include dark-ios-palette();
}
:root.md {
@include dark-md-theme();
@include dark-md-palette();
}
}

View File

@ -0,0 +1,13 @@
@import "./high-contrast-dark";
:root {
@include high-contrast-dark-base-palette();
}
:root.ios {
@include high-contrast-dark-ios-palette();
}
:root.md {
@include high-contrast-dark-md-palette();
}

View File

@ -0,0 +1,13 @@
@import "./high-contrast-dark";
.ion-palette-high-contrast.ion-palette-dark {
@include high-contrast-dark-base-palette();
}
.ion-palette-high-contrast.ion-palette-dark.ios {
@include high-contrast-dark-ios-palette();
}
.ion-palette-high-contrast.ion-palette-dark.md {
@include high-contrast-dark-md-palette();
}

View File

@ -93,8 +93,10 @@ $lightest-text-color: $text-color;
/// as opposed to setting everything in :root
// so any high contrast dark styles override the standard
/// contrast dark styles.
@mixin high-contrast-dark-base-theme() {
@mixin high-contrast-dark-base-palette() {
& {
--ion-placeholder-opacity: 0.8;
@each $color-name, $value in $colors {
--ion-color-#{$color-name}: #{map.get($value, base)};
--ion-color-#{$color-name}-rgb: #{color-to-rgb-list(map.get($value, base))};
@ -104,27 +106,23 @@ $lightest-text-color: $text-color;
--ion-color-#{$color-name}-tint: #{map.get($value, tint)};
}
--ion-placeholder-opacity: 0.8;
}
}
@mixin high-contrast-dark-ios-theme() {
@mixin high-contrast-dark-ios-palette() {
$background-color: #000000;
& {
$background-color: #000000;
--ion-background-color: #{$background-color};
--ion-background-color-rgb: #{color-to-rgb-list($background-color)};
--ion-text-color: #{$text-color};
--ion-text-color-rgb: #{color-to-rgb-list($text-color)};
--ion-item-background: #000000;
--ion-card-background: #1c1c1d;
/// Only the item borders should increase in contrast
/// Borders for elements like toolbars should remain the same
--ion-item-border-color: var(--ion-background-color-step-400);
--ion-text-color-step-50: #{mix($darkest-text-color, $lightest-text-color, 5%)};
--ion-text-color-step-100: #{mix($darkest-text-color, $lightest-text-color, 10%)};
--ion-text-color-step-150: #{mix($darkest-text-color, $lightest-text-color, 15%)};
@ -144,7 +142,6 @@ $lightest-text-color: $text-color;
--ion-text-color-step-850: #{mix($darkest-text-color, $lightest-text-color, 85%)};
--ion-text-color-step-900: #{mix($darkest-text-color, $lightest-text-color, 90%)};
--ion-text-color-step-950: #{mix($darkest-text-color, $lightest-text-color, 95%)};
--ion-background-color-step-50: #{mix($text-color, $background-color, 5%)};
--ion-background-color-step-100: #{mix($text-color, $background-color, 10%)};
--ion-background-color-step-150: #{mix($text-color, $background-color, 15%)};
@ -176,18 +173,15 @@ $lightest-text-color: $text-color;
}
}
@mixin high-contrast-dark-md-theme() {
@mixin high-contrast-dark-md-palette() {
$background-color: #121212;
& {
$background-color: #121212;
--ion-background-color: #{$background-color};
--ion-background-color-rgb: #{color-to-rgb-list($background-color)};
--ion-text-color: #{$text-color};
--ion-text-color-rgb: #{color-to-rgb-list($text-color)};
--ion-border-color: #222222;
--ion-item-background: #1e1e1e;
--ion-toolbar-background: #1f1f1f;
--ion-tab-bar-background: #1f1f1f;
@ -196,7 +190,6 @@ $lightest-text-color: $text-color;
/// Only the item borders should increase in contrast
/// Borders for elements like toolbars should remain the same
--ion-item-border-color: var(--ion-background-color-step-400);
--ion-text-color-step-50: #{mix($darkest-text-color, $lightest-text-color, 5%)};
--ion-text-color-step-100: #{mix($darkest-text-color, $lightest-text-color, 10%)};
--ion-text-color-step-150: #{mix($darkest-text-color, $lightest-text-color, 15%)};
@ -216,7 +209,6 @@ $lightest-text-color: $text-color;
--ion-text-color-step-850: #{mix($darkest-text-color, $lightest-text-color, 85%)};
--ion-text-color-step-900: #{mix($darkest-text-color, $lightest-text-color, 90%)};
--ion-text-color-step-950: #{mix($darkest-text-color, $lightest-text-color, 95%)};
--ion-background-color-step-50: #{mix($text-color, $background-color, 5%)};
--ion-background-color-step-100: #{mix($text-color, $background-color, 10%)};
--ion-background-color-step-150: #{mix($text-color, $background-color, 15%)};

View File

@ -2,14 +2,14 @@
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
:root {
@include high-contrast-dark-base-theme();
@include high-contrast-dark-base-palette();
}
:root.ios {
@include high-contrast-dark-ios-theme();
@include high-contrast-dark-ios-palette();
}
:root.md {
@include high-contrast-dark-md-theme();
@include high-contrast-dark-md-palette();
}
}

View File

@ -0,0 +1,9 @@
@import "./high-contrast";
:root {
@include high-contrast-light-base-palette();
}
:root.md {
@include high-contrast-light-md-palette();
}

View File

@ -0,0 +1,9 @@
@import "./high-contrast";
.ion-palette-high-contrast {
@include high-contrast-light-base-palette();
}
.ion-palette-high-contrast.md {
@include high-contrast-light-md-palette();
}

View File

@ -89,29 +89,17 @@ $lightest-text-color: #888888;
/// --ion-color-primary: #{ion-color(primary, base)};
/// Maps to:
/// --ion-color-primary: var(--ion-color-primary, #...);
@mixin high-contrast-light-base-theme() {
@mixin high-contrast-light-base-palette() {
& {
@each $color-name, $value in $colors {
--ion-color-#{$color-name}: #{map.get($value, base)};
--ion-color-#{$color-name}-rgb: #{color-to-rgb-list(map.get($value, base))};
--ion-color-#{$color-name}-contrast: #{map.get($value, contrast)};
--ion-color-#{$color-name}-contrast-rgb: #{color-to-rgb-list(map.get($value, contrast))};
--ion-color-#{$color-name}-shade: #{map.get($value, shade)};
--ion-color-#{$color-name}-tint: #{map.get($value, tint)};
}
--ion-background-color: #{$background-color};
--ion-background-color-rgb: #{color-to-rgb-list($background-color)};
--ion-text-color: #{$text-color};
--ion-text-color-rgb: #{color-to-rgb-list($text-color)};
--ion-placeholder-opacity: 0.8;
/// Only the item borders should increase in contrast
/// Borders for elements like toolbars should remain the same
--ion-item-border-color: #7a7a7a;
--ion-text-color-step-50: #{mix($lightest-text-color, $darkest-text-color, 5%)};
--ion-text-color-step-100: #{mix($lightest-text-color, $darkest-text-color, 10%)};
--ion-text-color-step-150: #{mix($lightest-text-color, $darkest-text-color, 15%)};
@ -131,10 +119,19 @@ $lightest-text-color: #888888;
--ion-text-color-step-850: #{mix($lightest-text-color, $darkest-text-color, 85%)};
--ion-text-color-step-900: #{mix($lightest-text-color, $darkest-text-color, 90%)};
--ion-text-color-step-950: #{mix($lightest-text-color, $darkest-text-color, 95%)};
@each $color-name, $value in $colors {
--ion-color-#{$color-name}: #{map.get($value, base)};
--ion-color-#{$color-name}-rgb: #{color-to-rgb-list(map.get($value, base))};
--ion-color-#{$color-name}-contrast: #{map.get($value, contrast)};
--ion-color-#{$color-name}-contrast-rgb: #{color-to-rgb-list(map.get($value, contrast))};
--ion-color-#{$color-name}-shade: #{map.get($value, shade)};
--ion-color-#{$color-name}-tint: #{map.get($value, tint)};
}
}
}
@mixin high-contrast-light-md-theme() {
@mixin high-contrast-light-md-palette() {
// Toast
// --------------------------------------------------

View File

@ -2,10 +2,10 @@
@media (prefers-contrast: more) {
:root {
@include high-contrast-light-base-theme();
@include high-contrast-light-base-palette();
}
:root.md {
@include high-contrast-light-md-theme();
@include high-contrast-light-md-palette();
}
}

View File

@ -1,13 +0,0 @@
@import "./dark";
:root {
@include dark-base-theme();
}
:root.ios {
@include dark-ios-theme();
}
:root.md {
@include dark-md-theme();
}

View File

@ -1,13 +0,0 @@
@import "./dark";
.ion-theme-dark {
@include dark-base-theme();
}
.ion-theme-dark.ios {
@include dark-ios-theme();
}
.ion-theme-dark.md {
@include dark-md-theme();
}

View File

@ -1,13 +0,0 @@
@import "./high-contrast-dark";
:root {
@include high-contrast-dark-base-theme();
}
:root.ios {
@include high-contrast-dark-ios-theme();
}
:root.md {
@include high-contrast-dark-md-theme();
}

View File

@ -1,13 +0,0 @@
@import "./high-contrast-dark";
.ion-theme-high-contrast.ion-theme-dark {
@include high-contrast-dark-base-theme();
}
.ion-theme-high-contrast.ion-theme-dark.ios {
@include high-contrast-dark-ios-theme();
}
.ion-theme-high-contrast.ion-theme-dark.md {
@include high-contrast-dark-md-theme();
}

View File

@ -1,9 +0,0 @@
@import "./high-contrast";
:root {
@include high-contrast-light-base-theme();
}
:root.md {
@include high-contrast-light-md-theme();
}

View File

@ -1,9 +0,0 @@
@import "./high-contrast";
.ion-theme-high-contrast {
@include high-contrast-light-base-theme();
}
.ion-theme-high-contrast.md {
@include high-contrast-light-md-theme();
}