-
Notifications
You must be signed in to change notification settings - Fork 355
Ensure we use PST colours throughout #1927
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
Changes from all commits
848fc2f
43e4df8
f58dbee
959bb4f
2b0d8d3
57a2384
29875a8
d210f95
5c66a78
3a8609a
dcbade5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,12 +61,6 @@ a > code { | |
| color: var(--pst-color-inline-code-links); | ||
| } | ||
|
|
||
| // Fix for Sphinx's "highlight" directive - this is an issue with our accessible pygments theme | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No longer needed now that we fixed accessible pygments |
||
| // and the colour we are using for the background of the code blocks. | ||
| html[data-theme="light"] .highlight .nf { | ||
| color: #0078a1 !important; | ||
| } | ||
|
|
||
| // Minimum opacity needed for linenos to be WCAG AA conformant | ||
| span.linenos { | ||
| opacity: 0.8 !important; | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted to comment that on the issue but I only got to it now and I see there is a PR already, thanks for the quick response @trallard! I see now that these colors are always available, not only when sphinx-design is an active extension which was confusing me when I wrote the issue. |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -66,25 +66,33 @@ $all-colors: map.merge($pst-semantic-colors, $extra-semantic-colors); | |||||
|
|
||||||
| @mixin create-sd-colors($value, $name) { | ||||||
| // define the pst variables, so that downstream user overrides will work | ||||||
| @debug "Creating color variables for semantic color: #{$name}"; | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like we're able to create AA conforming colors for everything except warning-highlight in light mode:
Contrast ratio 4.4:1.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah there is no WCAG conformant combination with our text colours and the orange (at least how this is being calculated). And I did not want to spend hours and hours tweaking that to get perfect colours considering we only use these for hover effects.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense. I was actually trying to say that I was impressed that there was only one semantic color that didn't work. And it's not that far from the 4.5 target. |
||||||
|
|
||||||
| --pst-color-#{$name}: #{$value}; | ||||||
|
|
||||||
| // we are now using a11y-combination to calculate the text color - this is based | ||||||
| // on the WCAG color contrast guidelines | ||||||
| --pst-color-#{$name}-text: #{a11y-combination($value)}; | ||||||
|
|
||||||
| // TODO: highlight seems to be used for buttons @trallard to fix on a11y follow-up work | ||||||
| --pst-color-#{$name}-highlight: #{color.adjust($value, $lightness: -15%)}; | ||||||
| // highlight is used for hover effects on buttons, here we make some fluid scaling | ||||||
| // to avoid jarring effects -- we create a local variable that we can access | ||||||
| // later to calculate the text color | ||||||
| $highlight-color: color.scale($value, $lightness: -15%, $saturation: 5%); | ||||||
|
|
||||||
| --pst-color-#{$name}-highlight: #{$highlight-color}; | ||||||
|
|
||||||
| // override the sphinx-design variables | ||||||
| --sd-color-#{$name}: var(--pst-color-#{$name}); | ||||||
| --sd-color-#{$name}-text: var(--pst-color-#{$name}-text); | ||||||
|
|
||||||
| // TODO: highlight seems to be used for buttons @trallard to fix on a11y follow-up work | ||||||
| --sd-color-#{$name}-highlight: var(--pst-color-#{$name}-highlight); | ||||||
|
|
||||||
| // calculate the text color for the highlight color | ||||||
| --pst-color-#{$name}-highlight-text: #{a11y-combination($highlight-color)}; | ||||||
|
Comment on lines
+89
to
+90
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we already calculate a WCAG conformant text colour for our semantic colours it made sense to do the same for highlight colours that are used for hover |
||||||
| } | ||||||
|
|
||||||
| // Now we override the --sd-color-* variables. | ||||||
| @each $mode in (light, dark) { | ||||||
| @debug "Creating color variables for mode: #{$mode}"; | ||||||
| html[data-theme="#{$mode}"] { | ||||||
| // check if this color is defined differently for light/dark | ||||||
| @each $name in $sd-semantic-color-names { | ||||||
|
|
@@ -99,7 +107,7 @@ $all-colors: map.merge($pst-semantic-colors, $extra-semantic-colors); | |||||
| @if string.index($key, "bg") { | ||||||
| --sd-color-#{$name}-bg: #{$value}; | ||||||
|
|
||||||
| // create local variable | ||||||
| // create local variable -- needed to calculate the text color | ||||||
| $value: check-color($value); | ||||||
|
|
||||||
| --sd-color-#{$name}-bg-text: #{a11y-combination($value)}; | ||||||
|
|
@@ -341,6 +349,14 @@ html { | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| @each $name in $sd-semantic-color-names { | ||||||
| .sd-btn-#{$name} { | ||||||
| &:hover { | ||||||
| color: var(--pst-color-#{$name}-highlight-text) !important; | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think we should try upstreaming things like this? |
||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| @each $name in $sd-semantic-color-names { | ||||||
| .sd-btn-#{$name}, | ||||||
| .sd-btn-outline-#{$name} { | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,9 +53,13 @@ | |
| border-radius: 0.25rem; | ||
|
|
||
| &:hover { | ||
| // applying the same style as the SD "buttons" | ||
| @include link-style-hover; | ||
|
|
||
| text-decoration-thickness: 1px; | ||
|
Comment on lines
+56
to
+59
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems this was missed, so I added this to bring parity with other buttons @gabalafou unless there was a reason to leave this out?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. Plus, I like this parity because the text underline suggests that the button is actually a link, which is the case. |
||
| background-color: $hover-background-color; | ||
| border-color: $hover-background-color; | ||
| color: $color; | ||
| color: var(--pst-color-danger-highlight-text); | ||
| } | ||
|
|
||
| &:focus-visible { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.