Skip to content

Avoid white flash on page reload in dark theme #8494

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

Merged
merged 5 commits into from
Apr 7, 2025
Merged

Conversation

fm3
Copy link
Member

@fm3 fm3 commented Apr 2, 2025

Our dark theme is rendered dynamically with javascript.
That means that before javascript is initialized, there is a flash of white. This happens on every page reload.
Adding a pure css rule in the main html prevents that.

URL of deployed dev instance (used for testing):

Steps to test:

  • In your browser, select dark theme
  • hit some page reloads on wk
  • Should not see flash of white

Issues:

@fm3 fm3 self-assigned this Apr 2, 2025
Copy link
Contributor

coderabbitai bot commented Apr 2, 2025

📝 Walkthrough

Walkthrough

The changes update the main view template to conditionally apply a dark background based on the selectedTheme variable. When the theme is set to "auto", a media query applies a black background for dark mode, while "dark" directly applies a black background style. Additionally, the syntax for Open Graph meta tags has been condensed into single-line expressions for improved readability, without altering their functionality.

Changes

File(s) Change Summary
app/views/main.scala.html Added conditional styling for dark mode when selectedTheme is "auto" (via media query) or "dark" (direct style); refactored Open Graph meta tag mapping for clarity.
project/license.sbt Updated SBT plugin declaration for sbt-license-report from version 1.2.0 (com.typesafe.sbt) to 1.7.0 (com.github.sbt).

Assessment against linked issues

Objective Addressed Explanation
Flash of white when (re)loading the app in dark theme (#8375)

Possibly related PRs

  • Fix color theme for modals #8445: The changes in the main PR, which involve conditional styling based on the selectedTheme variable, are related to the retrieved PR that fixes color themes for modals by ensuring they respect user theme preferences, as both address theme management in the UI.

Suggested reviewers

  • philippotto

Poem

Hop along in lines and code,
I’ve tuned the themes on every node.
With dark mode set and glitches gone,
My rapid hops not overdrawn.
I the rabbit cheer, "Hooray!" with a yawn! 🥕✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6e7c6c3 and 066c199.

📒 Files selected for processing (1)
  • project/license.sbt (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: circleci_build
🔇 Additional comments (1)
project/license.sbt (1)

1-1:

✅ Verification successful

Plugin migration and version update looks good.

The change updates the SBT plugin from com.typesafe.sbt organization to com.github.sbt and upgrades the version from 1.2.0 to 1.7.0. This appears to be a necessary migration as the plugin has moved to a new organization.

This dependency update is unrelated to the PR's main objective of fixing the white flash in dark theme, but is likely part of general maintenance.


🏁 Script executed:

#!/bin/bash
# Verify SBT version compatibility with the updated plugin
cat project/build.properties | grep "sbt.version"

# Check for any migration guides or breaking changes
echo "Note: Please verify compatibility with your SBT version and check if there are any breaking changes in the plugin's migration from com.typesafe.sbt to com.github.sbt"

Length of output: 412


Plugin update verified: Compatible with SBT 1.10.1

  • The SBT version in project/build.properties (1.10.1) is confirmed to be compatible with the updated plugin.
  • The migration from the com.typesafe.sbt organization to com.github.sbt and upgrade from version 1.2.0 to 1.7.0 appears correct.
  • This dependency update remains a general maintenance change and is unrelated to the dark theme fix.

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@fm3 fm3 marked this pull request as ready for review April 3, 2025 08:26
@fm3 fm3 requested a review from knollengewaechs April 3, 2025 08:26
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
app/views/main.scala.html (2)

9-12: Ensure Correct Application of Dark Theme Background

The conditional style blocks for handling the dark theme are correctly implemented. When selectedTheme is "auto", the media query is added to conditionally set the background to black based on the user's system preference, and when it is "dark", a direct style is applied. The use of @@media is the appropriate way to escape the @ in the Play Framework template.

Consider appending a semicolon after background: black (i.e. background: black;) within the CSS block for consistency and to adhere to common CSS style guidelines.


14-16: Consistent Formatting for Open Graph Meta Tags

The revised one-line expressions for the Open Graph meta tags improve readability by condensing the optional mappings. For uniformity, consider inserting a space after the lambda arrow (=>) throughout. For example, modifying

@openGraphTitle.map { ogt =><meta ... }

to

@openGraphTitle.map { ogt => <meta ... }

will enhance consistency.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fa4dd9c and 6e7c6c3.

📒 Files selected for processing (1)
  • app/views/main.scala.html (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: circleci_build
🔇 Additional comments (1)
app/views/main.scala.html (1)

17-17: Validation of WKORG Instance Check

The conditional check for conf.Features.isWkorgInstance remains intact, ensuring that additional meta tags (such as description and keywords) are only included when appropriate. This maintains the intended functionality of the page.

@fm3 fm3 added the css Something frontend styling related label Apr 3, 2025
Copy link
Contributor

@knollengewaechs knollengewaechs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the code looks good and testing in a chromium-based browser and firefox was also great 😊 thanks for fixing this! 🙏

@fm3 fm3 enabled auto-merge (squash) April 7, 2025 06:00
@fm3 fm3 merged commit d26c4e8 into master Apr 7, 2025
3 checks passed
@fm3 fm3 deleted the dark-theme-avoid-flash branch April 7, 2025 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend bug css Something frontend styling related enhancement frontend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flash of white when (re)loading the app in dark theme
2 participants