Skip to content

Conversation

@paodb
Copy link
Member

@paodb paodb commented Jan 15, 2026

Update needed to make the component compatible with Vaadin 24 & Vaadin 25.

Close #27

Summary by CodeRabbit

  • New Features

    • Enhanced badge component styling with support for semantic variants (success, error, warning, contrast, primary).
    • Added pill-style badge variant and RTL language support.
  • Chores

    • Updated Vaadin dependency to 25.0.2.
    • Bumped project version to 1.2.0-SNAPSHOT.
  • Tests

    • Added demo examples showcasing styled badge variants.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 15, 2026

Walkthrough

This PR resolves a Vaadin 25 build error by replacing Vaadin's global badge module reference with a local TypeScript module and inline CSS. The project version is bumped to 1.2.0-SNAPSHOT, Vaadin dependency is updated to 25.0.2, and test assets are restructured to support version-specific styling configurations.

Changes

Cohort / File(s) Summary
Build Configuration
pom.xml
Version bumped to 1.2.0-SNAPSHOT; Vaadin updated from 25.0.0-beta2 to 25.0.2; new optional vaadin-dev dependency added to v25 profile; test-jar excludes extended to include AppShellConfiguratorImpl.class.
Badge Component Implementation
src/main/java/com/flowingcode/.../BadgeList.java, src/main/resources/META-INF/resources/frontend/src/fc-badge-list.ts, src/main/resources/META-INF/resources/frontend/styles/badge.css
JsModule annotation changed from @vaadin/vaadin-lumo-styles/badge-global.js to local ./src/fc-badge-list.ts; new CssImport annotation added; TS module refactored to load badge styles via inline CSS import; new comprehensive badge CSS stylesheet introduced with Lumo theming, semantic variants, RTL support, and pill styling.
Test Infrastructure
src/test/java/com/flowingcode/.../AppShellConfiguratorImpl.java, src/test/java/com/flowingcode/.../StyledBadgesDemo.java
New marker AppShellConfigurator implementation added; StyledBadgesDemo enriched with version-conditional CssImport and DemoSource annotations; preprocessor directives activated to enable Vaadin-version-specific styling paths and demo content blocks.
Test Styling Assets
src/test/resources/META-INF/frontend/styles/fc-badge-list.css, src/test/resources/META-INF/frontend/styles/styled-badges-demo-v25.css
New CSS files added for test styling; fc-badge-list.css defines custom-styled-badge class with lightgreen/green color scheme; styled-badges-demo-v25.css targets overflow-badge and custom-styled-badge selectors with matching color configuration.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • BadgeList#24: Modifies the same fc-badge-list.ts frontend module for update method and label rendering logic.
  • BadgeList#29: Updates the same StyledBadgesDemo.java class with additional CssImport and DemoSource annotations and related demo styling.

Suggested reviewers

  • mlopezFC
  • javier-godoy
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: replacing badge styles import from Vaadin's global badge JS module to a local badge.css file directly.
Linked Issues check ✅ Passed All changes address issue #27: removing the problematic @vaadin/vaadin-lumo-styles/badge-global.js import, replacing it with local module fc-badge-list.ts and badge.css, ensuring Vaadin 24/25 compatibility, and updating dependencies.
Out of Scope Changes check ✅ Passed All changes align with resolving the Vaadin 25 build issue and ensuring compatibility. Version bump to 1.2.0-SNAPSHOT, AppShellConfiguratorImpl addition, and CSS styling files all support the primary objective of fixing the import resolution problem.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

Actionable comments posted: 1

Caution

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

⚠️ Outside diff range comments (2)
src/main/resources/META-INF/resources/frontend/src/fc-badge-list.ts (1)

118-122: Potential null reference in disconnectedCallback.

The code accesses this.__parent before calling super.disconnectedCallback(), but then attempts to set parent.resizables = null after the super call. If __parent is undefined or null (e.g., if the element was never fully connected), this could throw an error.

Suggested defensive fix
 disconnectedCallback() {
   let parent = this.__parent;
   super.disconnectedCallback();
-  parent.resizables = null;
+  if (parent) {
+    parent.resizables = null;
+  }
 }
src/test/java/com/flowingcode/vaadin/addons/badgelist/StyledBadgesDemo.java (1)

114-120: Missing closing parenthesis in CSS var() function.

The padding value is missing the closing parenthesis for the CSS var() function, which will result in invalid CSS and the padding style not being applied.

🐛 Proposed fix
   private Icon createIcon(VaadinIcon vaadinIcon) {
     Icon icon = vaadinIcon.create();
-    icon.getStyle().set("padding", "var(--lumo-space-xs");
+    icon.getStyle().set("padding", "var(--lumo-space-xs)");
     return icon;
   }
🤖 Fix all issues with AI agents
In `@src/main/resources/META-INF/resources/frontend/src/fc-badge-list.ts`:
- Line 23: The imported CSS string badgeStylesContent is currently used raw in
the component's static styles; wrap it with Lit's unsafeCSS by importing
unsafeCSS from 'lit' and replacing the raw entry in the static styles array with
unsafeCSS(badgeStylesContent), keeping any other css`...` entries intact so
static styles contains CSSResult/Sheet objects only.
🧹 Nitpick comments (3)
src/test/java/com/flowingcode/vaadin/addons/AppShellConfiguratorImpl.java (1)

25-28: Consider adding serialVersionUID for the Serializable interface.

AppShellConfigurator extends Serializable, so this class should ideally declare a serialVersionUID to avoid potential serialization issues. However, since this is a test-only marker class, this is a minor concern.

Suggested fix
 `@Theme`
 public class AppShellConfiguratorImpl implements AppShellConfigurator {
-
+  private static final long serialVersionUID = 1L;
 }
src/test/resources/META-INF/frontend/styles/fc-badge-list.css (1)

1-8: Missing license header.

This file is missing the Apache 2.0 license header that is present in the other CSS files added in this PR (e.g., styled-badges-demo-v25.css). For consistency and compliance, consider adding the standard license header.

Also note that the .custom-styled-badge rule is duplicated in styled-badges-demo-v25.css. If both files are used together, verify this duplication is intentional and doesn't cause specificity conflicts.

src/main/resources/META-INF/resources/frontend/styles/badge.css (1)

177-187: RTL selectors use descendant selector inconsistently with LTR counterparts.

Lines 118-124 use the direct child combinator (>) for icon margin adjustments, but the RTL selectors here use a descendant selector (space). This inconsistency could cause the RTL styles to apply to nested icons unintentionally.

♻️ Suggested fix for consistency
 /* RTL specific styles */

-[dir='rtl'][theme~='badge'] vaadin-icon:first-child {
+[dir='rtl'][theme~='badge']>vaadin-icon:first-child {
   margin-right: -0.375em;
   margin-left: 0;
 }

-[dir='rtl'][theme~='badge'] vaadin-icon:last-child {
+[dir='rtl'][theme~='badge']>vaadin-icon:last-child {
   margin-left: -0.375em;
   margin-right: 0;
 }
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 93f640e and 80baf4f.

📒 Files selected for processing (8)
  • pom.xml
  • src/main/java/com/flowingcode/vaadin/addons/badgelist/BadgeList.java
  • src/main/resources/META-INF/resources/frontend/src/fc-badge-list.ts
  • src/main/resources/META-INF/resources/frontend/styles/badge.css
  • src/test/java/com/flowingcode/vaadin/addons/AppShellConfiguratorImpl.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/StyledBadgesDemo.java
  • src/test/resources/META-INF/frontend/styles/fc-badge-list.css
  • src/test/resources/META-INF/frontend/styles/styled-badges-demo-v25.css
🧰 Additional context used
🧬 Code graph analysis (1)
src/test/java/com/flowingcode/vaadin/addons/badgelist/StyledBadgesDemo.java (6)
src/test/java/com/flowingcode/vaadin/addons/badgelist/BadgeListDemo.java (1)
  • DemoSource (29-64)
src/test/java/com/flowingcode/vaadin/addons/badgelist/ReadOnlyBinderDemo.java (1)
  • DemoSource (41-116)
src/main/java/com/flowingcode/vaadin/addons/badgelist/BadgeList.java (1)
  • SuppressWarnings (37-94)
src/test/java/com/flowingcode/vaadin/addons/badgelist/BadgeListDemoView.java (1)
  • SuppressWarnings (30-44)
src/test/java/com/flowingcode/vaadin/addons/badgelist/BaseBadgeListDemo.java (1)
  • SuppressWarnings (30-55)
src/test/java/com/flowingcode/vaadin/addons/badgelist/DemoView.java (1)
  • SuppressWarnings (27-35)
🔇 Additional comments (8)
pom.xml (3)

7-7: LGTM!

Version bump to 1.2.0-SNAPSHOT is appropriate given the breaking change in styling approach for Vaadin 24/25 compatibility.


473-473: LGTM!

The exclusion of AppShellConfiguratorImpl.class from the demo-jar is correct since this is a test-only configuration class that shouldn't be shipped with the demo artifact.


502-511: The vaadin-dev dependency is correctly marked as optional.

Vaadin's vaadin-dev is a development-mode-only dependency that provides the frontend dev server, live reloading, and frontend toolchain (Vite/Node/npm/pnpm). It is not required for runtime functionality and should be excluded from production builds. Marking it as <optional>true</optional> is the correct approach for Vaadin 25, ensuring it's available during development but omitted from production artifacts.

src/test/resources/META-INF/frontend/styles/styled-badges-demo-v25.css (1)

21-28: LGTM!

The CSS rules correctly target the badge list component's shadow parts and custom badge class. The styling is consistent with the demo requirements for Vaadin 25.

src/main/resources/META-INF/resources/frontend/styles/badge.css (2)

1-25: License headers look good.

The dual license header structure correctly attributes both Flowing Code and Vaadin for the derived styling work.


26-175: Base badge styling and variants are well-structured.

The CSS correctly implements Lumo-themed badge styling with proper use of CSS custom properties. The selectors appropriately use attribute matching for theme variants.

src/main/java/com/flowingcode/vaadin/addons/badgelist/BadgeList.java (1)

27-27: Good approach to resolve Vaadin 25 compatibility.

Replacing the global Vaadin badge module reference with local TypeScript and CSS resources is the correct solution for the Vite/Rollup resolution issue reported in #27. The @CssImport annotation properly includes the new badge.css stylesheet.

Also applies to: 38-39

src/test/java/com/flowingcode/vaadin/addons/badgelist/StyledBadgesDemo.java (1)

34-50: Conditional compilation structure for Vaadin version support looks correct.

The DemoSource annotations and CssImport annotations are properly structured for conditional inclusion based on Vaadin version, supporting both v24 and v25 styling paths.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@javier-godoy javier-godoy merged commit 22ec8e4 into master Jan 15, 2026
4 checks passed
@github-project-automation github-project-automation bot moved this from To Do to Pending release in Flowing Code Addons Jan 15, 2026
@javier-godoy javier-godoy deleted the vaadin-24-25-support branch January 15, 2026 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Pending release

Development

Successfully merging this pull request may close these issues.

Vaadin 25: error during build (failed to resolve import @vaadin/vaadin-lumo-styles/badge-global.js)

3 participants