dotnet / docfx

Static site generator for .NET API documentation.
https://dotnet.github.io/docfx/
MIT License
4.03k stars 858 forks source link

[Feature Request] Images for light and dark theme #9386

Open okvalsralos opened 10 months ago

okvalsralos commented 10 months ago

Describe the solution you'd like docfx has a switcher in the header that lets readers choose between the light and the dark theme. If applicable authors should provide both the light and the dark version of every screenshot used in the documentation.

Additional context Add the _dark.png suffix to the name of the dark image version. This image will be then used when the user switches to the dark theme.

For example, save images as example.png and example_dark.png.

BarkenBark commented 9 months ago

+1

CaseyHofland commented 9 months ago

+1

bitbonk commented 8 months ago

Until this feature is implemented, do you known of any trick or workaround how to provide different images (and some icons) based on the theme?

zhaparoff commented 2 months ago

Or at least set light theme as default and disable theme switcher without deep diving into custom template creation...

ghost commented 2 months ago

It depends on the logo, but it's possible to create a transparent background logo which will work in light and dark themes.

bouda19 commented 1 month ago

@bitbonk

You can achieve that by adding a custom template and a main.css file with the following content :

#logo {
    margin-right: 10px;
}

[data-bs-theme=dark] #logo {
    content:url("../images/dark-logo.png");
}

[data-bs-theme=light] #logo {
    content:url("../images/light-logo.png");
}

I have created a sample repo and a sample demo site if needed.