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

ENH - Scalable colour system for theme #1174

Merged
merged 77 commits into from Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
2063ff5
Merge remote-tracking branch 'upstream/main' into main
Feb 8, 2023
2ae812e
Merge remote-tracking branch 'upstream/main' into trallard/color-system
trallard Feb 9, 2023
af45d7e
:memo: Update file names in documentation
trallard Feb 9, 2023
63af297
:art: Update mixins to match new colour system
trallard Feb 10, 2023
06ad737
:wheelchair: Update colours
trallard Feb 10, 2023
74c2eea
:wheelchair: Update foundation and text colours
trallard Feb 10, 2023
722f4d5
Add more colours - shadows and neutrals
trallard Feb 13, 2023
fbe4f35
:wheelchair: Replace text colour function w/WCAG one
trallard Feb 13, 2023
0d4dfe7
Merge remote-tracking branch 'upstream/main' into trallard/color-system
trallard Feb 13, 2023
4e71156
:recycle: Add full color system to root
trallard Feb 13, 2023
e072eb1
:wheelchair: Update variables - use color names
trallard Feb 13, 2023
884b822
:wheelchair: Ensure all the colours are evaluated correctly
trallard Feb 14, 2023
d520b72
Update mixins - move to separate file
trallard Feb 14, 2023
38c6dc7
Merge remote-tracking branch 'upstream/main' into trallard/color-system
trallard Feb 16, 2023
c4f9894
Update contrast ratios - add comments
trallard Feb 19, 2023
fe6fe76
♿️ Add luminance formula and ignore text col for now
trallard Feb 19, 2023
244772a
Update variables and remove debugs
trallard Feb 19, 2023
66bc02d
Merge remote-tracking branch 'upstream/main' into trallard/color-system
trallard Feb 19, 2023
7ef23d8
:zap: Improve colours parsing
trallard Feb 23, 2023
ef43e09
:wheelchair: Update admonition bg colours
trallard Feb 23, 2023
16678ea
Update headings colours
trallard Feb 23, 2023
0c9a6b5
:wheelchair: Change topic text colour and replace mixins
trallard Feb 24, 2023
f89e262
:wheelchair: Minor tweaks to secondary colour
trallard Feb 24, 2023
055f7c0
:wheelchair: Update code and announcement colours
trallard Feb 24, 2023
7930b5d
Update text-muted in dark theme
trallard Feb 24, 2023
a663273
♿️ Buttons are now WCAG AA conformant
trallard Feb 24, 2023
f1b3787
:lipstick: Update tabs hover
trallard Feb 24, 2023
5a6ae4c
♿️ Tweaks to colours in small components
trallard Mar 20, 2023
cb5b81b
♿️ Move WCAG contrast to mixin file
trallard Mar 20, 2023
9ed2d8c
Update theming docs
trallard Mar 20, 2023
8d55e7d
:memo: Update a11y docs
trallard Mar 20, 2023
7b94982
Update accessibility docs
trallard Mar 20, 2023
d21b3ed
Fix search button text contrast
trallard Mar 21, 2023
33484dd
Fix colours in admonitions
trallard Mar 21, 2023
655826c
Ensure we use WCAG compliant text color
trallard Mar 21, 2023
6943a46
Update docs - web components
trallard Mar 21, 2023
bcce67e
Fix quotes text colour
trallard Mar 21, 2023
19f789c
Add more details re accessibility
trallard Mar 21, 2023
16cb353
Merge remote-tracking branch 'upstream/main' into trallard/color-system
trallard Mar 21, 2023
daf994d
📝 Add accessibility notes to docs
trallard Mar 22, 2023
aafb573
:lipstick: Ensure we are generating background colours too
trallard Mar 22, 2023
59b265e
Merge remote-tracking branch 'upstream/main' into trallard/color-system
trallard Mar 27, 2023
1a883d1
:bug: Fix attention bg colour
trallard Mar 27, 2023
d62eb87
:bug: Fix bg colour issues
trallard Mar 27, 2023
d460b67
🎨 Improve sd colours
trallard Mar 27, 2023
5d7ebf4
Update styling
trallard Mar 27, 2023
6a710b0
Merge remote-tracking branch 'upstream/main' into trallard/color-system
trallard Mar 27, 2023
5aed77c
Lint files
trallard Mar 27, 2023
7d350f9
:heavy_minus_sign: Remove unused mixin
trallard Mar 27, 2023
a3395c3
Fix issues introduced by merging main
trallard Mar 28, 2023
2deceac
Add dropdowns background
trallard Apr 7, 2023
e3724a8
Merge remote-tracking branch 'upstream/main' into trallard/color-system
trallard Apr 7, 2023
cd3d67a
:memo: Update docs
trallard Apr 7, 2023
a855f97
:pencil2: Fix grammar and spelling
trallard Apr 13, 2023
fb789ab
Merge remote-tracking branch 'upstream/main' into trallard/color-system
trallard Apr 14, 2023
58aceaf
Minor edits to docs
trallard Apr 16, 2023
c11e0c3
Fix colour in code blocks
trallard Apr 16, 2023
6702fc2
:zap: Use math.pow - we use dart sass now
trallard Apr 17, 2023
17b0e35
:zap: Use math.pow
trallard Apr 17, 2023
d439d79
Merge remote-tracking branch 'upstream/main' into trallard/color-system
trallard Apr 17, 2023
f5f3795
:zap: Update mixins
trallard Apr 18, 2023
940a6b1
Merge remote-tracking branch 'upstream/main' into trallard/color-system
trallard Jun 13, 2023
659ecca
:heavy_plus_sign: Add math import in mixins
trallard Jun 13, 2023
85c1464
Fix highlight colour - pygments
trallard Jun 13, 2023
1330c74
Fix inline code links contrast
trallard Jun 13, 2023
8566578
Add selector to print - a11y tests
trallard Jun 13, 2023
181ed57
Fix line numbers contrast
trallard Jun 13, 2023
6dedf8e
Fix announcement link colours
trallard Jun 13, 2023
71ead9e
Merge branch 'main' into trallard/color-system
trallard Jun 14, 2023
0f1ffb9
Adjust background colours - light theme
trallard Jun 15, 2023
4c17a23
Update search highlight colours
trallard Jun 16, 2023
4687c7d
:wheelchair: Change hover colour to improve contrast
trallard Jun 16, 2023
9405a85
Update docs to align with system
trallard Jun 16, 2023
c0e54db
:see_no_evil: Update gitignore file
trallard Jun 19, 2023
e5830a2
Apply suggestions from code review
trallard Jun 19, 2023
559b1f7
:bug: Use correct variable names
trallard Jun 19, 2023
d3cdc27
Fix title colour in custom admonitions
trallard Jun 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/community/structure.md
Expand Up @@ -9,14 +9,14 @@ The content is written in a combination of reStructuredText and MyST Markdown.
## Location and structure of CSS/JS assets

The CSS and JS for this theme are built for the browser from `src/pydata_sphinx_theme/assets/*` with
[webpack](https://webpack.js.org/). The main entrypoints are:
[webpack](https://webpack.js.org/). The main entry points are:

- CSS: `src/pydata_sphinx_theme/assets/styles/index.scss`
- CSS: `src/pydata_sphinx_theme/assets/styles/pydata-sphinx-theme.scss`

- the main part of the theme assets
- customizes [Bootstrap](https://getbootstrap.com/) with [Sass](https://sass-lang.com)

- JS: `src/pydata_sphinx_theme/assets/scripts/index.js`
- JS: `src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js`

- provides add-on Bootstrap features, as well as some custom navigation behavior

Expand Down
Expand Up @@ -53,7 +53,8 @@ $extra-semantic-colors: (
"dark": map-get($pst-semantic-colors, "text-base"),
"muted": map-get($pst-semantic-colors, "text-muted"),
"light": rgb(201, 201, 201),
"black": rgb(0, 0, 0),
"black": hsl(216, 20%, 10%),
//gray-900
"white": rgb(255, 255, 255),
);

Expand Down
167 changes: 115 additions & 52 deletions src/pydata_sphinx_theme/assets/styles/variables/_color.scss
Expand Up @@ -5,97 +5,160 @@
* NOTE: this theme defines "info == primary" and "warning == secondary"
*/
$pst-semantic-colors: (
"primary": rgb(69, 157, 185),
"secondary": rgb(238, 144, 64),
"info": rgb(69, 157, 185),
"warning": rgb(238, 144, 64),
"primary": (
//WCAG AA compliant against dark bg
"50": #f4fbfc,
"100": #e9f6f8,
"200": #d0ecf1,
"300": #abdde6,
"400": #3fb1c5,
//WCAG AA compliant against light bg
"500": #0a7d91,
"600": #085d6c,
"700": #064752,
"800": #042c33,
"900": #021b1f,
),
"secondary": (
//WCAG AA compliant against dark bg
"50": #fbf8fe,
"100": #f6f2fe,
"200": #ece3fc,
"300": #decdfa,
"400": #b691f5,
//WCAG AA compliant against light bg
"500": #894def,
"600": #6730c5,
"700": #4e2595,
"800": #31175f,
"900": #1e0e39,
),
"info": (
"light": #276be9,
"light-bg": #eff4fd,
"dark": #79a3f2,
"dark-bg": #06245d,
),
"warning": (
"light": #f66a0a,
"light-bg": #fff8f2,
"dark": #ff9245,
"dark-bg": #652a02,
),
"success": (
"light": rgb(40, 167, 69),
"dark": rgb(72, 135, 87),
"light": #00843f,
"light-bg": #ecf6f1,
"dark": #5fb488,
"dark-bg": #002f17,
),
"attention": (
"light": rgb(255, 193, 7),
"dark": rgb(220, 169, 15),
"light": #f66a0a,
"light-bg": #fff8f2,
"dark": #ff9245,
"dark-bg": #652a02,
),
"danger": (
"light": rgb(220, 53, 69),
"dark": rgb(203, 70, 83),
"light": #d72d47,
"light-bg": #fcf1f2,
"dark": #e78894,
"dark-bg": #4e111b,
),
"text-base": (
"light": rgb(50, 50, 50),
// Black + 50
"dark": rgb(206, 206, 206),
// White - 50
"light": rgb(34, 40, 50),
// gray-800
// "dark": #e5e7ea
trallard marked this conversation as resolved.
Show resolved Hide resolved
"dark": #ced6dd,
// gray-100
),
"text-muted": (
"light": rgb(100, 100, 100),
// Twice as far from 0 as base
"dark": rgb(166, 166, 166),
// Twice as far from 256 as base
),
"shadow": (
"light": rgb(216, 216, 216),
"dark": rgb(33, 33, 33),
),
"border": (
"light": rgb(201, 201, 201),
"dark": rgb(192, 192, 192),
),
"inline-code": (
"light": rgb(232, 62, 140),
"dark": rgb(221, 158, 194),
),
"target": (
"light": rgb(251, 229, 78),
"dark": rgb(71, 39, 0),
"light": #48566b,
// gray-600
"dark": #d1d5da,
// gray-300
),
// TODO - update
"shadow":
(
// "light": rgb(216, 216, 216),
"light": rgba(0, 0, 0, 0.1),
"dark": rgba(0, 0, 0, 0.2),
),
// TODO- update (need muted and regular - this is muted)
"border":
(
"light": rgba(23, 23, 26, 0.2),
"dark": #48566b,
),
// TODO - update
"inline-code":
(
"light": rgb(232, 62, 140),
"dark": rgb(221, 158, 194),
),
// TODO - update
"target":
(
"light": rgb(251, 229, 78),
"dark": rgb(71, 39, 0),
),
// DEPTH COLORS
// background: color of the canvas / the furthest back layer
"background":
(
"light": rgb(255, 255, 255),
"dark": rgb(18, 18, 18),
"dark": #14181e,
),
// on-background: provides slight contrast against background
// (by use of shadows in light theme)
"on-background":
(
"light": rgb(255, 255, 255),
"dark": rgb(30, 30, 30),
"dark": #222832,
// gray-800
),
// surface: object set above the background (without shadows)
// Uses JupyterLab cell background colors in light/dark theme
trallard marked this conversation as resolved.
Show resolved Hide resolved
"surface":
(
"light": rgb(245, 245, 245),
"dark": rgb(33, 33, 33),
"light": #f3f4f5,
// gray-100
"dark": #364150,
// gray-700
),
// on_surface: object on top of surface object (without shadows)
//TODO - update
"on-surface":
(
"light": rgb(225, 225, 225),
"dark": rgb(55, 55, 55),
),
);

/*******************************************************************************
* write the color rules for each theme (light/dark)
*/
@mixin create-color-var($key, $value, $identifier: "") {
//$identifier is an optional variable - used for the new system
@if $identifier != "" {
--pst-color-#{$key}-#{$identifier}: #{$value};
} @else {
--pst-color-#{$key}: #{$value};
}
}

/* NOTE:
* Mixins enable us to reuse the same definitions for the different modes
* https://sass-lang.com/documentation/at-rules/mixin
* #{...} inserts a variable into a CSS selector or property name
* https://sass-lang.com/documentation/interpolation
*/
@mixin theme-colors($mode) {
// check if this color is defined differently for light/dark
@each $name, $value in $pst-semantic-colors {
// check if there is a map (i.e. multiple light/dark definitions)
@if type-of($value) == map {
$value: map-get($value, $mode);
}
& {
--pst-color-#{$name}: #{$value};
// support for single light/dark colour definitions
@if map-has-key($value, $mode) {
$value: map-get($value, $mode);
@include create-color-var($name, $value);
} // support for multiple light/dark colour definitions - as our new design system
@else {
@each $key, $val in $value {
@include create-color-var($key, $val, $name);
}
}
} @else {
@include create-color-var($name, $value);
}
}
// assign the "duplicate" colors (ones that just reference other variables)
Expand Down