Skip to content

Add a light/dark theme toggle to the documentation site - #247

Open
NopeCharon wants to merge 1 commit into
cedar-policy:mainfrom
NopeCharon:light-mode-toggle
Open

NopeCharon wants to merge 1 commit into
cedar-policy:mainfrom
NopeCharon:light-mode-toggle

Conversation

@NopeCharon

Copy link
Copy Markdown

Closes #224

The site only had the dark awsstyle color scheme. This adds a light variant and a button in the page header to switch between them.

  • The rules shared by both themes move from awsstyle.scss into _sass/awsstyle/_base.scss. The hard-coded text, heading, navigation and inline-code colors become variables that each scheme defines. The dark values are unchanged, so the default look is the same.
  • New awsstyle-light color scheme plus its stylesheet (assets/css/just-the-docs-awsstyle-light.scss).
  • A "Light mode" / "Dark mode" button in header_custom.html. The script in head_custom.html swaps the theme stylesheet before the page renders and stores the choice in localStorage. Dark remains the default for visitors who haven't chosen, and the site still works if storage is unavailable.

Checked by building the site with the repo's Dockerfile setup and loading pages in both themes in a browser; the dark theme looks the same as before.

The site only shipped the dark "awsstyle" color scheme, which some readers
find hard to focus on (cedar-policy#224).

* Move the rules shared by both themes out of awsstyle.scss into
  _sass/awsstyle/_base.scss. The hard-coded text, heading, navigation and
  inline-code colors become variables that each color scheme defines; the
  dark values are unchanged, so the default look of the site is the same.
* Add an awsstyle-light color scheme and its stylesheet
  (assets/css/just-the-docs-awsstyle-light.scss).
* Add a "Light mode" / "Dark mode" button to the page header
  (header_custom.html). The script in head_custom.html swaps the theme
  stylesheet before the page renders and stores the choice in localStorage.
  Dark remains the default for visitors who have not chosen.

Signed-off-by: NopeCharon <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docs in light mode?

1 participant