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

Allow hard-coding light/dark/dual mode #28

Closed
McSinyx opened this issue Nov 10, 2020 · 5 comments
Closed

Allow hard-coding light/dark/dual mode #28

McSinyx opened this issue Nov 10, 2020 · 5 comments
Labels
enhancement New feature or request wontfix This will not be worked on

Comments

@McSinyx
Copy link

McSinyx commented Nov 10, 2020

If the site's author uses images with transparent background, only light or dark would work, so it'd be nice if perse can hint that the other mode is broken by hard-coding the working mode.

Describe the solution you'd like

As suggested by @pavithraes on GH-24:

Something like a setting in conf.py for the preferred action?

html_theme_options = {
    "theme-color": light/dark/dual,
}

Describe alternatives you've considered

None.

Additional context

If plantuml plugin is used for Sphinx, the diagram would look somewhat like this in dark mode:

2020-11-10T13:19:08

One could tweak the plantuml theme but it's not very easy to get something looking nice for both dark and light.

@McSinyx McSinyx added the enhancement New feature or request label Nov 10, 2020
@pradyunsg
Copy link
Owner

"hey, don't do that" :)

Overall, I prefer that documentation authors to support both the color schemes properly and would like to enforce that preference here. Supporting this would also introduce complexity in the CSS and I don't think that complexity is worthwhile. For elements that don't work well with light/dark mode, I recommend using .. rstclass:: only-light and .. rstclass:: only-dark to ensure things look OK.

For folks who really want to disable a specific mode, they can override the CSS variables to effectively disable the dark/light mode. It's not something I want to make easy, for the reasons stated above.

@pradyunsg pradyunsg added the wontfix This will not be worked on label Nov 10, 2020
@McSinyx
Copy link
Author

McSinyx commented Nov 10, 2020

Supporting this would also introduce complexity in the CSS and I don't think that complexity is worthwhile.

This makes sense to me, I thought it was possible to do it in the Sphinx layer. .. rst-class:: only-light doesn't seem to have any effect and I don't have the mental space to play with the hard way at this moment, so I guess I try to avoid using plantuml with furo 🤷 (it's a school thing).

@pradyunsg
Copy link
Owner

Oh yea, that'll need to wait until 3d89d56 makes it into a release. :)

merlinND added a commit to mitsuba-renderer/mitsuba3 that referenced this issue Jul 8, 2022
The `furo` theme does not allow disabling dark mode with a configuration option:
pradyunsg/furo#28

Instead of changing the theme at load time (previous solution),
we override all dark theme colors to be equal to the light theme.

We also include overrides for the `sphinx_tabs` and `pygments` extensions.

+ specify the `language` sphinx option (there was a warning if left to `None`)
+ fix display and positioning of `copybutton` in notebooks
Speierers pushed a commit to mitsuba-renderer/mitsuba3 that referenced this issue Jul 8, 2022
The `furo` theme does not allow disabling dark mode with a configuration option:
pradyunsg/furo#28

Instead of changing the theme at load time (previous solution),
we override all dark theme colors to be equal to the light theme.

We also include overrides for the `sphinx_tabs` and `pygments` extensions.

+ specify the `language` sphinx option (there was a warning if left to `None`)
+ fix display and positioning of `copybutton` in notebooks
@merlinND
Copy link

merlinND commented Jul 8, 2022

For future reference, the following config options manage to "force light mode" by making dark mode colors equal to the light mode ones (values taken from _colors.scss).
It's just a workaround, but worked for us.

html_theme_options = {
    # Since Furo doesn't allow us to disable dark mode, we make dark mode
    # equivalent to light mode by overriding all colors back to their light value.
    # See: https://github.com/pradyunsg/furo/issues/28
    'dark_css_variables': {
        # Taken from: https://github.com/pradyunsg/furo/blob/c682d5d3502f3fa713c909eebbf9f3afa0f469d9/src/furo/assets/styles/variables/_colors.scss
        'color-problematic': '#b30000',

        # Base Colors
        'color-foreground-primary': 'black', # for main text and headings
        'color-foreground-secondary': '#5a5c63', # for secondary text
        'color-foreground-muted': '#646776', # for muted text
        'color-foreground-border': '#878787', # for content borders

        'color-background-primary': 'white', # for content
        'color-background-secondary': '#f8f9fb', # for navigation + ToC
        'color-background-hover': '#efeff4ff', # for navigation-item hover
        'color-background-hover--transparent': '#efeff400',
        'color-background-border': '#eeebee', # for UI borders
        'color-background-item': '#ccc', # for "background" items (eg: copybutton)

        # Announcements
        'color-announcement-background': '#000000dd',
        'color-announcement-text': '#eeebee',

        # Brand colors
        'color-brand-primary': '#2962ff',
        'color-brand-content': '#2a5adf',

        # Highlighted text (search)
        'color-highlighted-background': '#ddeeff',

        # GUI Labels
        'color-guilabel-background': '#ddeeff80',
        'color-guilabel-border': '#bedaf580',

        # API documentation
        'color-api-keyword': 'var(--color-foreground-secondary)',
        'color-highlight-on-target': '#ffffcc',

        # Admonitions
        'color-admonition-background': 'transparent',

        # Cards
        'color-card-border': 'var(--color-background-secondary)',
        'color-card-background': 'transparent',
        'color-card-marginals-background': 'var(--color-background-hover)',

        # Code blocks
        'color-code-foreground': 'black',
        'color-code-background': '#f8f9fb',
    }
}
# Force pygments style in dark mode back to the light variant
pygments_dark_style = 'tango'

Speierers pushed a commit to mitsuba-renderer/mitsuba3 that referenced this issue Jul 15, 2022
The `furo` theme does not allow disabling dark mode with a configuration option:
pradyunsg/furo#28

Instead of changing the theme at load time (previous solution),
we override all dark theme colors to be equal to the light theme.

We also include overrides for the `sphinx_tabs` and `pygments` extensions.

+ specify the `language` sphinx option (there was a warning if left to `None`)
+ fix display and positioning of `copybutton` in notebooks
@aidanCQ
Copy link

aidanCQ commented Jan 12, 2023

This worked for me. Hide the toggle button using CSS:

.theme-toggle-container {
  display: none;
}

Override the body's data attribute with JS:

document.body.setAttribute("data-theme", "dark");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants