Conversation
Rename and move all classes from the template package to com.flowingcode.vaadin.addons.fctogglebutton: - SerializationTest now tests FCToggleButton - TemplateDemo → FCToggleButtonDemo (updated title and route) - TemplateDemoView → FCToggleButtonDemoView (route, GitHub link) - DemoView forwards to FCToggleButtonDemoView - AbstractViewTest and ViewIT moved to fctogglebutton.it package - ViewIT now queries fc-toggle-button instead of paper-input
Replace all template references with FC Toggle Button content: badges, description, features list, demo URL, getting started examples, and release notes link.
Add FCToggleButtonVariant.CONTRAST, applying --lumo-contrast-color to the switch track when checked, consistent with Vaadin Button's contrast variant behavior.
Add FCToggleButtonVariant.MEDIUM as an explicit variant matching the default size, allowing it to be set programmatically alongside other theme variants.
Replace TEMPLATE_ADDON placeholder with FC Toggle Button Add-On in bug-report.yml and feature-request.yml descriptions.
Split demo content into three focused tabs: - FCToggleButtonDemo: labels and icons combinations - FCToggleButtonVariantsDemo: all color, size, and state variants - FCToggleButtonEventsDemo: value change, aria-label, and tooltip
Add width transition to slider so the squeeze animation is smooth. Add explicit active-state rules for medium, small, and large variants to override specificity from their resting-state rules, ensuring the expansion is symmetric (left-only when checked, right-only when unchecked) for all sizes.
Label color change based on toggle state was always active. Add highlightLabel property (default false) to the web component and expose withHighlightLabel()/withoutHighlightLabel() fluent methods on FCToggleButton to control the behavior explicitly.
Add a "With label highlighting" section to FCToggleButtonDemo with two examples using withHighlightLabel(): one with labels only and one combining labels and icons.
|
src/test/java/com/flowingcode/vaadin/addons/AppShellConfiguratorImpl.java
Outdated
Show resolved
Hide resolved
src/test/java/com/flowingcode/vaadin/addons/AppShellConfiguratorImpl.java
Outdated
Show resolved
Hide resolved
src/main/java/com/flowingcode/vaadin/addons/togglebutton/ToggleButton.java
Outdated
Show resolved
Hide resolved
src/main/java/com/flowingcode/vaadin/addons/togglebutton/ToggleButton.java
Outdated
Show resolved
Hide resolved
src/test/java/com/flowingcode/vaadin/addons/togglebutton/it/ToggleButtonIT.java
Outdated
Show resolved
Hide resolved
src/test/java/com/flowingcode/vaadin/addons/togglebutton/it/ToggleButtonVariantsIT.java
Outdated
Show resolved
Hide resolved
src/test/java/com/flowingcode/vaadin/addons/togglebutton/it/ViewIT.java
Outdated
Show resolved
Hide resolved
src/main/resources/META-INF/resources/frontend/fc-toggle-button.js
Outdated
Show resolved
Hide resolved
javier-godoy
left a comment
There was a problem hiding this comment.
In the v25 profile, please add the jakarta.servlet-api dependency (as done in AddonStarter24). Vaadin 25 uses Jakarta Servlet, so the javax.servlet:javax.servlet-api declared in the main dependencies won't be compatible when building with -Pv25.
<profile>
<id>v25</id>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-dev</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>| } | ||
|
|
||
| @Override | ||
| public Tooltip setTooltipText(String text) { |
There was a problem hiding this comment.
setTooltipText creates a new Tooltip on every call. Tooltip.forComponent(this) allocates a fresh tooltip each time, which deviates from the standard HasTooltip contract. Either delegate to getTooltip().setText(text) and return getTooltip(), or remove this override and rely on the default HasTooltip implementation.
| const maxTranslate = switchEl ? switchEl.offsetWidth - sliderWidth - gap * 2 : 20; | ||
| const threshold = maxTranslate * 0.5; | ||
|
|
||
| const newChecked = dx > 0 ? true : false; |
There was a problem hiding this comment.
Unnecessary ternary. dx > 0 ? true : false is equivalent to dx > 0. Please simplify.
|
|
||
| /* Readonly Styles: Unify the look for both checked/unchecked and variants */ | ||
| :host([readonly]) .switch { | ||
| background-color: var(--lumo-contrast-10pct, var(--vaadin-background-container)) !important; |
There was a problem hiding this comment.
!important in Shadow DOM readonly styles. Since these rules live inside the shadow root, selector specificity is already scoped — !important is not needed and prevents consumers from overriding the readonly appearance via CSS custom properties or ::part. Please remove all !important declarations from this block.
|
Some comments about read-only styles:
|
Vaadin 25 uses Jakarta Servlet, so the javax.servlet:javax.servlet-api declared in the main dependencies won't be compatible when building with -Pv25.
|
|
| /* Readonly Styles: Unify the look for both checked/unchecked and variants */ | ||
| :host([readonly]) .switch { | ||
| background-color: transparent; | ||
| border: 2px dashed var(--lumo-contrast-30pct, var(--vaadin-border-color)); |

Summary
ToggleButtoncomponent extendingAbstractSinglePropertyField<ToggleButton, Boolean>,implementing
HasSize,HasComponents,HasLabel,HasAriaLabel,HasTooltip, andHasThemeVariant<ToggleButtonVariant>ToggleButtonVariantenum with color variants (PRIMARY,SUCCESS,WARNING,ERROR,CONTRAST), size variants (SMALL,MEDIUM,LARGE), and touch variant (LONGSWIPE)fc-toggle-buttonLitElement web component with shadow DOM, Lumo tokenintegration, and symmetric active-state animations for all size variants
LONGSWIPEvariant producing a wider switch track optimized for touch; combinable withsize variants (
LONGSWIPE+SMALL/MEDIUM/LARGE)past the 50% threshold snaps to the new state with a smooth CSS transition
setLeftLabel,setRightLabel,setLeftIcon,setRightIcon,setItemLabelGenerator,withHighlightLabel,withoutHighlightLabel,withIconsInside,withIconsOutsideof the
SUCCESS,WARNING,ERROR, orCONTRASTvariant instead of always defaulting toprimary
withIconsInside()swaps the default layout to[label] [icon] [switch] [icon] [label],placing icons adjacent to the switch and labels on the outer edges
templatepackage tocom.flowingcode.vaadin.addons.togglebuttonpom.xmlname and description per AddonsInternal guidelinesREADME.mdwith correct badges, links, features list, and Getting Started examplesTest plan
mvn clean install— build passesmvn clean install jetty:runand verify all three demo tabs render correctlywithHighlightLabel()highlights the active side labeldisabledandread-onlystates behave correctlymvn test