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

Refactor color schemes to avoid repetition; add dark color scheme #258

Merged
merged 3 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
minor_changes:
- Add support for "dark mode" to the option table styling (https://github.com/ansible-community/antsibull-docs/pull/253).
- Add support for "dark mode" to the option table styling (https://github.com/ansible-community/antsibull-docs/pull/253, https://github.com/ansible-community/antsibull-docs/pull/258).
7 changes: 4 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ The `sphinx_antsibull_ext` [Sphinx extension](https://www.sphinx-doc.org/en/mast
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'notfound.extension', 'sphinx_antsibull_ext']
```

It is possible to configure the color scheme used by the extension using the `antsibull_ext_color_scheme` configuration. Currently, three values are supported:
It is possible to configure the color scheme used by the extension using the `antsibull_ext_color_scheme` configuration. Currently, the following values are supported:

1. `default`: the default colors.
2. `default-autodark`: the default colors with dark mode support.
3. `none`: define no colors. You can use this if you want to override all colors by your own definition and thus have no need for the default colors to be included.
2. `default-dark`: a dark color scheme.
3. `default-autodark`: the default colors or the dark colors, depending on a `prefers-color-scheme` media query.
4. `none`: define no colors. You can use this if you want to override all colors by your own definition and thus have no need for the default colors to be included.

The default color scheme can be found in [src/sphinx_antsibull_ext/css/colors-default.scss](https://github.com/ansible-community/antsibull-docs/blob/main/src/sphinx_antsibull_ext/css/colors-default.scss). See the [MDN page on using CSS custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties) for information on how the color definitions work.

Expand Down
1 change: 1 addition & 0 deletions src/sphinx_antsibull_ext/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"none",
"default",
"default-autodark",
"default-dark",
]


Expand Down
1 change: 1 addition & 0 deletions src/sphinx_antsibull_ext/colors-default-dark.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/sphinx_antsibull_ext/colors-default-dark.css.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
SPDX-FileCopyrightText: Ansible and contributors
SPDX-License-Identifier: GPL-3.0-or-later
1 change: 1 addition & 0 deletions src/sphinx_antsibull_ext/css/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ build_css() {
build_css antsibull-minimal
build_css colors-default
build_css colors-default-autodark
build_css colors-default-dark

grep -Fq '/* INSERT COLOR SCHEME HERE */' ../antsibull-minimal.css || (echo -e "\nERROR: Placeholder not found!" ; exit 1)
67 changes: 5 additions & 62 deletions src/sphinx_antsibull_ext/css/colors-default-autodark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,70 +2,13 @@
// GNU General Public License v3.0+ (see https://www.gnu.org/licenses/gpl-3.0.txt)
// SPDX-License-Identifier: GPL-3.0-or-later

:root {
// Links
--antsibull-links-background: #5bbdbf;
--antsibull-links-background-active: #91d9db;
--antsibull-links-focus-outline: #204748;
--antsibull-links-text: white;

// Tables
--antsibull-table-background-header: #6AB0DE;
--antsibull-table-background-even: #E7F2FA;
--antsibull-table-background-odd: #FFFFFF;
--antsibull-table-border: #000000;

// Narrow width "table" view that's no longer a table
--antsibull-narrowtable-background: #E7F2FA;
@use 'default-colors-light' as light;
@use 'default-colors-dark' as dark;

// Options
--antsibull-option-type: purple;
--antsibull-option-elements: purple;
--antsibull-option-required: red;
--antsibull-option-version-added: darkgreen;
--antsibull-option-aliases: darkgreen;
--antsibull-option-default: blue;
--antsibull-option-sample: blue;
--antsibull-option-sample-header: black;

// Attribute support
--antsibull-attribute-support-none: red;
--antsibull-attribute-support-partial: #a5a500;
--antsibull-attribute-support-full: green;
--antsibull-attribute-support-na: inherit;
:root {
@include light.colors;

@media (prefers-color-scheme: dark) {

// Links
--antsibull-links-background: #5bbdbf;
--antsibull-links-background-active: #91d9db;
--antsibull-links-focus-outline: #204748;
--antsibull-links-text: white;

// Tables
--antsibull-table-background-header: #48484b;
--antsibull-table-background-even: #1c1c1e;
--antsibull-table-background-odd: #242426;
--antsibull-table-border: #656569;

// Narrow width "table" view that's no longer a table
--antsibull-narrowtable-background: #48484b;

// Options
--antsibull-option-type: #ff93ff;
--antsibull-option-elements: #ff93ff;
--antsibull-option-required: #ff8282;
--antsibull-option-version-added: #71d471;
--antsibull-option-aliases: #71d471;
--antsibull-option-default: #adadff;
--antsibull-option-sample: #adadff;
--antsibull-option-sample-header: white;

// Attribute support
--antsibull-attribute-support-none: #ff8282;
--antsibull-attribute-support-partial: #b6b600;
--antsibull-attribute-support-full: #00cc00;
--antsibull-attribute-support-na: inherit;

@include dark.colors;
}
}
9 changes: 9 additions & 0 deletions src/sphinx_antsibull_ext/css/colors-default-dark.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) Ansible and contributors
// GNU General Public License v3.0+ (see https://www.gnu.org/licenses/gpl-3.0.txt)
// SPDX-License-Identifier: GPL-3.0-or-later

@use 'default-colors-dark' as dark;

:root {
@include dark.colors;
}
33 changes: 3 additions & 30 deletions src/sphinx_antsibull_ext/css/colors-default.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,8 @@
// GNU General Public License v3.0+ (see https://www.gnu.org/licenses/gpl-3.0.txt)
// SPDX-License-Identifier: GPL-3.0-or-later

:root {
// Links
--antsibull-links-background: #5bbdbf;
--antsibull-links-background-active: #91d9db;
--antsibull-links-focus-outline: #204748;
--antsibull-links-text: white;

// Tables
--antsibull-table-background-header: #6AB0DE;
--antsibull-table-background-even: #E7F2FA;
--antsibull-table-background-odd: #FFFFFF;
--antsibull-table-border: #000000;

// Narrow width "table" view that's no longer a table
--antsibull-narrowtable-background: #E7F2FA;
@use 'default-colors-light' as light;

// Options
--antsibull-option-type: purple;
--antsibull-option-elements: purple;
--antsibull-option-required: red;
--antsibull-option-version-added: darkgreen;
--antsibull-option-aliases: darkgreen;
--antsibull-option-default: blue;
--antsibull-option-sample: blue;
--antsibull-option-sample-header: black;

// Attribute support
--antsibull-attribute-support-none: red;
--antsibull-attribute-support-partial: #a5a500;
--antsibull-attribute-support-full: green;
--antsibull-attribute-support-na: inherit;
:root {
@include light.colors;
}
36 changes: 36 additions & 0 deletions src/sphinx_antsibull_ext/css/default-colors-dark.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) Ansible and contributors
// GNU General Public License v3.0+ (see https://www.gnu.org/licenses/gpl-3.0.txt)
// SPDX-License-Identifier: GPL-3.0-or-later

@mixin colors {
// Links
--antsibull-links-background: #5bbdbf;
--antsibull-links-background-active: #91d9db;
--antsibull-links-focus-outline: #204748;
--antsibull-links-text: white;

// Tables
--antsibull-table-background-header: #48484b;
--antsibull-table-background-even: #1c1c1e;
--antsibull-table-background-odd: #242426;
--antsibull-table-border: #656569;

// Narrow width "table" view that's no longer a table
--antsibull-narrowtable-background: #48484b;

// Options
--antsibull-option-type: #ff93ff;
--antsibull-option-elements: #ff93ff;
--antsibull-option-required: #ff8282;
--antsibull-option-version-added: #71d471;
--antsibull-option-aliases: #71d471;
--antsibull-option-default: #adadff;
--antsibull-option-sample: #adadff;
--antsibull-option-sample-header: white;

// Attribute support
--antsibull-attribute-support-none: #ff8282;
--antsibull-attribute-support-partial: #b6b600;
--antsibull-attribute-support-full: #00cc00;
--antsibull-attribute-support-na: inherit;
}
36 changes: 36 additions & 0 deletions src/sphinx_antsibull_ext/css/default-colors-light.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) Ansible and contributors
// GNU General Public License v3.0+ (see https://www.gnu.org/licenses/gpl-3.0.txt)
// SPDX-License-Identifier: GPL-3.0-or-later

@mixin colors {
// Links
--antsibull-links-background: #5bbdbf;
--antsibull-links-background-active: #91d9db;
--antsibull-links-focus-outline: #204748;
--antsibull-links-text: white;

// Tables
--antsibull-table-background-header: #6AB0DE;
--antsibull-table-background-even: #E7F2FA;
--antsibull-table-background-odd: #FFFFFF;
--antsibull-table-border: #000000;

// Narrow width "table" view that's no longer a table
--antsibull-narrowtable-background: #E7F2FA;

// Options
--antsibull-option-type: purple;
--antsibull-option-elements: purple;
--antsibull-option-required: red;
--antsibull-option-version-added: darkgreen;
--antsibull-option-aliases: darkgreen;
--antsibull-option-default: blue;
--antsibull-option-sample: blue;
--antsibull-option-sample-header: black;

// Attribute support
--antsibull-attribute-support-none: red;
--antsibull-attribute-support-partial: #a5a500;
--antsibull-attribute-support-full: green;
--antsibull-attribute-support-na: inherit;
}
Loading