Skip to content

feat: add initial lumo variables support#29

Open
mlopezFC wants to merge 1 commit intomainfrom
issue-28
Open

feat: add initial lumo variables support#29
mlopezFC wants to merge 1 commit intomainfrom
issue-28

Conversation

@mlopezFC
Copy link
Copy Markdown
Member

@mlopezFC mlopezFC commented Dec 6, 2025

Closes #28

Summary by CodeRabbit

  • New Features

    • Added a dark mode toggle button in the toolbar.
  • Style

    • Integrated Lumo design system for consistent colors and typography.
    • Updated global styles for improved text, background, and card visuals.
  • Bug Fixes

    • Corrected drawer/content spacing so layout margins behave correctly across states.

@mlopezFC mlopezFC requested a review from paodb December 6, 2025 18:24
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 6, 2025

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 571012b6-9e72-4e21-88b7-d7cb6e97a771

📥 Commits

Reviewing files that changed from the base of the PR and between 2967694 and d811cc0.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • dev/index.html
  • package.json
  • src/fc-applayout.ts
✅ Files skipped from review due to trivial changes (1)
  • package.json
🚧 Files skipped from review as they are similar to previous changes (2)
  • dev/index.html
  • src/fc-applayout.ts

Walkthrough

Adds Vaadin Lumo theming and a demo dark-mode toggle, replaces hard-coded colors with Lumo CSS variables in the component, injects styles into the drawer's shadow DOM, and bumps/introduces Vaadin styling dependencies.

Changes

Cohort / File(s) Summary
Demo & HTML
dev/index.html
Imports Vaadin Lumo global color and typography styles at document level; adds a dark-mode toggle icon button and inline script toggling theme="dark" on the document; switches html, body base styling to Lumo CSS variables; removes previous app-drawer content background override; forces .hamlet and .hamlet h5 text color to black.
Package manifest
package.json
Bumps @vaadin/vaadin-themable-mixin (-> 24.3.11) and adds @vaadin/vaadin-lumo-styles@24.3.11; EOF newline removed.
Component implementation
src/fc-applayout.ts
Replaces hard-coded toolbar/header colors with Lumo CSS variables and imports Lumo styles; injects style into app-drawer shadow DOM to apply Lumo base background to #contentContainer; sets #contentContainer flex layout in firstUpdated; fixes _updateMargin indentation/conditional structure.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • paodb
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding support for Lumo CSS variables as the foundation for dark mode functionality.
Linked Issues check ✅ Passed The PR implements dark mode support using Lumo variables (#28): dev/index.html adds a dark-mode toggle, src/fc-applayout.ts replaces hard-coded colors with Lumo CSS variables, and package.json adds the required @vaadin/vaadin-lumo-styles dependency.
Out of Scope Changes check ✅ Passed All changes are directly related to adding Lumo variable support for dark mode: styling updates, Lumo imports, dark-mode toggle UI, and package dependency updates align with the stated objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-28

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Dec 6, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
B Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Copy link
Copy Markdown

@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: 3

🧹 Nitpick comments (1)
src/fc-applayout.ts (1)

218-242: Shadow DOM manipulation is fragile; consider adding defensive checks.

Injecting styles into app-drawer's shadow DOM is a reasonable workaround for theming third-party components, but the non-null assertions (!) will throw if app-drawer changes its internal structure. Consider adding defensive checks:

  override firstUpdated() {
-   const contentContainer = this.drawer.shadowRoot!.getElementById("contentContainer")!;
-   contentContainer.style.display = "flex";
-   contentContainer.style.flexDirection = "column";
+   const contentContainer = this.drawer.shadowRoot?.getElementById("contentContainer");
+   if (contentContainer) {
+     contentContainer.style.display = "flex";
+     contentContainer.style.flexDirection = "column";
+   }

    // Inject Lumo background color into app-drawer shadow DOM
    this._injectDrawerStyles();
  }

  private _injectDrawerStyles() {
+   if (!this.drawer.shadowRoot) return;
+
    // Create a style element to inject Lumo variables into shadow DOM
-   let styleEl = this.drawer.shadowRoot!.querySelector('style#lumo-injected');
+   let styleEl = this.drawer.shadowRoot.querySelector('style#lumo-injected');
    if (!styleEl) {
      styleEl = document.createElement('style');
      styleEl.id = 'lumo-injected';
-     this.drawer.shadowRoot!.appendChild(styleEl);
+     this.drawer.shadowRoot.appendChild(styleEl);
    }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c0471ff and 2967694.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • dev/index.html (1 hunks)
  • package.json (2 hunks)
  • src/fc-applayout.ts (9 hunks)
🔇 Additional comments (4)
dev/index.html (2)

11-15: LGTM!

Correct approach to import Lumo global styles at document level for dark mode support.


168-184: LGTM!

The dark mode toggle implementation correctly follows Vaadin's Lumo pattern by toggling the theme="dark" attribute on the document element.

src/fc-applayout.ts (2)

29-30: LGTM!

Correct imports for Lumo color and typography styles to enable CSS variable support.


50-112: LGTM!

Good migration to Lumo CSS variables throughout the component styles. These will properly respond to dark mode changes.

Comment thread dev/index.html Outdated
Comment thread dev/index.html Outdated
Comment on lines +64 to +88
.hamlet {
user-select: none;
color: black;
}

.hamlet paper-card {
max-width: 600px;
min-width: 200px;
}
.hamlet paper-card {
max-width: 600px;
min-width: 200px;
}

.hamlet paper-card.claudius {
.hamlet paper-card.claudius {
background: rgb(220,248,198);
}
}

.hamlet paper-card h5 {margin-top: 0.25em}
.hamlet paper-card h5 {
margin-top: 0.25em;
color: black;
}

.hamlet paper-card[elevation="0"] {
.hamlet paper-card[elevation="0"] {
background: rgb(254,244,197);
border-radius: 8px;
min-width: 30%;
height: 42px;
}

.hamlet paper-card[elevation="0"] .card-content {
padding: 8px;
text-align: center;
}

menu-item vcf-toggle-button {
padding-bottom: 2px;
}


</style>
</head>
<body>
<fc-applayout>
<div slot="profile" style="text-align: center;">
<img src="./avatar.png" alt="avatar" style="width: 80px; margin-top: 20px;">
<h4 slot="profile">User</h4>
</div>
<img slot="title" class="applogo" src="./applogo.png" alt="applogo">
<div slot="title" main-title="">AppLayout Vaadin 14 Demo</div>
<paper-icon-button disabled slot="toolbar" icon="block" role="button" tabindex="0" aria-disabled="false"></paper-icon-button>
<paper-icon-button slot="toolbar" icon="settings" title="Settings" role="button" tabindex="0" aria-disabled="false"></paper-icon-button>
<div slot="menu">
<p onclick="this.dispatchEvent(new CustomEvent('item-clicked', {bubbles: true}))">This is menu</p>
</div>
<div>
border-radius: 8px;
min-width: 30%;
height: 42px;
}
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot Dec 6, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Hard-coded colors won't adapt to dark mode.

The .hamlet section uses hard-coded colors (color: black, rgb(220,248,198), rgb(254,244,197)) that won't respond to the dark mode toggle. This will result in poor contrast when dark mode is enabled—black text on a dark background.

Consider using Lumo variables for these styles as well, or scope them to light mode only:

     .hamlet {
       user-select: none;
-      color: black;
+      color: var(--lumo-body-text-color);
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.hamlet {
user-select: none;
color: black;
}
.hamlet paper-card {
max-width: 600px;
min-width: 200px;
}
.hamlet paper-card {
max-width: 600px;
min-width: 200px;
}
.hamlet paper-card.claudius {
.hamlet paper-card.claudius {
background: rgb(220,248,198);
}
}
.hamlet paper-card h5 {margin-top: 0.25em}
.hamlet paper-card h5 {
margin-top: 0.25em;
color: black;
}
.hamlet paper-card[elevation="0"] {
.hamlet paper-card[elevation="0"] {
background: rgb(254,244,197);
border-radius: 8px;
min-width: 30%;
height: 42px;
}
.hamlet paper-card[elevation="0"] .card-content {
padding: 8px;
text-align: center;
}
menu-item vcf-toggle-button {
padding-bottom: 2px;
}
</style>
</head>
<body>
<fc-applayout>
<div slot="profile" style="text-align: center;">
<img src="./avatar.png" alt="avatar" style="width: 80px; margin-top: 20px;">
<h4 slot="profile">User</h4>
</div>
<img slot="title" class="applogo" src="./applogo.png" alt="applogo">
<div slot="title" main-title="">AppLayout Vaadin 14 Demo</div>
<paper-icon-button disabled slot="toolbar" icon="block" role="button" tabindex="0" aria-disabled="false"></paper-icon-button>
<paper-icon-button slot="toolbar" icon="settings" title="Settings" role="button" tabindex="0" aria-disabled="false"></paper-icon-button>
<div slot="menu">
<p onclick="this.dispatchEvent(new CustomEvent('item-clicked', {bubbles: true}))">This is menu</p>
</div>
<div>
border-radius: 8px;
min-width: 30%;
height: 42px;
}
.hamlet {
user-select: none;
color: var(--lumo-body-text-color);
}
.hamlet paper-card {
max-width: 600px;
min-width: 200px;
}
.hamlet paper-card.claudius {
background: rgb(220,248,198);
}
.hamlet paper-card h5 {
margin-top: 0.25em;
color: black;
}
.hamlet paper-card[elevation="0"] {
background: rgb(254,244,197);
border-radius: 8px;
min-width: 30%;
height: 42px;
}
🤖 Prompt for AI Agents
In dev/index.html around lines 64–88, several styles use hard-coded colors
(.hamlet { color: black }, .hamlet paper-card.claudius { background:
rgb(220,248,198) }, .hamlet paper-card[elevation="0"] { background:
rgb(254,244,197) }) which won’t adapt to dark mode; update these rules to use
Lumo theme variables (e.g. var(--lumo-body-text-color), var(--lumo-base-color),
or appropriate contrast/background variables) or scope them to light mode only
by wrapping them in a :host-context([theme~="light"]) selector so text and card
backgrounds switch correctly with the theme toggle. Ensure all hard-coded
RGB/hex values are replaced with the corresponding Lumo CSS variables or moved
into a light-mode-only block.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The color: black on .hamlet is intentional. As noted, the cards within this section use fixed light background colors (rgb(220,248,198) and rgb(254,244,197)) that are not theme-aware. Replacing this with var(--lumo-body-text-color) would produce near-white text on those light backgrounds in dark mode, breaking contrast. Since the card backgrounds are fixed, the text color must be fixed too to guarantee readability.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@paodb, that's a fair and well-reasoned point. Since .hamlet paper-card.claudius and .hamlet paper-card[elevation="0"] use fixed light background colors that aren't theme-aware, pairing them with a fixed color: black is the correct approach to guarantee readable contrast regardless of the active theme. Using var(--lumo-body-text-color) would indeed risk near-invisible text on those light surfaces in dark mode. I'll withdraw the suggestion.

(◕‿◕✿)


✏️ Learnings added
Learnt from: paodb
Repo: FlowingCode/fc-applayout PR: 29
File: dev/index.html:64-88
Timestamp: 2026-04-28T17:39:07.395Z
Learning: In `dev/index.html`, the `.hamlet` CSS rule uses intentional hard-coded `color: black` because the card backgrounds within that section (`rgb(220,248,198)` for `.claudius` and `rgb(254,244,197)` for `[elevation="0"]`) are fixed light colors not tied to any Lumo/theme variable. Fixing the text color to black ensures readable contrast even in dark mode where `var(--lumo-body-text-color)` would produce near-white text on those light backgrounds.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Comment thread package.json Outdated
@paodb
Copy link
Copy Markdown
Member

paodb commented Mar 5, 2026

There are a few comments from Code Rabbit and Sonar that still need to be addressed.

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
B Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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.

Allow dark mode support

2 participants