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

fix(theming): Ensure all text colors have enough contrast for accessibility #40773

Merged
merged 5 commits into from
Oct 27, 2023

Conversation

susnux
Copy link
Contributor

@susnux susnux commented Oct 4, 2023

Summary

Part of multiple a11y issues.

Text that has assigned the color --color-text-maxcontrast should always have a contrast of 4.5:1, even when the element is hovered where the background will be --color-background-hover.
So the maxcontrast color is slightly adjusted (I honestly do not see a difference 🙈 ) but it ensures a contrast of 4.5:1

Screenshots

before after
Screenshot_20231004_233903 Screenshot_20231004_233841

Checklist

@susnux susnux added bug design Design, UI, UX, etc. 3. to review Waiting for reviews accessibility labels Oct 4, 2023
@susnux susnux force-pushed the fix/contrast-maxcontrast-vs-hover branch from 17a051a to 4349b2b Compare October 4, 2023 21:42
@skjnldsv
Copy link
Member

skjnldsv commented Oct 5, 2023

Could we have testing with various combinations of foreground/background colors so we're sure all of them pass WCAG AA ? :)

@susnux susnux force-pushed the fix/contrast-maxcontrast-vs-hover branch from 4349b2b to 2b820eb Compare October 5, 2023 10:33
@susnux
Copy link
Contributor Author

susnux commented Oct 5, 2023

Could we have testing with various combinations of foreground/background colors so we're sure all of them pass WCAG AA ? :)

@skjnldsv Done but some combination are failing, how to handle those, ignore? Fix? 😅

@susnux susnux force-pushed the fix/contrast-maxcontrast-vs-hover branch from 6b469bd to 499208e Compare October 5, 2023 12:57
@susnux
Copy link
Contributor Author

susnux commented Oct 5, 2023

cc @jancborchardt are those failing combinations expected to be used together or do we never want them to be used together? (those without a check mark but a number)

Accessibility of CSS color variables for Generic combinations
    ✓ color contrast of color-main-text on color-background-main (321ms)
    ✓ color contrast of color-main-text on color-background-hover (51ms)
    ✓ color contrast of color-main-text on color-background-dark (54ms)
    ✓ color contrast of color-main-text on color-background-darker (49ms)
    ✓ color contrast of color-text-maxcontrast on color-background-main (49ms)
    ✓ color contrast of color-text-maxcontrast on color-background-hover (58ms)
    1) color contrast of color-text-maxcontrast on color-background-dark
    2) color contrast of color-text-maxcontrast on color-background-darker
    ✓ color contrast of color-text-maxcontrast-default on color-background-main (65ms)
    ✓ color contrast of color-text-maxcontrast-default on color-background-hover (45ms)
    3) color contrast of color-text-maxcontrast-default on color-background-dark
    4) color contrast of color-text-maxcontrast-default on color-background-darker
    ✓ color contrast of color-error-text on color-background-main (83ms)
    ✓ color contrast of color-error-text on color-background-hover (59ms)
    ✓ color contrast of color-error-text on color-background-dark (56ms)
    5) color contrast of color-error-text on color-background-darker
    ✓ color contrast of color-warning-text on color-background-main (67ms)
    6) color contrast of color-warning-text on color-background-hover
    7) color contrast of color-warning-text on color-background-dark
    8) color contrast of color-warning-text on color-background-darker
    ✓ color contrast of color-success-text on color-background-main (169ms)
    ✓ color contrast of color-success-text on color-background-hover (65ms)
    ✓ color contrast of color-success-text on color-background-dark (69ms)
    ✓ color contrast of color-success-text on color-background-darker (62ms)
    ✓ color contrast of color-info-text on color-background-main (87ms)
    ✓ color contrast of color-info-text on color-background-hover (68ms)
    ✓ color contrast of color-info-text on color-background-dark (71ms)
    ✓ color contrast of color-info-text on color-background-darker (82ms)

  Accessibility of CSS color variables for Primary
    9) color contrast of color-primary-text on color-primary-default
    ✓ color contrast of color-primary-text on color-primary (177ms)
    10) color contrast of color-primary-text on color-primary-hover

  Accessibility of CSS color variables for Primary light
    ✓ color contrast of color-primary-light-text on color-primary-light (187ms)
    ✓ color contrast of color-primary-light-text on color-primary-light-hover (60ms)

  Accessibility of CSS color variables for Primary element
    ✓ color contrast of color-primary-element-text on color-primary-element (49ms)
    ✓ color contrast of color-primary-element-text on color-primary-element-hover (52ms)
    ✓ color contrast of color-primary-element-text-dark on color-primary-element (56ms)
    11) color contrast of color-primary-element-text-dark on color-primary-element-hover

  Accessibility of CSS color variables for Primary element light
    ✓ color contrast of color-primary-element-light-text on color-primary-element-light (82ms)
    ✓ color contrast of color-primary-element-light-text on color-primary-element-light-hover (105ms)

Previous with -light and -lighter:

 Accessibility of CSS color variables for Generic combinations
    ✓ color contrast of color-main-text on color-background-main (357ms)
    ✓ color contrast of color-main-text on color-background-hover (59ms)
    ✓ color contrast of color-main-text on color-background-dark (46ms)
    ✓ color contrast of color-main-text on color-background-darker (48ms)
    ✓ color contrast of color-text-light on color-background-main (38ms)
    ✓ color contrast of color-text-light on color-background-hover (50ms)
    ✓ color contrast of color-text-light on color-background-dark (39ms)
    ✓ color contrast of color-text-light on color-background-darker (51ms)
    ✓ color contrast of color-text-lighter on color-background-main (40ms)
    ✓ color contrast of color-text-lighter on color-background-hover (53ms)
    1) color contrast of color-text-lighter on color-background-dark
    2) color contrast of color-text-lighter on color-background-darker
    ✓ color contrast of color-text-maxcontrast on color-background-main (46ms)
    ✓ color contrast of color-text-maxcontrast on color-background-hover (43ms)
    3) color contrast of color-text-maxcontrast on color-background-dark
    4) color contrast of color-text-maxcontrast on color-background-darker
    ✓ color contrast of color-text-maxcontrast-default on color-background-main (74ms)
    ✓ color contrast of color-text-maxcontrast-default on color-background-hover (44ms)
    5) color contrast of color-text-maxcontrast-default on color-background-dark
    6) color contrast of color-text-maxcontrast-default on color-background-darker
    ✓ color contrast of color-error-text on color-background-main (72ms)
    ✓ color contrast of color-error-text on color-background-hover (39ms)
    ✓ color contrast of color-error-text on color-background-dark (43ms)
    7) color contrast of color-error-text on color-background-darker
    ✓ color contrast of color-warning-text on color-background-main (83ms)
    8) color contrast of color-warning-text on color-background-hover
    9) color contrast of color-warning-text on color-background-dark
    10) color contrast of color-warning-text on color-background-darker
    ✓ color contrast of color-success-text on color-background-main (110ms)
    ✓ color contrast of color-success-text on color-background-hover (49ms)
    ✓ color contrast of color-success-text on color-background-dark (55ms)
    ✓ color contrast of color-success-text on color-background-darker (59ms)
    ✓ color contrast of color-info-text on color-background-main (58ms)
    ✓ color contrast of color-info-text on color-background-hover (68ms)
    ✓ color contrast of color-info-text on color-background-dark (53ms)
    ✓ color contrast of color-info-text on color-background-darker (55ms)

  Accessibility of CSS color variables for Primary
    11) color contrast of color-primary-text on color-primary-default
    ✓ color contrast of color-primary-text on color-primary (106ms)
    12) color contrast of color-primary-text on color-primary-hover

  Accessibility of CSS color variables for Primary light
    ✓ color contrast of color-primary-light-text on color-primary-light (89ms)
    ✓ color contrast of color-primary-light-text on color-primary-light-hover (52ms)

  Accessibility of CSS color variables for Primary element
    ✓ color contrast of color-primary-element-text on color-primary-element (52ms)
    ✓ color contrast of color-primary-element-text on color-primary-element-hover (51ms)
    ✓ color contrast of color-primary-element-text-dark on color-primary-element (51ms)
    13) color contrast of color-primary-element-text-dark on color-primary-element-hover

  Accessibility of CSS color variables for Primary element light
    ✓ color contrast of color-primary-element-light-text on color-primary-element-light (95ms)
    ✓ color contrast of color-primary-element-light-text on color-primary-element-light-hover (54ms)

@jancborchardt
Copy link
Member

Just to clarify, since most of the issues appear with these values:

  • Both color-text-light and color-text-lighter are deprecated in favor of color-text-maxcontrast
  • Where is color-background-dark and -darker used? Cause dark theme is just color-main-background as well, or do you mean dark theme by this?

@susnux
Copy link
Contributor Author

susnux commented Oct 5, 2023

Just to clarify, since most of the issues appear with these values:

* Both color-text-light and color-text-lighter are deprecated in favor of color-text-maxcontrast

Ok then it does not make sense to test those ✅

* Where is color-background-dark and -darker used? Cause dark theme is just color-main-background as well, or do you mean dark theme by this?

They are unrelated to the dark color theme, but used for element backgrounds to stand out of the main background.

Those background colors are used e.g. for selected items, like if you select an app in the app settings the background color of that row it changed to -dark:
Screenshot_20231005_163008


It (-dark) is also used as the background color for code blocks in markdown (pre) .
-darker is used on some backgrounds, like two-factor-provider

@susnux susnux force-pushed the fix/contrast-maxcontrast-vs-hover branch 2 times, most recently from 12d998a to 1641e4e Compare October 5, 2023 14:51
@susnux
Copy link
Contributor Author

susnux commented Oct 6, 2023

@jancborchardt Basically I see 3 problems:

  1. The dark(er) background is not accessible with color maxcontrast. (For dark this might be a problem as we use it for normal element backgrounds, for darker we can migrate our code to only use it for presentation purpose without text on it)
  2. Primary: We already added the element version for this problem?
  3. The warning text color. Same problem as with that yellow / golden stars for favorites: Yellow / Orange simply has no contrast on bright background.

@jancborchardt
Copy link
Member

The dark(er) background is not accessible with color maxcontrast. (For dark this might be a problem as we use it for normal element backgrounds, for darker we can migrate our code to only use it for presentation purpose without text on it)

Yeah sounds good. Maybe also good to look at what other dark modes like e.g. GitHub do?

Primary: We already added the element version for this problem?

Yep, exactly.

The warning text color. Same problem as with that yellow / golden stars for favorites: Yellow / Orange simply has no contrast on bright background.

Yes – we should probably just not use text in those colors, and if we have warning text always use NcNoteCard. Or if it needs to be smaller use the colored icon but normal colored text.

@susnux
Copy link
Contributor Author

susnux commented Oct 24, 2023

Yeah sounds good. Maybe also good to look at what other dark modes like e.g. GitHub do?

To not confuse @jancborchardt it is not about dark mode, it is about that slightly darker background for e.g. every second table row or something like that (similar to hover).

@skjnldsv skjnldsv added this to the Nextcloud 28 milestone Oct 24, 2023
@susnux susnux force-pushed the fix/contrast-maxcontrast-vs-hover branch from 1641e4e to c008f3e Compare October 25, 2023 11:58
@susnux
Copy link
Contributor Author

susnux commented Oct 25, 2023

@nextcloud/designers Please review that you are ok with this changes.

I tried to stick as close as possible to the previous values, but for text accessibility at least some values had to be changed.
(See added accessibility test for combinations that shall pass).

@susnux susnux changed the title fix(theming): Ensure that maxcontrast text has always a contrast of 4.5:1 even on hover fix(theming): Ensure all text colors have enough contrast for accessibility Oct 25, 2023
@jancborchardt
Copy link
Member

@susnux could you post before/after screenshots of the specific cases we should check for easier review? :)

@susnux susnux force-pushed the fix/contrast-maxcontrast-vs-hover branch from c008f3e to 16bf124 Compare October 25, 2023 13:51
@susnux

This comment was marked as outdated.

@susnux
Copy link
Contributor Author

susnux commented Oct 25, 2023

And I pushed another commit which also fixes the accessibility issues, but might look better. What do you think?
With the last commit:

This is now the way to go:

https://jsfiddle.net/r5d8nwz4/

image

@nimishavijay
Copy link
Member

@susnux The latest screenshots look great to me :) much closer color to what is existing compared to the previous screenshot 👍 if the accessibility issues are also solved then we can go ahead :)

Copy link
Member

@skjnldsv skjnldsv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work as always!! Thank you so much for doing this!

Comment on lines +20 to +22
--color-text-light: var(--color-main-text);
/** @deprecated use `--color-text-maxcontrast` instead */
--color-text-lighter: var(--color-text-maxcontrast);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be in the documentation 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Learned this here:
#40773 (comment)

So I added that comments, is there a place to document that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jancborchardt since when does color-text-lighter, color-text-light, been removed/deprecated?
Was there an official statement somewhere?

@susnux you can document it in the migration guide https://github.com/nextcloud/documentation/blob/master/developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_28.rst

Copy link
Contributor Author

@susnux susnux Oct 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was there an official statement somewhere?

If yes, does the 3 years rules also apply to CSS variables? (Just because I am curious, like how long do we keep providing the deprecated SCSS variables).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No clue really, For frontend we followed more the rule of 3 versions 🙈

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@skjnldsv I think I found it [1] so seems to be deprecated since Nextcloud 20
[1] 9aff535

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok removing them then 🤷

Copy link
Contributor

@JuliaKirschenheuter JuliaKirschenheuter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool! Thank you

@susnux
Copy link
Contributor Author

susnux commented Oct 27, 2023

Github 🤦

@susnux susnux reopened this Oct 27, 2023
@susnux susnux merged commit 32eaf57 into master Oct 27, 2023
70 of 80 checks passed
@susnux susnux deleted the fix/contrast-maxcontrast-vs-hover branch October 27, 2023 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews accessibility bug design Design, UI, UX, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants