Skip to content

Commit 1d65a70

Browse files
ugur-vaadinweb-padawanjouni
authored
feat: add Aura variants (#8145)
* feat: add base variants * test: update tests to use base variants * feat: update base variants based on web component styles * fix: fix compilation errors and cleanup * fix: fix compilation * fix: fix compilation and remove duplicate tests * fix: update incorrect variants * feat: use both horizontal and vertical in group variants * feat: add primary variant and deprecate lumo version * refactor: remove icon base variant * refactor: add missing deprecation * feat: remove base variants and add aura variants * feat: add aura variants for grid and gridpro * refactor: revert changes and cleanup * fix: remove variants instead of adding * feat: add missing variants * refactor: add missing button variants to drawer toggle variants * refactor: remove drawer toggle variants * refactor: add theme specific variants for details * chore: revert newline change * test: remove unnecessary test * add missing layout spacing variants * refactor: add missing menu bar variants * refactor: remove redundant group orientation variants * Update vaadin-button-flow-parent/vaadin-button-flow/src/main/java/com/vaadin/flow/component/button/ButtonVariant.java Co-authored-by: Jouni Koivuviita <jouni@vaadin.com> --------- Co-authored-by: web-padawan <iamkulykov@gmail.com> Co-authored-by: Jouni Koivuviita <jouni@vaadin.com>
1 parent a8f37a0 commit 1d65a70

File tree

88 files changed

+1479
-356
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+1479
-356
lines changed

vaadin-avatar-flow-parent/vaadin-avatar-flow/src/main/java/com/vaadin/flow/component/avatar/AvatarVariant.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ public enum AvatarVariant implements ThemeVariant {
2424
LUMO_XLARGE("xlarge"),
2525
LUMO_LARGE("large"),
2626
LUMO_SMALL("small"),
27-
LUMO_XSMALL("xsmall");
27+
LUMO_XSMALL("xsmall"),
28+
LUMO_REVERSE("reverse"),
29+
AURA_REVERSE("reverse");
2830

2931
private final String variant;
3032

vaadin-avatar-flow-parent/vaadin-avatar-flow/src/test/java/com/vaadin/flow/component/avatar/tests/AvatarGroupTest.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,13 @@
1616
package com.vaadin.flow.component.avatar.tests;
1717

1818
import java.util.List;
19-
import java.util.Set;
2019

2120
import org.junit.Assert;
2221
import org.junit.Before;
2322
import org.junit.Test;
2423

2524
import com.vaadin.flow.component.avatar.AvatarGroup;
2625
import com.vaadin.flow.component.avatar.AvatarGroup.AvatarGroupItem;
27-
import com.vaadin.flow.component.avatar.AvatarGroupVariant;
28-
import com.vaadin.flow.component.avatar.AvatarVariant;
2926

3027
public class AvatarGroupTest {
3128

@@ -136,25 +133,6 @@ public void getMaxItemsVisible_returnsNull() {
136133
Assert.assertNull(avatarGroup.getMaxItemsVisible());
137134
}
138135

139-
@Test
140-
public void addThemeVariant_themeAttributeContainsThemeVariant() {
141-
avatarGroup.addThemeVariants(AvatarGroupVariant.LUMO_LARGE);
142-
143-
Set<String> themeNames = avatarGroup.getThemeNames();
144-
Assert.assertTrue(
145-
themeNames.contains(AvatarVariant.LUMO_LARGE.getVariantName()));
146-
}
147-
148-
@Test
149-
public void addThemeVariant_removeThemeVariant_doesNotContainThemeVariant() {
150-
avatarGroup.addThemeVariants(AvatarGroupVariant.LUMO_LARGE);
151-
avatarGroup.removeThemeVariants(AvatarGroupVariant.LUMO_LARGE);
152-
153-
Set<String> themeNames = avatarGroup.getThemeNames();
154-
Assert.assertFalse(
155-
themeNames.contains(AvatarVariant.LUMO_LARGE.getVariantName()));
156-
}
157-
158136
@Test
159137
public void setI18n() {
160138
AvatarGroup.AvatarGroupI18n i18n = new AvatarGroup.AvatarGroupI18n()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2000-2025 Vaadin Ltd.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
package com.vaadin.flow.component.avatar.tests;
17+
18+
import org.junit.Test;
19+
20+
import com.vaadin.flow.component.avatar.AvatarGroup;
21+
import com.vaadin.flow.component.avatar.AvatarGroupVariant;
22+
import com.vaadin.tests.ThemeVariantTestHelper;
23+
24+
public class AvatarGroupVariantTest {
25+
26+
@Test
27+
public void addThemeVariant_themeNamesContainsThemeVariant() {
28+
ThemeVariantTestHelper.addThemeVariant_themeNamesContainsThemeVariant(
29+
new AvatarGroup(), AvatarGroupVariant.LUMO_SMALL);
30+
}
31+
32+
@Test
33+
public void addThemeVariant_removeThemeVariant_themeNamesDoesNotContainThemeVariant() {
34+
ThemeVariantTestHelper
35+
.addThemeVariant_removeThemeVariant_themeNamesDoesNotContainThemeVariant(
36+
new AvatarGroup(), AvatarGroupVariant.LUMO_SMALL);
37+
}
38+
}

vaadin-avatar-flow-parent/vaadin-avatar-flow/src/test/java/com/vaadin/flow/component/avatar/tests/AvatarTest.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,11 @@
1515
*/
1616
package com.vaadin.flow.component.avatar.tests;
1717

18-
import java.util.Set;
19-
2018
import org.junit.Assert;
2119
import org.junit.Before;
2220
import org.junit.Test;
2321

2422
import com.vaadin.flow.component.avatar.Avatar;
25-
import com.vaadin.flow.component.avatar.AvatarVariant;
2623

2724
public class AvatarTest {
2825

@@ -73,25 +70,6 @@ public void constructAvatarWithNameAndImage() {
7370
Assert.assertEquals(avatar.getImage(), "https://vaadin.com/");
7471
}
7572

76-
@Test
77-
public void addThemeVariant_themeAttributeContainsThemeVariant() {
78-
avatar.addThemeVariants(AvatarVariant.LUMO_LARGE);
79-
80-
Set<String> themeNames = avatar.getThemeNames();
81-
Assert.assertTrue(
82-
themeNames.contains(AvatarVariant.LUMO_LARGE.getVariantName()));
83-
}
84-
85-
@Test
86-
public void addThemeVariant_removeThemeVariant_doesNotContainThemeVariant() {
87-
avatar.addThemeVariants(AvatarVariant.LUMO_LARGE);
88-
avatar.removeThemeVariants(AvatarVariant.LUMO_LARGE);
89-
90-
Set<String> themeNames = avatar.getThemeNames();
91-
Assert.assertFalse(
92-
themeNames.contains(AvatarVariant.LUMO_LARGE.getVariantName()));
93-
}
94-
9573
@Test
9674
public void setI18n() {
9775
Avatar.AvatarI18n i18n = new Avatar.AvatarI18n()
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2000-2025 Vaadin Ltd.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
package com.vaadin.flow.component.avatar.tests;
17+
18+
import org.junit.Test;
19+
20+
import com.vaadin.flow.component.avatar.Avatar;
21+
import com.vaadin.flow.component.avatar.AvatarVariant;
22+
import com.vaadin.tests.ThemeVariantTestHelper;
23+
24+
public class AvatarVariantTest {
25+
26+
@Test
27+
public void addThemeVariant_themeNamesContainsThemeVariant() {
28+
ThemeVariantTestHelper.addThemeVariant_themeNamesContainsThemeVariant(
29+
new Avatar(), AvatarVariant.LUMO_SMALL);
30+
}
31+
32+
@Test
33+
public void addThemeVariant_removeThemeVariant_themeNamesDoesNotContainThemeVariant() {
34+
ThemeVariantTestHelper
35+
.addThemeVariant_removeThemeVariant_themeNamesDoesNotContainThemeVariant(
36+
new Avatar(), AvatarVariant.LUMO_SMALL);
37+
}
38+
}

vaadin-button-flow-parent/vaadin-button-flow/src/main/java/com/vaadin/flow/component/button/ButtonVariant.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ public enum ButtonVariant implements ThemeVariant {
3030
LUMO_WARNING("warning"),
3131
LUMO_ERROR("error"),
3232
LUMO_CONTRAST("contrast"),
33-
LUMO_ICON("icon");
33+
LUMO_ICON("icon"),
34+
AURA_PRIMARY("primary"),
35+
AURA_TERTIARY("tertiary"),
36+
AURA_ACCENT("accent"),
37+
AURA_DANGER("danger");
3438

3539
private final String variant;
3640

vaadin-button-flow-parent/vaadin-button-flow/src/test/java/com/vaadin/flow/component/button/tests/ButtonTest.java

Lines changed: 0 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package com.vaadin.flow.component.button.tests;
1717

18-
import java.util.Set;
1918
import java.util.concurrent.atomic.AtomicBoolean;
2019

2120
import org.junit.Assert;
@@ -24,7 +23,6 @@
2423
import com.vaadin.flow.component.HasAriaLabel;
2524
import com.vaadin.flow.component.Text;
2625
import com.vaadin.flow.component.button.Button;
27-
import com.vaadin.flow.component.button.ButtonVariant;
2826
import com.vaadin.flow.component.icon.Icon;
2927
import com.vaadin.flow.component.icon.VaadinIcon;
3028
import com.vaadin.flow.component.shared.HasTooltip;
@@ -36,10 +34,6 @@ public class ButtonTest {
3634

3735
private static final String TEST_STRING = "lorem ipsum";
3836

39-
private static final String THEME_ATTRIBUTE = "theme";
40-
private static final String THEME_ATTRIBUTE_ICON = "icon";
41-
private static final String THEME_ATTRIBUTE_PRIMARY = "primary";
42-
4337
@Test
4438
public void emptyCtor() {
4539
button = new Button();
@@ -139,55 +133,6 @@ public void changeOrder_setIcon_setText_changeOrder() {
139133
assertIconBeforeText();
140134
}
141135

142-
@Test
143-
public void updatingThemeAttribute() {
144-
button = new Button();
145-
assertButtonHasNoThemeAttribute();
146-
147-
button.setIcon(new Icon());
148-
assertButtonHasThemeAttribute(THEME_ATTRIBUTE_ICON);
149-
150-
button.setText("foo");
151-
assertButtonHasNoThemeAttribute();
152-
153-
button.setIcon(null);
154-
assertButtonHasNoThemeAttribute();
155-
156-
button = new Button("foo", new Icon());
157-
assertButtonHasNoThemeAttribute();
158-
159-
button.setText("");
160-
assertButtonHasThemeAttribute(THEME_ATTRIBUTE_ICON);
161-
162-
button = new Button("foo", new Icon());
163-
button.setText(null);
164-
assertButtonHasThemeAttribute(THEME_ATTRIBUTE_ICON);
165-
166-
// should ignore tooltips when determining theme
167-
button = new Button();
168-
button.setTooltipText("foo");
169-
button.setIcon(new Icon());
170-
assertButtonHasThemeAttribute(THEME_ATTRIBUTE_ICON);
171-
172-
button = new Button(new Icon());
173-
button.setTooltipText("foo");
174-
assertButtonHasThemeAttribute(THEME_ATTRIBUTE_ICON);
175-
176-
// don't override explicitly set theme-attribute
177-
button = new Button();
178-
button.getElement().setAttribute(THEME_ATTRIBUTE,
179-
THEME_ATTRIBUTE_PRIMARY);
180-
assertButtonHasThemeAttribute(THEME_ATTRIBUTE_PRIMARY);
181-
button.setIcon(new Icon());
182-
assertButtonHasThemeAttribute(THEME_ATTRIBUTE_PRIMARY);
183-
button.setText("foo");
184-
assertButtonHasThemeAttribute(THEME_ATTRIBUTE_PRIMARY);
185-
button.setIcon(null);
186-
assertButtonHasThemeAttribute(THEME_ATTRIBUTE_PRIMARY);
187-
button.setText(null);
188-
assertButtonHasThemeAttribute(THEME_ATTRIBUTE_PRIMARY);
189-
}
190-
191136
@Test
192137
public void setEnabled() {
193138
button = new Button();
@@ -237,63 +182,6 @@ public void testFireClickDisabled() {
237182
Assert.assertFalse(clicked.get());
238183
}
239184

240-
@Test
241-
public void addThemeVariant_themeNamesContainsThemeVariant() {
242-
button = new Button();
243-
button.addThemeVariants(ButtonVariant.LUMO_SMALL);
244-
245-
Set<String> themeNames = button.getThemeNames();
246-
Assert.assertTrue(
247-
themeNames.contains(ButtonVariant.LUMO_SMALL.getVariantName()));
248-
}
249-
250-
@Test
251-
public void addThemeVariant_removeThemeVariant_themeNamesDoesNotContainThemeVariant() {
252-
button = new Button();
253-
button.addThemeVariants(ButtonVariant.LUMO_SMALL);
254-
button.removeThemeVariants(ButtonVariant.LUMO_SMALL);
255-
256-
Set<String> themeNames = button.getThemeNames();
257-
Assert.assertFalse(
258-
themeNames.contains(ButtonVariant.LUMO_SMALL.getVariantName()));
259-
}
260-
261-
@Test
262-
public void addThemeVariant_setIcon_themeAttributeContainsThemeVariantAndIcon() {
263-
button = new Button();
264-
button.addThemeVariants(ButtonVariant.LUMO_SUCCESS);
265-
button.setIcon(new Icon(VaadinIcon.ARROW_RIGHT));
266-
267-
Set<String> themeNames = button.getThemeNames();
268-
Assert.assertTrue(themeNames.contains("icon"));
269-
Assert.assertTrue(themeNames
270-
.contains(ButtonVariant.LUMO_SUCCESS.getVariantName()));
271-
}
272-
273-
@Test
274-
public void setIcon_addThemeVariant_themeAttributeContiansThemeVariantAndIcon() {
275-
button = new Button();
276-
button.setIcon(new Icon(VaadinIcon.ARROW_RIGHT));
277-
button.addThemeVariants(ButtonVariant.LUMO_SUCCESS);
278-
279-
Set<String> themeNames = button.getThemeNames();
280-
Assert.assertTrue(themeNames.contains("icon"));
281-
Assert.assertTrue(themeNames
282-
.contains(ButtonVariant.LUMO_SUCCESS.getVariantName()));
283-
}
284-
285-
@Test
286-
public void changeIcon_iconThemeIsPreserved() {
287-
button = new Button();
288-
button.setIcon(new Icon(VaadinIcon.ARROW_RIGHT));
289-
290-
Assert.assertEquals("icon", button.getThemeName());
291-
292-
button.setIcon(new Icon(VaadinIcon.ALARM));
293-
294-
Assert.assertEquals("icon", button.getThemeName());
295-
}
296-
297185
@Test
298186
public void disableOnClick_click_componentIsDisabled() {
299187
AtomicBoolean buttonIsEnabled = new AtomicBoolean(true);
@@ -337,15 +225,6 @@ public void setAriaLabel() {
337225
Assert.assertEquals("Aria label", button.getAriaLabel().get());
338226
}
339227

340-
private void assertButtonHasThemeAttribute(String theme) {
341-
Assert.assertTrue("Expected " + theme + " to be in the theme attribute",
342-
button.getThemeNames().contains(theme));
343-
}
344-
345-
private void assertButtonHasNoThemeAttribute() {
346-
Assert.assertNull(button.getElement().getAttribute("theme"));
347-
}
348-
349228
private void assertIconBeforeText() {
350229
Assert.assertTrue("Icon should be child of button",
351230
button.getElement().getChildren()

0 commit comments

Comments
 (0)