Skip to content

Commit 74c655f

Browse files
committed
feat(example-app): ✨ update tag preview screen with controllables
1 parent 24b9b19 commit 74c655f

File tree

1 file changed

+85
-47
lines changed

1 file changed

+85
-47
lines changed
Lines changed: 85 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import React, { useState } from "react";
22
import {
33
Box,
4-
Checkbox,
5-
CheckboxGroup,
64
Icon,
5+
Radio,
6+
RadioGroup,
77
Slot,
8+
Switch,
89
Tag,
910
TagSizes,
1011
TagTheme,
@@ -14,53 +15,90 @@ import {
1415

1516
export const TagScreen = () => {
1617
const tailwind = useTheme();
17-
const sizes: TagSizes[] = ["sm", "md", "lg", "xl"];
18-
const themeColors: TagTheme[] = ["base", "primary"];
19-
const variants: TagVariant[] = ["solid", "subtle", "outline"];
20-
const [value, setValue] = useState<string[]>([]);
18+
const [selectedSize, setSelectedSize] = useState<TagSizes>("md");
19+
const [selectedVariant, setSelectedVariant] = useState<TagVariant>("solid");
20+
const [selectedTheme, setSelectedTheme] = useState<TagTheme>("base");
21+
const [hasPrefix, setHasPrefix] = useState<boolean>(false);
22+
const [hasSuffix, setHasSuffix] = useState<boolean>(false);
23+
const [isClosable, setIsClosable] = useState<boolean>(false);
2124

2225
return (
23-
<Box
24-
style={tailwind.style("flex-1 justify-center items-center bg-white-900")}
25-
>
26-
<CheckboxGroup value={value} onChange={setValue}>
27-
<Checkbox label="Closable" value="closable" />
28-
<Checkbox label="Show Prefix" value="showprefix" />
29-
</CheckboxGroup>
30-
{sizes.map((size, index) => {
31-
return (
32-
<Box style={tailwind.style("flex-col my-1")} key={size + index}>
33-
{variants.map((variant, variantIndex) => {
34-
return (
35-
<Box
36-
style={tailwind.style("flex-row my-1")}
37-
key={variant + variantIndex}
38-
>
39-
{themeColors.map((theme, themeIndex) => {
40-
return (
41-
<Tag
42-
style={tailwind.style("mx-1")}
43-
size={size}
44-
key={theme + themeIndex}
45-
variant={variant}
46-
themeColor={theme}
47-
closable={value.includes("closable")}
48-
prefix={
49-
value.includes("showprefix") ? (
50-
<Icon icon={<Slot />} />
51-
) : null
52-
}
53-
>
54-
Continue
55-
</Tag>
56-
);
57-
})}
58-
</Box>
59-
);
60-
})}
61-
</Box>
62-
);
63-
})}
26+
<Box style={tailwind.style("flex-1 items-center bg-white-900")}>
27+
<Box style={tailwind.style("flex-1 px-2 justify-center")}>
28+
<Tag
29+
size={selectedSize}
30+
variant={selectedVariant}
31+
themeColor={selectedTheme}
32+
prefix={hasPrefix ? <Icon icon={<Slot />} /> : null}
33+
suffix={hasSuffix ? <Icon icon={<Slot />} /> : null}
34+
closable={isClosable}
35+
style={tailwind.style("mx-1")}
36+
>
37+
Continue
38+
</Tag>
39+
</Box>
40+
41+
<Box
42+
style={tailwind.style(
43+
"w-full py-2 rounded-t-lg shadow-lg bg-gray-100 justify-end items-center",
44+
)}
45+
>
46+
<RadioGroup
47+
value={selectedSize}
48+
onChange={value => setSelectedSize(value as TagSizes)}
49+
orientation="horizontal"
50+
>
51+
<Radio value="sm" label="sm" />
52+
<Radio value="md" label="md" />
53+
<Radio value="lg" label="lg" />
54+
<Radio value="xl" label="xl" />
55+
</RadioGroup>
56+
<RadioGroup
57+
value={selectedVariant}
58+
onChange={value => setSelectedVariant(value as TagVariant)}
59+
orientation="horizontal"
60+
>
61+
<Radio value="outline" label="outline" />
62+
<Radio value="subtle" label="subtle" />
63+
<Radio value="solid" label="solid" />
64+
</RadioGroup>
65+
<RadioGroup
66+
value={selectedTheme}
67+
onChange={value => setSelectedTheme(value as TagTheme)}
68+
orientation="horizontal"
69+
>
70+
<Radio value="base" label="base" />
71+
<Radio value="primary" label="primary" />
72+
</RadioGroup>
73+
<Box
74+
style={tailwind.style(
75+
"flex flex-row justify-center flex-wrap w-full",
76+
)}
77+
>
78+
<Switch
79+
state={hasPrefix}
80+
onStateChange={value => setHasPrefix(value)}
81+
size="md"
82+
style={tailwind.style("ml-1 mt-1")}
83+
label="Prefix"
84+
/>
85+
<Switch
86+
state={hasSuffix}
87+
onStateChange={value => setHasSuffix(value)}
88+
size="md"
89+
style={tailwind.style("ml-1 mt-1")}
90+
label="Suffix"
91+
/>
92+
93+
<Switch
94+
state={isClosable}
95+
onStateChange={value => setIsClosable(value)}
96+
size="md"
97+
style={tailwind.style("ml-1 mt-1")}
98+
label="Closable"
99+
/>
100+
</Box>
101+
</Box>
64102
</Box>
65103
);
66104
};

0 commit comments

Comments
 (0)