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

dhall-docs: Fix white flashes on page load in dark mode #2574

Merged
merged 2 commits into from
Apr 12, 2024

Conversation

kukimik
Copy link
Collaborator

@kukimik kukimik commented Mar 11, 2024

Loading a page with dark mode enabled currently results in a short white flash. This happens because the page is first rendered in light mode, and only after it is loaded the class indicating that dark mode is enabled is toggled. The effect is even more visible because of the 0.5s transition effect set in CSS.

test

This PR solves the problem by toggling the class indicating that dark mode is enabled before the page is rendered (the script is called inside <head>). The class is now set on the <html> element instead of <body> because document.body is not ready yet when the script is executed.

@kukimik kukimik force-pushed the dark_flash branch 2 times, most recently from c1fe557 to c701c6d Compare March 12, 2024 14:17
@kukimik
Copy link
Collaborator Author

kukimik commented Mar 12, 2024

The hydra build failed with:

building
Preprocessing library 'metamodel' for lsp-types-2.0.1.0..
Building library 'metamodel' for lsp-types-2.0.1.0..
[1 of 2] Compiling Language.LSP.MetaModel.Types ( metamodel/Language/LSP/MetaModel/Types.hs, dist/build/metamodel/Language/LSP/MetaModel/Types.o, dist/build/metamodel/Language/LSP/MetaModel/Types.dyn_o )

<no location info>: error:
    /tmp/nix-build-lsp-types-2.0.1.0.drv-0/ghc1648975_0/ghc_4.s: hClose: resource exhausted (No space left on device)

which is probably not my fault.

We set the class indicating that dark mode is
enabled before the page is rendered (the script
is called inside `<head>`). The class is now
set on the `<html>` element instead of `<body>`
because `document.body` is not ready yet when
the script is executed.
@kukimik kukimik merged commit ec50168 into dhall-lang:main Apr 12, 2024
6 checks passed
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.

1 participant