Skip to content

feat: derive CSS classname from demo route#146

Open
javier-godoy wants to merge 3 commits intomasterfrom
classnames
Open

feat: derive CSS classname from demo route#146
javier-godoy wants to merge 3 commits intomasterfrom
classnames

Conversation

@javier-godoy
Copy link
Member

@javier-godoy javier-godoy commented Feb 28, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Routed demo components now automatically generate CSS class names derived from their route paths for improved styling capabilities.
  • Bug Fixes

    • Added validation to prevent legacy theme configuration; an error will be raised if detected during initialization.

@coderabbitai
Copy link

coderabbitai bot commented Feb 28, 2026

Walkthrough

Updates POM version to 5.3.0-SNAPSHOT, introduces legacy @Theme annotation detection in DynamicTheme that throws IllegalStateException during initialization, and adds runtime-derived CSS class names to routed demo components based on their Route annotation values.

Changes

Cohort / File(s) Summary
Build Configuration
pom.xml
Version bump from 5.2.1-SNAPSHOT to 5.3.0-SNAPSHOT.
Core Demo Components
src/main/java/com/flowingcode/vaadin/addons/demo/DynamicTheme.java, src/main/java/com/flowingcode/vaadin/addons/demo/TabbedDemo.java
DynamicTheme adds private assertNotLegacyTheme() helper to detect and forbid legacy @Theme annotations during initialization paths; TabbedDemo adds runtime-derived CSS class naming logic based on Route annotation values, building class names from cumulative path segments.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • mlopezFC
  • paodb
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: derive CSS classname from demo route' directly reflects the main change in TabbedDemo.java, which adds runtime CSS class names derived from Route annotations.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch classnames

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 link

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/com/flowingcode/vaadin/addons/demo/DynamicTheme.java (1)

138-149: ⚠️ Potential issue | 🟡 Minor

Document the new IllegalStateException in this overload too.

initialize(IndexHtmlResponse) now calls assertNotLegacyTheme() (Line 152), so its Javadoc should include the same throws contract as the AppShellSettings overload.

Javadoc consistency patch
   /**
    * Initializes the theme settings into the provided {`@code` IndexHtmlResponse}.
@@
    * `@param` response the index HTML response to be modified
    * `@throws` UnsupportedOperationException if the runtime Vaadin version is older than 25
+   * `@throws` IllegalStateException if the {`@link` AppShellConfigurator} is configured with the legacy
+   *         {`@link` Theme} annotation
    */
   public void initialize(IndexHtmlResponse response) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/com/flowingcode/vaadin/addons/demo/DynamicTheme.java` around
lines 138 - 149, The Javadoc for initialize(IndexHtmlResponse) is missing the
new throws clause for IllegalStateException introduced by the call to
assertNotLegacyTheme(); update the Javadoc on initialize(IndexHtmlResponse) to
include an `@throws` IllegalStateException documenting that assertNotLegacyTheme()
will throw when a legacy theme is detected (matching the AppShellSettings
overload), in addition to the existing `@throws` UnsupportedOperationException
note.
🧹 Nitpick comments (1)
src/main/java/com/flowingcode/vaadin/addons/demo/TabbedDemo.java (1)

203-212: Consider sanitizing route segments before using them as CSS class names, if special characters may appear in future routes.

The current approach uses @Route path segments directly. While this works for the existing routes in the codebase (which contain only alphanumerics, slashes, and hyphens), hardening against special characters would be prudent defensive coding if dynamic or user-provided routes are ever introduced.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/com/flowingcode/vaadin/addons/demo/TabbedDemo.java` around
lines 203 - 212, The route segments used to build CSS class names (in TabbedDemo
where demo.getClass().getAnnotation(Route.class) is mapped and each segment
appended to prefix and passed to demo.addClassName) should be sanitized first to
remove or replace unsafe characters; before appending each segment, normalize it
(e.g., toLowerCase()) and replace any characters not allowed in CSS class names
(use a regex like [^a-z0-9_-] to replace with '-' or remove) and skip empty
results so demo.addClassName only receives safe class-name tokens.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/main/java/com/flowingcode/vaadin/addons/demo/DynamicTheme.java`:
- Around line 138-149: The Javadoc for initialize(IndexHtmlResponse) is missing
the new throws clause for IllegalStateException introduced by the call to
assertNotLegacyTheme(); update the Javadoc on initialize(IndexHtmlResponse) to
include an `@throws` IllegalStateException documenting that assertNotLegacyTheme()
will throw when a legacy theme is detected (matching the AppShellSettings
overload), in addition to the existing `@throws` UnsupportedOperationException
note.

---

Nitpick comments:
In `@src/main/java/com/flowingcode/vaadin/addons/demo/TabbedDemo.java`:
- Around line 203-212: The route segments used to build CSS class names (in
TabbedDemo where demo.getClass().getAnnotation(Route.class) is mapped and each
segment appended to prefix and passed to demo.addClassName) should be sanitized
first to remove or replace unsafe characters; before appending each segment,
normalize it (e.g., toLowerCase()) and replace any characters not allowed in CSS
class names (use a regex like [^a-z0-9_-] to replace with '-' or remove) and
skip empty results so demo.addClassName only receives safe class-name tokens.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f9d1755 and 829f0e7.

📒 Files selected for processing (3)
  • pom.xml
  • src/main/java/com/flowingcode/vaadin/addons/demo/DynamicTheme.java
  • src/main/java/com/flowingcode/vaadin/addons/demo/TabbedDemo.java

@javier-godoy javier-godoy marked this pull request as ready for review February 28, 2026 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To Do

Development

Successfully merging this pull request may close these issues.

1 participant