Skip to content

Commit bf3a365

Browse files
paodbjavier-godoy
authored andcommitted
feat(demo): add new demo with theme support
1 parent e3b0a2b commit bf3a365

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed

src/test/java/com/flowingcode/vaadin/addons/chipfield/ChipfieldDemoView.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class ChipfieldDemoView extends TabbedDemo {
3636
private static final String DISABLED_DEMO = "Disabled";
3737
private static final String BINDER_DEMO = "Binder";
3838
private static final String READONLY_DEMO = "Readonly";
39+
private static final String STYLED_DEMO = "Styled";
3940
private static final String DATAPROVIDER_SOURCE =
4041
"https://github.com/FlowingCode/ChipFieldAddon/blob/master/src/test/java/com/flowingcode/vaadin/addons/chipfield/DataProviderDemo.java";
4142
private static final String RESTRICTED_SOURCE =
@@ -46,6 +47,8 @@ public class ChipfieldDemoView extends TabbedDemo {
4647
"https://github.com/FlowingCode/ChipFieldAddon/blob/master/src/test/java/com/flowingcode/vaadin/addons/chipfield/BinderDemo.java";
4748
private static final String READONLY_SOURCE =
4849
"https://github.com/FlowingCode/ChipFieldAddon/blob/master/src/test/java/com/flowingcode/vaadin/addons/chipfield/ReadonlyDemo.java";
50+
private static final String STYLED_SOURCE =
51+
"https://github.com/FlowingCode/ChipFieldAddon/blob/master/src/test/java/com/flowingcode/vaadin/addons/chipfield/StyledDemo.java";
4952

5053
public ChipfieldDemoView() {
5154

@@ -54,5 +57,6 @@ public ChipfieldDemoView() {
5457
addDemo(new DisabledDemo(), DISABLED_DEMO, DISABLED_SOURCE);
5558
addDemo(new BinderDemo(), BINDER_DEMO, BINDER_SOURCE);
5659
addDemo(new ReadonlyDemo(), READONLY_DEMO, READONLY_SOURCE);
60+
addDemo(new StyledDemo(), STYLED_DEMO, STYLED_SOURCE);
5761
}
5862
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.flowingcode.vaadin.addons.chipfield;
2+
3+
import java.util.Arrays;
4+
import com.vaadin.flow.component.dependency.CssImport;
5+
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
6+
7+
@CssImport(value = "./styles/paper-chip-styles.css", themeFor = "paper-chip")
8+
@CssImport(value = "./styles/paper-chip-input-autocomplete-styles.css", themeFor = "paper-chip-input-autocomplete")
9+
public class StyledDemo extends VerticalLayout {
10+
11+
public StyledDemo() {
12+
ChipField<String> chf =
13+
new ChipField<>("Select some planets (Allowed pattern [a-zA-Z])");
14+
chf.setWidth("90%");
15+
chf.setAvailableItems(
16+
Arrays.asList(
17+
"Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"));
18+
chf.setAllowedPattern("[a-zA-Z]");
19+
chf.addSelectedItem("Mercury");
20+
chf.addSelectedItem("Venus");
21+
chf.setClosable(true);
22+
23+
chf.setThemeName("styled-demo");
24+
25+
add(chf);
26+
}
27+
28+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
:host([theme~="styled-demo"]) {
2+
border: 1px solid #c1c1c1;
3+
border-radius: 0.5em;
4+
padding-left: 10px;
5+
padding-bottom: 10px;
6+
}
7+
8+
:host([theme~="styled-demo"]) paper-input {
9+
10+
/* disable underline*/
11+
--paper-input-container-underline: {
12+
display: none;
13+
};
14+
15+
/* disable on focus*/
16+
--paper-input-container-underline-focus: {
17+
display: none;
18+
};
19+
20+
/* disable on input-disable*/
21+
--paper-input-container-underline-disabled: {
22+
display: none;
23+
};
24+
25+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
:host([theme~="styled-demo"]) .chip {
2+
border-radius: 4px;
3+
background-color: #e9e9e9;
4+
}
5+
6+
:host([theme~="styled-demo"]) .chip .label {
7+
color: var(--lumo-primary-text-color);
8+
font-size: 15px;
9+
}
10+
11+
:host([theme~="styled-demo"]) .chip .close {
12+
color: var(--lumo-body-text-color);
13+
background-color: transparent;
14+
}

0 commit comments

Comments
 (0)