Skip to content

Commit 45bd9af

Browse files
12rambaucholdgraf
andauthored
ENH: simplify color variables (#659)
* draft of new color scheme * remove background of the guilabel * remove navbar shadow in dark theme * remove shadow in versionmodified * use target color for viewcode background * change target opacity * change the order of the viewcode target background * set admonition background * reset viewcode color * explain the depth variables * lighten the depth color in dark theme * use a background for version directive * move the target background object * use background-color for viewcode target * remove the never used admonition transition * use the new variable name * update colors and variable customization docs * correct sphinx warnings (#5) * wrong code highlight * Docs updates * overwrite header settings from panel lib Co-authored-by: Chris Holdgraf <[email protected]>
1 parent 74d68d6 commit 45bd9af

File tree

18 files changed

+208
-359
lines changed

18 files changed

+208
-359
lines changed

docs/user_guide/customizing.rst

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ To add a custom stylesheet, follow these steps:
2727
1. **Create a CSS stylesheet** in ``_static/css/custom.css``, and add the CSS rules you wish.
2828
2. **Attach the stylesheet to your Sphinx build**. Add the following to ``conf.py``
2929

30-
.. code-block:: rst
30+
.. code-block:: python
3131
3232
html_static_path = ['_static']
3333
@@ -141,19 +141,21 @@ CSS Theme variables
141141
===================
142142

143143
This theme defines several `CSS variables <css-variable-help_>`_ that can be
144-
used to quickly control behavior across your documentation.
144+
used to quickly control behavior and display across your documentation.
145145

146146
These are based on top of the basic `Bootstrap CSS variables <https://getbootstrap.com/docs/4.0/getting-started/theming/#css-variables>`_
147-
extended with some theme specific variables. An overview of all variables and
148-
every default is defined in `the pydata default CSS variables file <pydata-css-variables_>`_.
147+
extended with some theme specific variables.
148+
149+
base variables
150+
--------------
149151

150152
In order to change a variable, follow these steps:
151153

152154
1. :ref:`Add a custom CSS stylesheet <custom-css>`. This is where we'll configure the variables.
153155
2. Underneath a ``:root`` section, add the variables you wish to update. For example, to update
154156
the base font size, you might add this to ``custom.css``:
155157

156-
.. code-block:: none
158+
.. code-block:: css
157159
158160
:root {
159161
--pst-font-size-base: 17px;
@@ -172,6 +174,31 @@ For a complete list of the theme variables that you may override, see the
172174
.. literalinclude:: ../../src/pydata_sphinx_theme/theme/pydata_sphinx_theme/static/styles/theme.css
173175
:language: CSS
174176

177+
Color variables
178+
---------------
179+
180+
Each color variable has two values, one corresponding to the "light" and one for the "dark" theme.
181+
These are used throughout many of the theme elements to define text color, background color, etc.
182+
183+
You can control the colors used for these variables for each theme by
184+
:ref:`adding a custom CSS stylesheet <custom-css>` and adding a structure like so:
185+
186+
.. code-block:: css
187+
188+
html[data-theme="light"] {
189+
--pst-color-primary: black;
190+
}
191+
192+
html[data-theme="dark"] {
193+
--pst-color-primary: white;
194+
}
195+
196+
For a complete list of the theme colors that you may override, see the
197+
`color variables defaults CSS file <pydata-css-colors_>`_:
198+
199+
.. literalinclude:: ../../src/pydata_sphinx_theme/assets/styles/base/_color.scss
200+
:language: scss
201+
175202
Change footer display
176203
=====================
177204

@@ -253,7 +280,7 @@ The default body and header fonts can be changed as follows:
253280
before waiting for the CSS to be parsed, but should be used with care.
254281

255282
.. _pydata-css-variables: https://github.com/pydata/pydata-sphinx-theme/blob/master/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/static/styles/theme.css
256-
.. _pydata-css-colors: https://github.com/pydata/pydata-sphinx-theme/blob/master/src/pydata_sphinx_theme/assets/style/color.scss
283+
.. _pydata-css-colors: https://github.com/pydata/pydata-sphinx-theme/blob/master/src/pydata_sphinx_theme/assets/styles/base/_color.scss
257284
.. _css-variable-help: https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties
258285

259286
.. meta::

src/pydata_sphinx_theme/assets/styles/abstracts/_mixins.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
}
1212

1313
&::-webkit-scrollbar-thumb {
14-
background: var(--pst-color-deactivate);
14+
background: var(--pst-color-text-muted);
1515
border-radius: 0.25rem;
1616
}
1717

src/pydata_sphinx_theme/assets/styles/base/_base.scss

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ body {
2424
p {
2525
margin-bottom: 1.15rem;
2626
font-size: 1em;
27-
color: var(--pst-color-paragraph);
27+
color: var(--pst-color-text-base);
2828

2929
/* section header in docstring pages */
3030
&.rubric {
@@ -46,7 +46,7 @@ a {
4646
}
4747

4848
&.headerlink {
49-
color: var(--pst-color-headerlink);
49+
color: var(--pst-color-danger);
5050
opacity: 0.4;
5151
font-size: 0.8em;
5252
padding: 0 4px 0 4px;
@@ -72,37 +72,37 @@ h1 {
7272
@extend .heading-style;
7373
margin-top: 0;
7474
font-size: var(--pst-font-size-h1);
75-
color: var(--pst-color-h1);
75+
color: var(--pst-color-primary);
7676
}
7777

7878
h2 {
7979
@extend .heading-style;
8080
font-size: var(--pst-font-size-h2);
81-
color: var(--pst-color-h2);
81+
color: var(--pst-color-primary);
8282
}
8383

8484
h3 {
8585
@extend .heading-style;
8686
font-size: var(--pst-font-size-h3);
87-
color: var(--pst-color-h3);
87+
color: var(--pst-color-text-base);
8888
}
8989

9090
h4 {
9191
@extend .heading-style;
9292
font-size: var(--pst-font-size-h4);
93-
color: var(--pst-color-h4);
93+
color: var(--pst-color-text-base);
9494
}
9595

9696
h5 {
9797
@extend .heading-style;
9898
font-size: var(--pst-font-size-h5);
99-
color: var(--pst-color-h5);
99+
color: var(--pst-color-text-base);
100100
}
101101

102102
h6 {
103103
@extend .heading-style;
104104
font-size: var(--pst-font-size-h6);
105-
color: var(--pst-color-h6);
105+
color: var(--pst-color-text-base);
106106
}
107107

108108
small,
@@ -122,19 +122,25 @@ samp {
122122
font-family: var(--pst-font-family-monospace);
123123
}
124124

125+
kbd {
126+
// use theme negative
127+
background-color: var(--pst-color-text-base);
128+
color: var(--pst-color-background);
129+
}
130+
125131
code {
126132
color: var(--pst-color-inline-code);
127133
}
128134

129135
pre {
130136
margin: 1.5em 0 1.5em 0;
131137
padding: 10px;
132-
background-color: var(--pst-color-preformatted-background);
133-
color: var(--pst-color-preformatted-text);
138+
background-color: var(--pst-color-surface);
139+
color: var(--pst-color-text-base);
134140
line-height: 1.2em;
135-
border: 1px solid var(--pst-color-preformatted-border);
141+
border: 1px solid var(--pst-color-border);
136142
border-radius: 0.2rem;
137-
box-shadow: 1px 1px 1px var(--pst-color-preformatted-shadow);
143+
box-shadow: 1px 1px 1px var(--pst-color-shadow);
138144

139145
@include scrollbar-style();
140146
@include scrollbar-on-hover();

0 commit comments

Comments
 (0)