Skip to content

Migrate to native Vaadin Badge component#40

Open
paodb wants to merge 17 commits intomasterfrom
25.1
Open

Migrate to native Vaadin Badge component#40
paodb wants to merge 17 commits intomasterfrom
25.1

Conversation

@paodb
Copy link
Copy Markdown
Member

@paodb paodb commented Apr 1, 2026

Summary

  • Updated component version to 2.0.0-SNAPSHOT
  • Upgraded to Vaadin 25.1.1 and Java 21
  • Removed the custom Badge class and CSS in favor of Vaadin's native com.vaadin.flow.component.badge.Badge
  • Updated the fc-badge-list web component to use vaadin-badge
  • Added ThemeDetectionMixin to now which theme is being used
  • Fixed Aura theme styling for the overflow badge (shadow DOM boundary workaround)
  • Fixed Aura theme styling for hidden badges rendered inside the context menu
  • Updated all demos to use the native Vaadin Badge API
  • Added dynamic theme switching support in the demo
  • Updated license headers

Closes #34

Summary by CodeRabbit

  • New Features

    • Improved theme detection with Aura-specific styling and updated overflow badge visuals
    • Experimental badge component enabled via feature flag
  • Refactor

    • Migrated from a custom badge implementation to Vaadin's native badge component
    • Removed legacy badge styling and related APIs; updated baseline to Vaadin 25.1+ and Java 21; project version bumped to 2.x
  • Chores

    • Consolidated build settings and removed a version-specific build profile
    • README updated (supported versions and demo link)

paodb added 5 commits April 1, 2026 16:36
Drop the v25 profile and promote its settings to the base build. Replace javax.servlet-api with jakarta.servlet-api 6.1.0 and add vaadin-dev dependency required for development mode in Vaadin 25.
Replace the removed custom Badge class with the native Vaadin Badge. Remove the @CssImport for badge.css since vaadin-badge manages its own styles via shadow DOM.
Badge styles are now managed by vaadin-badge's own shadow DOM.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 1, 2026

Warning

Rate limit exceeded

@paodb has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 54 minutes and 5 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 54 minutes and 5 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bf386e13-18c7-4436-8fa7-2650f5073d6e

📥 Commits

Reviewing files that changed from the base of the PR and between fa77a90 and 8038711.

📒 Files selected for processing (19)
  • README.md
  • 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/test/java/com/flowingcode/vaadin/addons/AppShellConfiguratorImpl.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/BadgeListDemo.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/BadgeListDemoView.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/BaseBadgeListDemo.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/DemoView.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/Person.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/ReadOnlyBinderDemo.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/StyledBadgesDemo.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/TestData.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/it/AbstractViewTest.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/it/ViewIT.java
  • src/test/resources/META-INF/frontend/styles/badge-list-demo-styles.css
  • src/test/resources/META-INF/frontend/styles/fc-badge-list.css
  • src/test/resources/META-INF/frontend/styles/styled-badges-demo-v25.css
  • src/test/resources/META-INF/frontend/styles/styled-badges-demo.css

Walkthrough

Replaces the add-on's custom Badge implementation with Vaadin's native Badge (requires Vaadin 25.1+), removes the custom Badge class and CSS, updates the frontend component to use ThemeDetectionMixin and vaadin-badge, enables the experimental badge feature flag, bumps project to 2.0.0-SNAPSHOT and Java target to 21, and updates demos and test resources accordingly.

Changes

Cohort / File(s) Summary
Version & Build Configuration
README.md, pom.xml
Bumped artifact to 2.0.0-SNAPSHOT; Vaadin upgraded to 25.1.1; Java compiler source/target moved 17→21; flowingcode.commons.demo.version bumped; added optional com.vaadin:vaadin-dev; switched test servlet API to jakarta.servlet-api:6.1.0; removed v25 Maven profile; updated demo URL in README.
Custom Badge Component Removal
src/main/java/com/flowingcode/vaadin/addons/badgelist/Badge.java
Deleted the custom Badge class (constructors and theme-management methods removed).
BadgeList Core Migration
src/main/java/.../badgelist/BadgeList.java, src/main/resources/.../frontend/src/fc-badge-list.ts
BadgeList now imports/uses com.vaadin.flow.component.badge.Badge; frontend TS uses ThemeDetectionMixin, reads data-application-theme, renders overflow with vaadin-badge, chooses plus icon per theme, and copies Aura-specific computed styles for overflow clones.
Custom Styling Removal
src/main/resources/.../frontend/styles/badge.css
Removed the entire custom badge CSS theme (all badge styling selectors and rules deleted).
Feature Flag & AppShell
src/main/resources/vaadin-featureflags.properties, src/test/java/.../AppShellConfiguratorImpl.java
Enabled com.vaadin.experimental.badgeComponent feature flag; replaced @Theme usage with configurePage(AppShellSettings) override to initialize DynamicTheme conditionally.
Demo & Test Code Updates
src/test/java/.../badgelist/* (BadgeListDemo, StyledBadgesDemo, ReadOnlyBinderDemo, etc.)
Demos/tests updated to import/use com.vaadin.flow.component.badge.Badge; swapped theme-name string usage to BadgeVariant and setIcon(...); removed Vaadin-version conditional CSS imports; updated header years.
Test Resources & Styles
src/test/resources/.../styles/*
Deleted styled-badges-demo-v25.css; added license header to fc-badge-list.css; narrowed .custom-styled-badge selector to fc-badge-list .custom-styled-badge; added font-size fallback in demo styles; minor formatting changes.
Copyright & Metadata Only
various src/test/java/*, README.md
Updated copyright years from 2023–2024 to 2023–2026 and README supported-versions entry.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • javier-godoy
  • mlopezFC
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% 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 primary change—migrating from a custom Badge implementation to Vaadin's native Badge component.
Linked Issues check ✅ Passed The PR addresses issue #34 by replacing the custom Badge class with Vaadin 25.1's native Badge component, updating web components, CSS, and demos accordingly.
Out of Scope Changes check ✅ Passed All changes are directly related to the Badge migration objective. Version bumps, Java upgrade to 21, and copyright updates are necessary supporting changes.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 25.1

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.

@paodb paodb requested review from javier-godoy and mlopezFC April 6, 2026 11:37
@paodb paodb marked this pull request as ready for review April 6, 2026 11:38
@paodb paodb requested a review from scardanzan April 6, 2026 14:16
@javier-godoy
Copy link
Copy Markdown
Member

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

Copy link
Copy Markdown
Member

@javier-godoy javier-godoy left a comment

Choose a reason for hiding this comment

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

Three issues in fc-badge-list.ts worth addressing before merge.

@github-project-automation github-project-automation bot moved this from To Do to In Progress in Flowing Code Addons Apr 9, 2026
@paodb paodb requested a review from javier-godoy April 10, 2026 19:58
Copy link
Copy Markdown
Member

@javier-godoy javier-godoy left a comment

Choose a reason for hiding this comment

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

LGTM. Please squash WIP commits

@sonarqubecloud
Copy link
Copy Markdown

@paodb
Copy link
Copy Markdown
Member Author

paodb commented Apr 14, 2026

LGTM. Please squash WIP commits

Done @javier-godoy

@paodb paodb requested a review from javier-godoy April 14, 2026 20:36
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: 1

🧹 Nitpick comments (1)
src/main/resources/META-INF/resources/frontend/src/fc-badge-list.ts (1)

31-35: Align _overflowBadge type with the rendered <vaadin-badge> element.

_overflowBadge is typed as HTMLDivElement but now references a <vaadin-badge> custom element. Change to HTMLElement for correct type checking.

♻️ Proposed fix
-  _overflowBadge!: HTMLDivElement
+  _overflowBadge!: HTMLElement

Also applies to: 283-287

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

In `@src/main/resources/META-INF/resources/frontend/src/fc-badge-list.ts` around
lines 31 - 35, The _overflowBadge property in the BadgeList class is incorrectly
typed as HTMLDivElement while the template renders a <vaadin-badge> custom
element; update the declaration of _overflowBadge to use a more appropriate type
(HTMLElement) and adjust any other similar declarations in this file (e.g., the
other _overflowBadge declaration later in the file) so type checking matches the
rendered vaadin-badge element; locate the property by name (_overflowBadge)
within the BadgeList class and change its type annotation from HTMLDivElement to
HTMLElement.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/test/resources/META-INF/frontend/styles/fc-badge-list.css`:
- Line 1: The CSS header uses a nonstandard opener "/*-" which triggers
Stylelint's comment-whitespace-inside rule; replace the opener with a standard
CSS block comment opener "/*" at the start of the header in
src/test/resources/META-INF/frontend/styles/fc-badge-list.css so the comment
conforms to Stylelint rules and no other comment content needs changing.

---

Nitpick comments:
In `@src/main/resources/META-INF/resources/frontend/src/fc-badge-list.ts`:
- Around line 31-35: The _overflowBadge property in the BadgeList class is
incorrectly typed as HTMLDivElement while the template renders a <vaadin-badge>
custom element; update the declaration of _overflowBadge to use a more
appropriate type (HTMLElement) and adjust any other similar declarations in this
file (e.g., the other _overflowBadge declaration later in the file) so type
checking matches the rendered vaadin-badge element; locate the property by name
(_overflowBadge) within the BadgeList class and change its type annotation from
HTMLDivElement to HTMLElement.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 662883c8-f375-4721-8bca-afd3ff3ed33a

📥 Commits

Reviewing files that changed from the base of the PR and between dbc3ce8 and fa77a90.

📒 Files selected for processing (13)
  • README.md
  • src/main/java/com/flowingcode/vaadin/addons/badgelist/BadgeList.java
  • src/main/resources/META-INF/resources/frontend/src/fc-badge-list.ts
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/BadgeListDemo.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/BadgeListDemoView.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/BaseBadgeListDemo.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/DemoView.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/Person.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/ReadOnlyBinderDemo.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/TestData.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/it/AbstractViewTest.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/it/ViewIT.java
  • src/test/resources/META-INF/frontend/styles/fc-badge-list.css
✅ Files skipped from review due to trivial changes (10)
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/BaseBadgeListDemo.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/DemoView.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/BadgeListDemo.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/it/ViewIT.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/Person.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/it/AbstractViewTest.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/ReadOnlyBinderDemo.java
  • README.md
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/TestData.java
  • src/test/java/com/flowingcode/vaadin/addons/badgelist/BadgeListDemoView.java

@@ -1,4 +1,23 @@
/* FOR VAADIN 25 */
/*-
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix header comment opener to satisfy Stylelint.

/*- triggers comment-whitespace-inside; use a standard CSS block comment opener.

🧹 Proposed fix
-/*-
+/*
📝 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
/*-
/*
🧰 Tools
🪛 Stylelint (17.7.0)

[error] 1-1: Expected whitespace after "/*" (comment-whitespace-inside)

(comment-whitespace-inside)

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

In `@src/test/resources/META-INF/frontend/styles/fc-badge-list.css` at line 1, The
CSS header uses a nonstandard opener "/*-" which triggers Stylelint's
comment-whitespace-inside rule; replace the opener with a standard CSS block
comment opener "/*" at the start of the header in
src/test/resources/META-INF/frontend/styles/fc-badge-list.css so the comment
conforms to Stylelint rules and no other comment content needs changing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Vaadin 25.1 introduces Badge component

2 participants