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

feat: add high contrast themes #29010

merged 31 commits into from
Feb 13, 2024

Commits on Jan 9, 2024

  1. feat(high-contrast): add separate text and background step color vari…

    …ables (#28797)
    
    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. -->
    Both the background color step variables and the text color step
    variables are based on the `--ion-color-step-` variables.
    
    ## What is the new behavior?
    <!-- Please describe the behavior or changes that are being added by
    this PR. -->
    
    - The background color step variables are defined based on the
    `--ion-background-color-step-` values (not yet defined)
    - The text color step variables are defined based on the
    `--ion-text-color-step-` values (not yet defined)
    - The previous values remain as fallbacks
    
    ## Does this introduce a breaking change?
    
    - [ ] Yes
    - [x] 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.
    -->
    
    
    ## Other information
    
    <!-- Any other information that is important to this PR such as
    screenshots of how the component looks before and after the change. -->
    mapsandapps committed Jan 9, 2024
    Configuration menu
    Copy the full SHA
    f5df2a3 View commit details
    Browse the repository at this point in the history
  2. feat(high-contrast): define high contrast theme files and tokens (#28796

    )
    
    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. -->
    This PR introduces `high-contrast-light.{always, class, system}.css` and
    `high-contrast-dark.{always, class, system}.css` files to add high
    contrast themes to Ionic applications. It also defines new color tokens
    that meet AAA WCAG criteria for text.
    
    I also added tests to verify that these colors meet said criteria when
    used against the correct contrast color.
    
    ## Does this introduce a breaking change?
    
    - [ ] Yes
    - [x] 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.
    -->
    
    
    ## Other information
    
    <!-- Any other information that is important to this PR such as
    screenshots of how the component looks before and after the change. -->
    
    Reviews:
    
    We already have test criteria that verifies a) the colors chosen meet
    AAA WCAG criteria and b) that the CSS is being generated properly. It
    would be good to get manual testing for the `.system.css` stylesheet:
    
    1. Open any test file and make sure the high contrast system file is
    loaded:
    ```html
    <link href="../../../../../css/themes/high-contrast-dark.system.css" rel="stylesheet" />
    ```
    2. Enable high contrast on your computer. For macOS, this can be enabled
    in Settings > Accessibility > Display > Increase contrast. For iOS, this
    can be enabled in Settings > Accessibility > Display & Text size >
    Increase contrast. For Android, the system level toggle is only
    available in Android 14 in Settings > Accessibility > Color and Motion >
    Contrast Level.
    liamdebeasi committed Jan 9, 2024
    Configuration menu
    Copy the full SHA
    c2d2bf4 View commit details
    Browse the repository at this point in the history

Commits on Jan 11, 2024

  1. fix(themes): switch the order of the legacy and modern step color var…

    …iables (#28813)
    
    Issue number: N/A
    
    ---------
    
    ## What is the current behavior?
    The step colors currently check if the modern variables are defined and
    use the legacy variables as a fallback, like so:
    
    ```scss
    $background-color-step-50: var(--ion-background-color-step-50, var(--ion-color-step-50);
    
    ...
    
    $text-color-step-950: var(--ion-text-color-step-950, var(--ion-color-step-50);
    ``` 
    
    This is an issue because when we define the new step variables to be
    distributed as part of the light theme, it will always use those
    variables and never use the user's defined legacy variables:
    
    ```scss
    // ionic.theme.default.css
    
    :root {
      --ion-background-color-step-50: #{mix($text-color-value, $background-color-value, 5%)};
    }
    ```
    
    ## What is the new behavior?
    Switch the order of the step color variables so that the legacy
    variables are used first, with the modern variables used as a fallback:
    
    ```scss
    $background-color-step-50: var(--ion-color-step-50, var(--ion-background-color-step-50);
    
    ...
    
    $text-color-step-950: var(--ion-color-step-50, var(--ion-text-color-step-950);
    ``` 
    
    This will allow a user to override us setting
    `--ion-background-color-step-50` with their own `--ion-color-step-50`
    variable.
    
    ## Does this introduce a breaking change?
    
    - [ ] Yes
    - [x] No
    brandyscarney committed Jan 11, 2024
    Configuration menu
    Copy the full SHA
    84480c4 View commit details
    Browse the repository at this point in the history
  2. feat(toast): high contrast support for button text (#28804)

    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. -->
    
    With the high contrast themes, the `ion-toast` buttons do not have
    sufficient color contrast to satisfy Level AAA.
    
    ## What is the new behavior?
    <!-- Please describe the behavior or changes that are being added by
    this PR. -->
    
    - `ion-toast` buttons satisfy Level AAA color contrast with the high
    contrast themes
    
    ## Does this introduce a breaking change?
    
    - [ ] Yes
    - [x] 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.
    -->
    
    
    ## Other information
    
    <!-- Any other information that is important to this PR such as
    screenshots of how the component looks before and after the change. -->
    
    ### Testing Locally
    
    In `core/src/components/toast/test/buttons/index.html` add the
    stylesheet import either the dark or light high contrast theme:
    
    Dark (high contrast):
    ```css
    <link href="../../../../../css/themes/high-contrast-dark.always.css" rel="stylesheet" />
    ```
    
    Light (hight contrast):
    ```css
    <link href="../../../../../css/themes/high-contrast-light.always.css" rel="stylesheet" />
    ```
    
    ---------
    
    Co-authored-by: ionitron <hi@ionicframework.com>
    sean-perkins and Ionitron committed Jan 11, 2024
    Configuration menu
    Copy the full SHA
    d6addeb View commit details
    Browse the repository at this point in the history

Commits on Jan 22, 2024

  1. feat(themes): include additional step variables for light and dark th…

    …eme (#28814)
    
    - updates the dark theme to include the new modern color tokens `--ion-background-color-step-*` and `--ion-text-color-step-*`
    - updates the light theme to set these variables instead of using the fallback
    brandyscarney committed Jan 22, 2024
    Configuration menu
    Copy the full SHA
    0ddf41b View commit details
    Browse the repository at this point in the history

Commits on Jan 29, 2024

  1. Configuration menu
    Copy the full SHA
    0fec614 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    09b76b5 View commit details
    Browse the repository at this point in the history

Commits on Jan 30, 2024

  1. refactor(datetime-button): migrate step color usage (#28908)

    Co-authored-by: Liam DeBeasi <liamdebeasi@users.noreply.github.com>
    thetaPC and liamdebeasi committed Jan 30, 2024
    Configuration menu
    Copy the full SHA
    7d1aea2 View commit details
    Browse the repository at this point in the history
  2. refactor(datetime): migrate step color usage (#28910)

    Co-authored-by: Liam DeBeasi <liamdebeasi@users.noreply.github.com>
    thetaPC and liamdebeasi committed Jan 30, 2024
    Configuration menu
    Copy the full SHA
    578f760 View commit details
    Browse the repository at this point in the history
  3. fix(range): use new step color tokens (#28905)

    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. -->
    
    Range uses an `--ion-color-step-*` token directly. These tokens will be
    deprecated soon.
    
    ## What is the new behavior?
    <!-- Please describe the behavior or changes that are being added by
    this PR. -->
    
    New token added, while keeping the old one for backwards compatibility.
    
    ## Does this introduce a breaking change?
    
    - [ ] Yes
    - [x] 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.
    -->
    
    
    ## Other information
    
    <!-- Any other information that is important to this PR such as
    screenshots of how the component looks before and after the change. -->
    amandaejohnston committed Jan 30, 2024
    Configuration menu
    Copy the full SHA
    5a2b1e6 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    e8a9bff View commit details
    Browse the repository at this point in the history
  5. refactor(action-sheet): use new step color tokens (#28906)

    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. -->
    
    Action sheet uses an `--ion-color-step-*` token directly. These tokens
    will be deprecated soon.
    
    ## What is the new behavior?
    <!-- Please describe the behavior or changes that are being added by
    this PR. -->
    
    New token added, while keeping the old one for backwards compatibility.
    
    ## Does this introduce a breaking change?
    
    - [ ] Yes
    - [x] 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.
    -->
    
    
    ## Other information
    
    <!-- Any other information that is important to this PR such as
    screenshots of how the component looks before and after the change. -->
    
    Co-authored-by: Liam DeBeasi <liamdebeasi@users.noreply.github.com>
    amandaejohnston and liamdebeasi committed Jan 30, 2024
    Configuration menu
    Copy the full SHA
    7be84d2 View commit details
    Browse the repository at this point in the history
  6. refactor(alert): use correct color step tokens (#28923)

    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. -->
    
    Alert is using the wrong type of step tokens for a couple styles -- only
    text elements should use `$text-color-step-*`, while everything else
    (including borders) should use `$background-color-step-*`.
    
    ## What is the new behavior?
    <!-- Please describe the behavior or changes that are being added by
    this PR. -->
    
    Tokens updated, including changing the step values so the actual color
    resolved remains the same.
    
    ## Does this introduce a breaking change?
    
    - [ ] Yes
    - [x] 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.
    -->
    
    
    ## Other information
    
    <!-- Any other information that is important to this PR such as
    screenshots of how the component looks before and after the change. -->
    amandaejohnston committed Jan 30, 2024
    Configuration menu
    Copy the full SHA
    0316833 View commit details
    Browse the repository at this point in the history
  7. refactor(picker): update to use new step token (#28927)

    Issue number: internal
    
    ---------
    
    ## What is the current behavior?
    The picker highlight only uses the `--ion-color-step-150` variable with
    a fallback to `#eeeeef`.
    
    ## What is the new behavior?
    The picker highlight falls back to using the
    `--ion-background-color-step-150` variable if it is defined but
    prioritizes `--ion-color-step-150` if it is also defined. This is the
    new step color token added for high-contrast themes.
    
    ## Does this introduce a breaking change?
    
    - [ ] Yes
    - [x] No
    
    ## Other information
    
    No visual diffs are expected.
    brandyscarney committed Jan 30, 2024
    Configuration menu
    Copy the full SHA
    34651fa View commit details
    Browse the repository at this point in the history

Commits on Jan 31, 2024

  1. refactor(segment-button): update to use new step token (#28925)

    Issue number: internal
    
    ---------
    
    ## What is the current behavior?
    The segment button checked indicator only uses the
    `--ion-color-step-350` variable with a fallback to the
    `--ion-background-color`.
    
    ## What is the new behavior?
    The segment button checked indicator falls back to using the
    `--ion-background-color-step-350` variable if it is defined but
    prioritizes `--ion-color-step-350` if it is also defined. This is the
    new step color token added for high-contrast themes.
    
    ## Does this introduce a breaking change?
    
    - [ ] Yes
    - [x] No
    
    ## Other information
    
    No visual diffs are expected.
    brandyscarney committed Jan 31, 2024
    Configuration menu
    Copy the full SHA
    868de29 View commit details
    Browse the repository at this point in the history
  2. refactor(toast): use the correct step color tokens for background and…

    … text (#28928)
    
    Issue number: internal
    
    ---------
    
    ## What is the current behavior?
    The toast container background and toast text color were using the
    following:
    
    ```scss
    /// @prop - Background of the toast
    $toast-md-background: $text-color-step-200 !default;
    
    /// @prop - Color of the toast
    $toast-md-color: $background-color-step-50 !default;
    ```
    
    Which evaluated to:
    
    ```css
    :host {
      --background: var(--ion-color-step-800, var(--ion-text-color-step-200, #333333));
      --color: var(--ion-color-step-50, var(--ion-background-color-step-50, #f2f2f2));
    }
    ```
    
    ## What is the new behavior?
    The variables have been updated so that the `background` variable is
    used for the background of the toast container and the `text` variable
    is used for the text color of the toast:
    
    ```scss
    /// @prop - Background of the toast
    $toast-md-background: $background-color-step-800 !default;
    
    /// @prop - Color of the toast
    $toast-md-color: $text-color-step-950 !default;
    ```
    
    This evaluates to:
    
    ```css
    :host {
      --background: var(--ion-color-step-800, var(--ion-background-color-step-800, #333333));
      --color: var(--ion-color-step-50, var(--ion-text-color-step-950, #f2f2f2));
    }
    ```
    
    ## Does this introduce a breaking change?
    
    - [ ] Yes
    - [x] No
    
    There are no breaking changes as the `--ion-color-step-*` variables
    being used are the same, and the `--ion-background-color-step-*` and
    `--ion-text-color-step-*` have not been released yet. The fallback
    colors when both variables are undefined have also not changed.
    
    ## Other information
    
    No visual diffs are expected.
    brandyscarney committed Jan 31, 2024
    Configuration menu
    Copy the full SHA
    e49abc5 View commit details
    Browse the repository at this point in the history
  3. refactor(modal): update to use new step token (#28926)

    Issue number: internal
    
    ---------
    
    ## What is the current behavior?
    The modal handle only uses the `--ion-color-step-350` variable with a
    fallback to `#c0c0be`.
    
    ## What is the new behavior?
    The modal handle falls back to using the
    `--ion-background-color-step-350` variable if it is defined but
    prioritizes `--ion-color-step-350` if it is also defined. This is the
    new step color token added for high-contrast themes.
    
    ## Does this introduce a breaking change?
    
    - [ ] Yes
    - [x] No
    
    ## Other information
    
    No visual diffs are expected.
    brandyscarney committed Jan 31, 2024
    Configuration menu
    Copy the full SHA
    374cab4 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    a4352e5 View commit details
    Browse the repository at this point in the history
  5. refactor(breadcrumb): use new step color tokens (#28930)

    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. -->
    The breadcrumbs use the `--ion-color-step` tokens or a fallback.
    
    ## What is the new behavior?
    <!-- Please describe the behavior or changes that are being added by
    this PR. -->
    
    - The breadcrumb text colors use the `--ion-color-step` tokens or the
    `--ion-text-color-step` tokens or a fallback
    - The breadcrumb background colors use the `--ion-color-step` tokens or
    the `--ion-background-color-step` tokens or a fallback
    
    ## Does this introduce a breaking change?
    
    - [ ] Yes
    - [x] 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.
    -->
    
    <!-- 
    ## Other information
    
    Any other information that is important to this PR such as screenshots
    of how the component looks before and after the change. -->
    mapsandapps committed Jan 31, 2024
    Configuration menu
    Copy the full SHA
    35e8bf4 View commit details
    Browse the repository at this point in the history
  6. refactor(refresher): use new step color tokens (#28941)

    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. -->
    The refresher uses the --ion-color-step tokens or a fallback.
    
    ## What is the new behavior?
    <!-- Please describe the behavior or changes that are being added by
    this PR. -->
    
    - The refresher colors use the --ion-color-step tokens or the
    --ion-text-color-step tokens or a fallback
    - The refresher background colors use the --ion-color-step tokens or the
    --ion-background-color-step tokens or a fallback
    
    ## Does this introduce a breaking change?
    
    - [ ] Yes
    - [x] 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.
    -->
    
    <!-- 
    ## Other information
    
    Any other information that is important to this PR such as screenshots
    of how the component looks before and after the change. -->
    mapsandapps committed Jan 31, 2024
    Configuration menu
    Copy the full SHA
    0b46a02 View commit details
    Browse the repository at this point in the history

Commits on Feb 1, 2024

  1. Configuration menu
    Copy the full SHA
    c487dac View commit details
    Browse the repository at this point in the history
  2. feat(theming): add a global --ion-placeholder-opacity variable (#28944)

    Issue number: internal
    
    ---------
    
    ## What is the current behavior?
    Developers are unable to globally change the placeholder opacity for
    inputs, textareas, searchbars, and selects. This becomes particularly
    problematic when trying to apply a high contrast theme.
     
    ## What is the new behavior?
    - Adds the `--ion-placeholder-opacity` with a fallback of `0.6` (this
    fallback is unchanged)
    - Sets the `--ion-placeholder-opacity` to `0.8` for the high contrast
    light & dark themes
    
    > [!NOTE]
    > The ticket says to update the standard light and dark themes to define
    `--ion-placeholder-opacity: 0.6`, however, I did not do this because
    this is not different than the fallback and therefore does not need to
    be defined.
    
    ## Does this introduce a breaking change?
    
    - [ ] Yes
    - [x] No
    
    ## Other information
    
    Documentation pull request:
    ionic-team/ionic-docs#3421
    brandyscarney committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    4d8aff0 View commit details
    Browse the repository at this point in the history

Commits on Feb 6, 2024

  1. Configuration menu
    Copy the full SHA
    c147895 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7acf13c View commit details
    Browse the repository at this point in the history

Commits on Feb 9, 2024

  1. Configuration menu
    Copy the full SHA
    fe9dca5 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    c9aa703 View commit details
    Browse the repository at this point in the history

Commits on Feb 12, 2024

  1. Configuration menu
    Copy the full SHA
    ec480aa View commit details
    Browse the repository at this point in the history

Commits on Feb 13, 2024

  1. Configuration menu
    Copy the full SHA
    2366591 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    b5c8366 View commit details
    Browse the repository at this point in the history
  3. Update core/src/css/themes/high-contrast.scss

    Co-authored-by: Brandy Carney <brandyscarney@users.noreply.github.com>
    liamdebeasi and brandyscarney committed Feb 13, 2024
    Configuration menu
    Copy the full SHA
    c7c7842 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    33c479b View commit details
    Browse the repository at this point in the history