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

bug: Theme Step Colors are Only Defined for DARK Mode #29965

Open
3 tasks done
ejohanson-vi3 opened this issue Oct 23, 2024 · 1 comment
Open
3 tasks done

bug: Theme Step Colors are Only Defined for DARK Mode #29965

ejohanson-vi3 opened this issue Oct 23, 2024 · 1 comment
Labels

Comments

@ejohanson-vi3
Copy link

Prerequisites

Ionic Framework Version

v7.x, v8.x

Current Behavior

If an Ionic app has DARK mode active, there are "step" color variables defined, which are named "--ion-background-color-step-50", "--ion-background-color-step-100", etc., up to "--ion-background-color-step-950". Also there are contrasting "step" colors for text named "--ion-text-color-step-50", etc.

These step colors work as expected in DARK mode. However, if the app is put into LIGHT mode, these variables are not defined at all. This results in plain white for any color CSS attribute that tries to use them in LIGHT mode.

Expected Behavior

The "step" color definitions should work both in LIGHT mode and DARK mode, although the definitions for LIGHT mode should be the inverse of dark mode. That is, the "--ion-background-color-step-100" for LIGHT mode should be the same value as the "--ion-background-color-step-900" for DARK mode.

Steps to Reproduce

  1. Place some CSS into an Ionic app that references a "step" color, such as:
.my-class {
	background-color: var(--ion-background-color-step-750);
	color: var(--ion-text-color-step-750);
}
  1. Run the Ionic app using the LIGHT theme.
  2. You would expect a medium-dark gray background and a light gray text, but instead you get pure white.
  3. If you switch the app to the DARK them, then it will work.

Code Reproduction URL

https://github.com/ejohanson-vi3/step-colors

Ionic Info

Ionic:

Ionic CLI : 7.2.0 (C:\local\nodejs\node_modules@ionic\cli)
Ionic Framework : @ionic/vue 8.2.0

Capacitor:

Capacitor CLI : 6.0.0
@capacitor/android : 6.0.0
@capacitor/core : 6.0.0
@capacitor/ios : 6.0.0

Utility:

cordova-res : 0.15.4
native-run : 2.0.1

System:

NodeJS : v20.14.0 (C:\local\nodejs\node.exe)
npm : 10.8.1
OS : Windows 10

Additional Information

As a workaround, a project can add the following to the theme/variables.css file. However, this just uses the Android MD colors, and does not differentiate between iOS and MD platforms (the definitions in the Ionic source code have slightly different color values for iOS and MD in DARK mode).

:root {
    --ion-background-color-step-950: #1e1e1e;
    --ion-background-color-step-900: #2a2a2a;
    --ion-background-color-step-850: #363636;
    --ion-background-color-step-800: #414141;
    --ion-background-color-step-750: #4d4d4d;
    --ion-background-color-step-700: #595959;
    --ion-background-color-step-650: #656565;
    --ion-background-color-step-600: #717171;
    --ion-background-color-step-550: #7d7d7d;
    --ion-background-color-step-500: #898989;
    --ion-background-color-step-450: #949494;
    --ion-background-color-step-400: #a0a0a0;
    --ion-background-color-step-350: #acacac;
    --ion-background-color-step-300: #b8b8b8;
    --ion-background-color-step-250: #c4c4c4;
    --ion-background-color-step-200: #d0d0d0;
    --ion-background-color-step-150: #dbdbdb;
    --ion-background-color-step-100: #e7e7e7;
    --ion-background-color-step-50: #f3f3f3;
    --ion-text-color-step-950: #f3f3f3;
    --ion-text-color-step-900: #e7e7e7;
    --ion-text-color-step-850: #dbdbdb;
    --ion-text-color-step-800: #d0d0d0;
    --ion-text-color-step-750: #c4c4c4;
    --ion-text-color-step-700: #b8b8b8;
    --ion-text-color-step-650: #acacac;
    --ion-text-color-step-600: #a0a0a0;
    --ion-text-color-step-550: #949494;
    --ion-text-color-step-500: #898989;
    --ion-text-color-step-450: #7d7d7d;
    --ion-text-color-step-400: #717171;
    --ion-text-color-step-350: #656565;
    --ion-text-color-step-300: #595959;
    --ion-text-color-step-250: #4d4d4d;
    --ion-text-color-step-200: #414141;
    --ion-text-color-step-150: #363636;
    --ion-text-color-step-100: #2a2a2a;
    --ion-text-color-step-50: #1e1e1e;
}
@ionitron-bot ionitron-bot bot added the triage label Oct 23, 2024
@wsamoht
Copy link

wsamoht commented Oct 31, 2024

For reference, this was brought up on the forum too - https://forum.ionicframework.com/t/theme-color-definitions-for-ion-background-color-step/244827

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants