@clickhouse/click-ui 0.0.0 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +1 -0
- package/.prettierrc +14 -0
- package/.storybook/main.ts +1 -0
- package/.storybook/manager.ts +11 -0
- package/.storybook/preview-head.html +2 -4
- package/.storybook/preview.tsx +13 -4
- package/.storybook/theme.ts +16 -0
- package/build-tokens.js +6 -6
- package/package.json +25 -5
- package/public/favicon.ico +0 -0
- package/public/logo.svg +17 -0
- package/src/App.tsx +102 -39
- package/src/components/Accordion/Accordion.stories.tsx +4 -54
- package/src/components/Accordion/Accordion.tsx +1 -0
- package/src/components/Alert/Alert.stories.tsx +14 -0
- package/src/components/Alert/Alert.test.tsx +27 -0
- package/src/components/Alert/Alert.tsx +130 -0
- package/src/components/Avatar/Avatar.stories.tsx +13 -0
- package/src/components/Avatar/Avatar.tsx +64 -0
- package/src/components/Badge/Badge.stories.ts +19 -3
- package/src/components/Badge/Badge.test.tsx +6 -1
- package/src/components/Badge/Badge.tsx +67 -13
- package/src/components/BigStat/BigStat.stories.ts +10 -5
- package/src/components/BigStat/BigStat.tsx +36 -24
- package/src/components/Button/Button.stories.ts +12 -68
- package/src/components/Button/Button.test.tsx +2 -2
- package/src/components/Button/Button.tsx +59 -41
- package/src/components/ButtonGroup/ButtonGroup.stories.ts +3 -3
- package/src/components/Card/Card.stories.ts +3 -3
- package/src/components/Checkbox/Checkbox.stories.tsx +35 -0
- package/src/components/Checkbox/Checkbox.test.tsx +41 -0
- package/src/components/Checkbox/Checkbox.tsx +89 -0
- package/src/components/ContextMenu/ContextMenu.stories.tsx +73 -0
- package/src/components/ContextMenu/ContextMenu.test.tsx +152 -0
- package/src/components/ContextMenu/ContextMenu.tsx +155 -0
- package/src/components/Dropdown/Dropdown.stories.tsx +64 -0
- package/src/components/Dropdown/Dropdown.test.tsx +141 -0
- package/src/components/Dropdown/Dropdown.tsx +149 -0
- package/src/components/FormField/Label.stories.tsx +39 -0
- package/src/components/FormField/Label.tsx +47 -0
- package/src/components/FormField/Select.stories.tsx +48 -0
- package/src/components/FormField/Select.test.tsx +216 -0
- package/src/components/FormField/Select.tsx +574 -0
- package/src/components/FormField/SelectContext.tsx +101 -0
- package/src/components/FormField/commonElement.tsx +42 -0
- package/src/components/GenericMenu.tsx +114 -0
- package/src/components/HoverCard/HoverCard.stories.tsx +64 -0
- package/src/components/HoverCard/HoverCard.test.tsx +85 -0
- package/src/components/HoverCard/HoverCard.tsx +65 -0
- package/src/components/Icon/Icon.stories.ts +4 -35
- package/src/components/Icon/Icon.tsx +166 -18
- package/src/components/Icon/types.ts +78 -1
- package/src/components/IconButton/IconButton.stories.ts +25 -7
- package/src/components/IconButton/IconButton.test.tsx +32 -0
- package/src/components/IconButton/IconButton.tsx +60 -71
- package/src/components/Panel/Panel.stories.tsx +25 -0
- package/src/components/Panel/Panel.tsx +33 -0
- package/src/components/Popover/Popover.stories.tsx +67 -0
- package/src/components/Popover/Popover.test.tsx +46 -0
- package/src/components/Popover/Popover.tsx +115 -0
- package/src/components/RadioGroup/RadioGroup.stories.tsx +43 -0
- package/src/components/RadioGroup/RadioGroup.test.tsx +59 -0
- package/src/components/RadioGroup/RadioGroup.tsx +149 -0
- package/src/components/Separator/Separator.stories.tsx +24 -0
- package/src/components/Separator/Separator.tsx +29 -0
- package/src/components/SidebarNavigationItem/SidebarNavigationItem.stories.tsx +2 -2
- package/src/components/Spacer/Spacer.stories.tsx +20 -0
- package/src/components/Spacer/Spacer.tsx +15 -0
- package/src/components/Switch/Switch.stories.ts +3 -3
- package/src/components/Switch/Switch.tsx +3 -2
- package/src/components/Table/Table.stories.tsx +29 -0
- package/src/components/Table/Table.tsx +109 -0
- package/src/components/Tabs/Tabs.stories.tsx +2 -37
- package/src/components/Tooltip/Tooltip.stories.tsx +68 -0
- package/src/components/Tooltip/Tooltip.test.tsx +44 -0
- package/src/components/Tooltip/Tooltip.tsx +67 -0
- package/src/components/Typography/Text/Text.stories.tsx +22 -0
- package/src/components/Typography/Text/Text.test.tsx +16 -0
- package/src/components/Typography/Text/Text.tsx +30 -0
- package/src/components/Typography/Title/Title.stories.tsx +31 -0
- package/src/components/Typography/Title/Title.test.tsx +16 -0
- package/src/components/Typography/Title/Title.tsx +36 -0
- package/src/components/icons/Activity.tsx +30 -0
- package/src/components/icons/ArrowDown.tsx +22 -0
- package/src/components/icons/ArrowRight.tsx +22 -0
- package/src/components/icons/ArrowTriangle.tsx +36 -0
- package/src/components/icons/ArrowUp.tsx +22 -0
- package/src/components/icons/Backups.tsx +29 -0
- package/src/components/icons/Blog.tsx +38 -0
- package/src/components/icons/Book.tsx +30 -0
- package/src/components/icons/Brackets.tsx +22 -0
- package/src/components/icons/Briefcase.tsx +30 -0
- package/src/components/icons/Building.tsx +30 -0
- package/src/components/icons/BurgerMenu.tsx +22 -0
- package/src/components/icons/Cards.tsx +30 -0
- package/src/components/icons/CellTower.tsx +21 -0
- package/src/components/icons/CheckIcon.tsx +21 -0
- package/src/components/icons/CheckInCircle.tsx +39 -0
- package/src/components/icons/ChevronDown.tsx +19 -5
- package/src/components/icons/ChevronLeft.tsx +22 -0
- package/src/components/icons/ChevronRight.tsx +3 -3
- package/src/components/icons/ChevronUp.tsx +22 -0
- package/src/components/icons/Clock.tsx +37 -0
- package/src/components/icons/Cloud.tsx +23 -0
- package/src/components/icons/Code.tsx +22 -0
- package/src/components/icons/CodeInSquare.tsx +30 -0
- package/src/components/icons/Connect.tsx +22 -0
- package/src/components/icons/ConnectAlt.tsx +30 -0
- package/src/components/icons/Console.tsx +30 -0
- package/src/components/icons/Copy.tsx +33 -0
- package/src/components/icons/CrossIcon.tsx +29 -0
- package/src/components/icons/Data.tsx +36 -0
- package/src/components/icons/DatabaseIcon.tsx +27 -29
- package/src/components/icons/Disk.tsx +30 -0
- package/src/components/icons/Display.tsx +30 -0
- package/src/components/icons/Document.tsx +30 -0
- package/src/components/icons/DotsHorizontal.tsx +36 -0
- package/src/components/icons/DotsVertical.tsx +33 -0
- package/src/components/icons/Email.tsx +33 -0
- package/src/components/icons/Empty.tsx +14 -0
- package/src/components/icons/FilterIcon.tsx +29 -16
- package/src/components/icons/Fire.tsx +23 -0
- package/src/components/icons/Folder.tsx +20 -0
- package/src/components/icons/Gift.tsx +21 -0
- package/src/components/icons/HistoryIcon.tsx +13 -13
- package/src/components/icons/Home.tsx +29 -0
- package/src/components/icons/Http.tsx +22 -0
- package/src/components/icons/Icons.mdx +31 -28
- package/src/components/icons/InfoInCircleIcon.tsx +37 -0
- package/src/components/icons/InformationIcon.tsx +34 -0
- package/src/components/icons/InsertRowIcon.tsx +30 -32
- package/src/components/icons/Integrations.tsx +29 -0
- package/src/components/icons/LightBulb.tsx +40 -0
- package/src/components/icons/Lightening.tsx +30 -0
- package/src/components/icons/Loading.tsx +57 -0
- package/src/components/icons/Metrics.tsx +38 -0
- package/src/components/icons/MetricsAlt.tsx +30 -0
- package/src/components/icons/Payment.tsx +23 -0
- package/src/components/icons/Payments/Amex.tsx +44 -0
- package/src/components/icons/Payments/MasterCard.tsx +48 -0
- package/src/components/icons/Payments/Paypal.tsx +41 -0
- package/src/components/icons/Payments/Visa.tsx +36 -0
- package/src/components/icons/Payments/index.tsx +30 -0
- package/src/components/icons/Pencil.tsx +30 -0
- package/src/components/icons/PieChart.tsx +30 -0
- package/src/components/icons/Play.tsx +30 -0
- package/src/components/icons/Plus.tsx +22 -0
- package/src/components/icons/Popout.tsx +22 -0
- package/src/components/icons/PopoverArrow.tsx +22 -0
- package/src/components/icons/Question.tsx +30 -0
- package/src/components/icons/Refresh.tsx +29 -0
- package/src/components/icons/Search.tsx +22 -0
- package/src/components/icons/Secure.tsx +30 -0
- package/src/components/icons/Services.tsx +23 -0
- package/src/components/icons/Settings.tsx +22 -0
- package/src/components/icons/Share.tsx +29 -0
- package/src/components/icons/SlideIn.tsx +28 -0
- package/src/components/icons/SlideOut.tsx +28 -0
- package/src/components/icons/SortAltIcon.tsx +18 -20
- package/src/components/icons/SortIcon.tsx +24 -0
- package/src/components/icons/Sparkle.tsx +23 -0
- package/src/components/icons/Speaker.tsx +30 -0
- package/src/components/icons/Speed.tsx +29 -0
- package/src/components/icons/Star.tsx +23 -0
- package/src/components/icons/Support.tsx +37 -0
- package/src/components/icons/Table.tsx +30 -0
- package/src/components/icons/Taxi.tsx +120 -0
- package/src/components/icons/Trash.tsx +22 -0
- package/src/components/icons/Upload.tsx +29 -0
- package/src/components/icons/Url.tsx +22 -0
- package/src/components/icons/UsersIcon.tsx +27 -27
- package/src/components/icons/WarningIcon.tsx +30 -0
- package/src/components/index.ts +31 -10
- package/src/index.ts +2 -2
- package/src/styles/types.ts +715 -295
- package/src/styles/variables.classic.json +171 -0
- package/src/styles/variables.dark.json +447 -129
- package/src/styles/variables.json +830 -410
- package/src/styles/variables.light.json +339 -179
- package/tokens/themes/$themes.json +3657 -1
- package/tokens/themes/classic.json +492 -0
- package/tokens/themes/component.json +1126 -441
- package/tokens/themes/dark.json +1871 -758
- package/tokens/themes/light.json +852 -266
- package/tokens/themes/primitives.json +294 -210
- package/vite.config.ts +6 -4
- package/app/.babelrc +0 -27
- package/app/.eslintrc.json +0 -6
- package/app/.storybook/main.ts +0 -17
- package/app/.storybook/preview.tsx +0 -26
- package/app/README.md +0 -38
- package/app/next.config.js +0 -6
- package/app/package-lock.json +0 -28711
- package/app/package.json +0 -44
- package/app/public/favicon.ico +0 -0
- package/app/public/next.svg +0 -1
- package/app/public/vercel.svg +0 -1
- package/app/src/assets/RightArrow/right-arrow.tsx +0 -17
- package/app/src/assets/S3Logo/s3-logo.tsx +0 -31
- package/app/src/assets/amazon_s3.svg +0 -9
- package/app/src/assets/arrow.svg +0 -3
- package/app/src/globals.d.ts +0 -4
- package/app/src/pages/_app.tsx +0 -8
- package/app/src/pages/_document.tsx +0 -17
- package/app/src/pages/api/hello.ts +0 -13
- package/app/src/pages/index.tsx +0 -141
- package/app/src/pages/label.tsx +0 -27
- package/app/src/stories/assets/code-brackets.svg +0 -1
- package/app/src/stories/assets/colors.svg +0 -1
- package/app/src/stories/assets/comments.svg +0 -1
- package/app/src/stories/assets/direction.svg +0 -1
- package/app/src/stories/assets/flow.svg +0 -1
- package/app/src/stories/assets/plugin.svg +0 -1
- package/app/src/stories/assets/repo.svg +0 -1
- package/app/src/stories/assets/stackalt.svg +0 -1
- package/app/src/styles/Home.module.css +0 -235
- package/app/src/styles/globals.css +0 -111
- package/app/src/styles/types.ts +0 -1031
- package/app/src/styles/variables.classic.css +0 -16
- package/app/src/styles/variables.classic.json +0 -31
- package/app/src/styles/variables.css +0 -763
- package/app/src/styles/variables.dark.css +0 -135
- package/app/src/styles/variables.dark.json +0 -339
- package/app/src/styles/variables.json +0 -1029
- package/app/src/styles/variables.light.css +0 -203
- package/app/src/styles/variables.light.json +0 -478
- package/app/tokens/themes/$metadata.json +0 -9
- package/app/tokens/themes/$themes.json +0 -1
- package/app/tokens/themes/classic.json +0 -58
- package/app/tokens/themes/component.json +0 -868
- package/app/tokens/themes/dark.json +0 -937
- package/app/tokens/themes/light.json +0 -1380
- package/app/tokens/themes/primitives.json +0 -859
- package/app/tsconfig.json +0 -23
- package/src/components/FormField/FormField.stories.ts +0 -14
- package/src/components/FormField/FormField.tsx +0 -22
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ThemeProvider } from "styled-components";
|
|
2
|
+
import { themes } from "../../theme";
|
|
3
|
+
import { fireEvent, render } from "@testing-library/react";
|
|
4
|
+
import { RadioGroup } from "@/components";
|
|
5
|
+
import { RadioGroupProps } from "./RadioGroup";
|
|
6
|
+
|
|
7
|
+
describe("RadioGroup", () => {
|
|
8
|
+
const renderRadioGroup = (props: RadioGroupProps) =>
|
|
9
|
+
render(
|
|
10
|
+
<ThemeProvider theme={themes.dark}>
|
|
11
|
+
<RadioGroup
|
|
12
|
+
inline
|
|
13
|
+
{...props}
|
|
14
|
+
>
|
|
15
|
+
<RadioGroup.Item
|
|
16
|
+
id="RadioButton1"
|
|
17
|
+
label="Radio Button1"
|
|
18
|
+
value="RadioButton1"
|
|
19
|
+
/>
|
|
20
|
+
<RadioGroup.Item
|
|
21
|
+
label="Radio Button2"
|
|
22
|
+
value="RadioButton2"
|
|
23
|
+
id="RadioButton2"
|
|
24
|
+
/>
|
|
25
|
+
<RadioGroup.Item
|
|
26
|
+
label="Radio Button3"
|
|
27
|
+
value="RadioButton3"
|
|
28
|
+
id="RadioButton3"
|
|
29
|
+
/>
|
|
30
|
+
</RadioGroup>
|
|
31
|
+
</ThemeProvider>
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
it("should execute action on click", () => {
|
|
35
|
+
const handleClick = jest.fn();
|
|
36
|
+
const { getByLabelText } = renderRadioGroup({
|
|
37
|
+
onValueChange: handleClick,
|
|
38
|
+
});
|
|
39
|
+
const radio = getByLabelText("Radio Button1");
|
|
40
|
+
expect(radio.dataset.state).toBe("unchecked");
|
|
41
|
+
fireEvent.click(radio);
|
|
42
|
+
expect(radio.dataset.state).toBe("checked");
|
|
43
|
+
expect(handleClick).toBeCalledTimes(1);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("should not execute action on click if the radio is disabled", () => {
|
|
47
|
+
const handleClick = jest.fn();
|
|
48
|
+
const { getByLabelText } = renderRadioGroup({
|
|
49
|
+
onValueChange: handleClick,
|
|
50
|
+
disabled: true,
|
|
51
|
+
});
|
|
52
|
+
const radio = getByLabelText("Radio Button2");
|
|
53
|
+
expect(radio.dataset.state).toBe("unchecked");
|
|
54
|
+
expect(radio).not.toBeNull();
|
|
55
|
+
fireEvent.click(radio);
|
|
56
|
+
expect(radio.dataset.state).toBe("unchecked");
|
|
57
|
+
expect(handleClick).toBeCalledTimes(0);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import * as RadixRadioGroup from "@radix-ui/react-radio-group";
|
|
2
|
+
import { HTMLAttributes, ReactNode, useId } from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
|
|
5
|
+
export interface RadioGroupProps extends RadixRadioGroup.RadioGroupProps {
|
|
6
|
+
inline?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const RadioGroupRoot = styled(RadixRadioGroup.Root)<{ inline: "true" | "false" }>`
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-wrap: wrap;
|
|
12
|
+
gap: ${({ theme }) => theme.click.checkbox.space.gap};
|
|
13
|
+
flex-direction: ${({ inline }) => (inline === "true" ? "row" : "column")};
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
export const RadioGroup = ({ children, inline, ...props }: RadioGroupProps) => {
|
|
17
|
+
return (
|
|
18
|
+
<RadioGroupRoot
|
|
19
|
+
inline={inline === true ? "true" : "false"}
|
|
20
|
+
{...props}
|
|
21
|
+
>
|
|
22
|
+
{children}
|
|
23
|
+
</RadioGroupRoot>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
interface RadioGroupInputProps extends RadixRadioGroup.RadioGroupItemProps {
|
|
28
|
+
label?: ReactNode;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type RadioGroupItemProps = RadioGroupInputProps & HTMLAttributes<HTMLDivElement>;
|
|
32
|
+
|
|
33
|
+
const RadioGroupItem = ({
|
|
34
|
+
id,
|
|
35
|
+
label,
|
|
36
|
+
value,
|
|
37
|
+
disabled,
|
|
38
|
+
required,
|
|
39
|
+
...props
|
|
40
|
+
}: RadioGroupItemProps) => {
|
|
41
|
+
const defaultId = useId();
|
|
42
|
+
return (
|
|
43
|
+
<Wrapper {...props}>
|
|
44
|
+
<RadioInput
|
|
45
|
+
value={value}
|
|
46
|
+
id={id ?? defaultId}
|
|
47
|
+
disabled={disabled}
|
|
48
|
+
required={required}
|
|
49
|
+
>
|
|
50
|
+
<RadioGroupIndicator />
|
|
51
|
+
</RadioInput>
|
|
52
|
+
{label && (
|
|
53
|
+
<label
|
|
54
|
+
className="Label"
|
|
55
|
+
htmlFor={id ?? defaultId}
|
|
56
|
+
>
|
|
57
|
+
{label}
|
|
58
|
+
</label>
|
|
59
|
+
)}
|
|
60
|
+
</Wrapper>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
RadioGroupItem.displayName = "RadioGroupItem";
|
|
65
|
+
RadioGroup.Item = RadioGroupItem;
|
|
66
|
+
|
|
67
|
+
const Wrapper = styled.div`
|
|
68
|
+
padding: ${({ theme }) => theme.click.checkbox.space.all};
|
|
69
|
+
|
|
70
|
+
display: flex;
|
|
71
|
+
align-items: center;
|
|
72
|
+
gap: ${({ theme }) => theme.click.checkbox.space.gap};
|
|
73
|
+
`;
|
|
74
|
+
|
|
75
|
+
const RadioInput = styled(RadixRadioGroup.Item)`
|
|
76
|
+
display: flex;
|
|
77
|
+
align-items: center;
|
|
78
|
+
justify-content: center;
|
|
79
|
+
outline: none;
|
|
80
|
+
cursor: pointer;
|
|
81
|
+
${({ theme }) => `
|
|
82
|
+
border-radius: ${theme.click.radio.radii.all};
|
|
83
|
+
width: 1rem;
|
|
84
|
+
height: 1rem;
|
|
85
|
+
background: ${theme.click.radio.color.background.default};
|
|
86
|
+
border: 1px solid ${theme.click.radio.color.stroke.default};
|
|
87
|
+
|
|
88
|
+
& ~ label {
|
|
89
|
+
color: ${theme.click.field.color.genericLabel.default};
|
|
90
|
+
font: ${theme.click.radio.typography.label.default};
|
|
91
|
+
cursor: pointer;
|
|
92
|
+
}
|
|
93
|
+
&:hover {
|
|
94
|
+
background: ${theme.click.radio.color.background.hover};
|
|
95
|
+
& ~ label {
|
|
96
|
+
color: ${theme.click.field.color.genericLabel.hover};
|
|
97
|
+
font: ${theme.click.radio.typography.label.hover};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
&[data-state="checked"] {
|
|
101
|
+
border-color: ${theme.click.radio.color.stroke.active};
|
|
102
|
+
background: ${theme.click.radio.color.background.active};
|
|
103
|
+
& ~ label {
|
|
104
|
+
color: ${theme.click.field.color.genericLabel.active};
|
|
105
|
+
font: ${theme.click.radio.typography.label.active};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
&[data-disabled] {
|
|
109
|
+
background: ${theme.click.radio.color.background.disabled};
|
|
110
|
+
border-color: ${theme.click.radio.color.stroke.disabled};
|
|
111
|
+
& ~ label {
|
|
112
|
+
color: ${theme.click.field.color.genericLabel.disabled};
|
|
113
|
+
font: ${theme.click.radio.typography.label.disabled};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
`};
|
|
117
|
+
`;
|
|
118
|
+
|
|
119
|
+
const RadioGroupIndicator = styled(RadixRadioGroup.Indicator)`
|
|
120
|
+
${({ theme }) => `
|
|
121
|
+
background: ${theme.click.radio.color.background.default};
|
|
122
|
+
&::after {
|
|
123
|
+
content: '';
|
|
124
|
+
display: block;
|
|
125
|
+
width: 6px;
|
|
126
|
+
height: 6px;
|
|
127
|
+
border-radius: 50%;
|
|
128
|
+
background-color: ${theme.click.radio.color.indicator.default};
|
|
129
|
+
&:hover {
|
|
130
|
+
background: ${theme.click.radio.color.indicator.hover};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
&[data-state="checked"] {
|
|
134
|
+
background: ${theme.click.radio.color.background.active};
|
|
135
|
+
&::after {
|
|
136
|
+
background: ${theme.click.radio.color.indicator.active};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
&:hover {
|
|
140
|
+
background: ${theme.click.radio.color.background.hover};
|
|
141
|
+
}
|
|
142
|
+
&[data-disabled] {
|
|
143
|
+
background: ${theme.click.radio.color.background.disabled};
|
|
144
|
+
&::after {
|
|
145
|
+
background: ${theme.click.radio.color.indicator.disabled};
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
`}
|
|
149
|
+
`;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import Separator from "./Separator";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
component: Separator,
|
|
5
|
+
title: "Display/Separator",
|
|
6
|
+
tags: ["separator","autodocs"],
|
|
7
|
+
argTypes: {
|
|
8
|
+
size: {
|
|
9
|
+
options: ["xs", "sm", "md", "lg", "xl", "xxl"],
|
|
10
|
+
control: { type: "radio" },
|
|
11
|
+
},
|
|
12
|
+
orientation: {
|
|
13
|
+
options: ["horizontal", "vertical"],
|
|
14
|
+
control: { type: "radio" },
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const Playground = {
|
|
20
|
+
args: {
|
|
21
|
+
size: "xs",
|
|
22
|
+
orientation: "horizontal",
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import * as RadixSeparator from "@radix-ui/react-separator";
|
|
3
|
+
interface Props extends RadixSeparator.SeparatorProps {
|
|
4
|
+
size: "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
|
|
5
|
+
}
|
|
6
|
+
const CUISeparator = styled(RadixSeparator.Root)<Props>`
|
|
7
|
+
&[data-orientation="horizontal"] {
|
|
8
|
+
height: 0.0625rem;
|
|
9
|
+
width: 100%;
|
|
10
|
+
}
|
|
11
|
+
&[data-orientation="vertical"] {
|
|
12
|
+
height: 100%;
|
|
13
|
+
width: 0.0625rem;
|
|
14
|
+
}
|
|
15
|
+
${({ theme, size, orientation }) => `
|
|
16
|
+
background: ${theme.click.separator.color.stroke.default};
|
|
17
|
+
margin: ${
|
|
18
|
+
orientation === "horizontal"
|
|
19
|
+
? `${theme.click.separator.horizontal.space.y[size]} ${theme.click.separator.horizontal.space.x.all}`
|
|
20
|
+
: `${theme.click.separator.vertical.space.y.all} ${theme.click.separator.vertical.space.x[size]}`
|
|
21
|
+
}
|
|
22
|
+
`}
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
const Separator = ({ orientation = "horizontal", ...props }: Props) => (
|
|
26
|
+
<CUISeparator orientation={orientation} {...props} />
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
export default Separator;
|
|
@@ -2,8 +2,8 @@ import { SidebarNavigationItem } from "@/components";
|
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
component: SidebarNavigationItem,
|
|
5
|
-
title: "SidebarNavigationItem",
|
|
6
|
-
tags: ["sidebar", "navigation-item"],
|
|
5
|
+
title: "Display/SidebarNavigationItem",
|
|
6
|
+
tags: ["sidebar", "navigation-item", "autodocs"],
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export const Default = {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Spacer } from "./Spacer";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
component: Spacer,
|
|
5
|
+
title: "Display/Spacer",
|
|
6
|
+
tags: ["spacer","autodocs"],
|
|
7
|
+
argTypes: {
|
|
8
|
+
size: {
|
|
9
|
+
options: ["xs", "sm", "md", "lg", "xl", "xxl"],
|
|
10
|
+
control: { type: "radio" },
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const Playground = {
|
|
16
|
+
args: {
|
|
17
|
+
size: "xxl",
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
|
|
3
|
+
export interface SpacerProps {
|
|
4
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const CUISpacer = styled.div<SpacerProps>`
|
|
8
|
+
background: transparent;
|
|
9
|
+
display: flex;
|
|
10
|
+
padding: ${({ theme, size = "md" }) => `${theme.click.spacer.horizontal.space.y[size]} ${theme.click.spacer.horizontal.space.x.all}`};
|
|
11
|
+
`
|
|
12
|
+
|
|
13
|
+
export const Spacer = ({ size }: SpacerProps) => (
|
|
14
|
+
<CUISpacer size={size} />
|
|
15
|
+
);
|
|
@@ -2,11 +2,11 @@ import { Switch } from "./Switch";
|
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
component: Switch,
|
|
5
|
-
title: "Switch",
|
|
6
|
-
tags: ["switch"],
|
|
5
|
+
title: "Forms/Switch",
|
|
6
|
+
tags: ["switch", "autodocs"],
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
export const
|
|
9
|
+
export const Playground = {
|
|
10
10
|
args: {
|
|
11
11
|
checked: true,
|
|
12
12
|
disabled: false,
|
|
@@ -77,7 +77,7 @@ function getThumbVars(
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
const SwitchRoot = styled(RadixSwitch.Root)<RootProps>(props => {
|
|
80
|
+
const SwitchRoot = styled(RadixSwitch.Root)<RootProps>((props) => {
|
|
81
81
|
const vars = getRootVars(props.theme, props.disabled, props.checked);
|
|
82
82
|
|
|
83
83
|
return {
|
|
@@ -87,10 +87,11 @@ const SwitchRoot = styled(RadixSwitch.Root)<RootProps>(props => {
|
|
|
87
87
|
border: vars.border,
|
|
88
88
|
borderRadius: props.theme.click.switch.radii.all,
|
|
89
89
|
position: "relative",
|
|
90
|
+
padding: 0,
|
|
90
91
|
};
|
|
91
92
|
});
|
|
92
93
|
|
|
93
|
-
const SwitchThumb = styled(RadixSwitch.Thumb)<ThumbProps>(props => {
|
|
94
|
+
const SwitchThumb = styled(RadixSwitch.Thumb)<ThumbProps>((props) => {
|
|
94
95
|
const vars = getThumbVars(props.theme, props.disabled, props.checked);
|
|
95
96
|
|
|
96
97
|
return {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Table } from "./Table";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
component: Table,
|
|
5
|
+
title: "Display/Table",
|
|
6
|
+
tags: ["table", "autodocs"],
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const Playground = {
|
|
10
|
+
args: {
|
|
11
|
+
children: [
|
|
12
|
+
<Table.Tr>
|
|
13
|
+
<Table.Th>Company</Table.Th>
|
|
14
|
+
<Table.Th>Contact</Table.Th>
|
|
15
|
+
<Table.Th>Country</Table.Th>
|
|
16
|
+
</Table.Tr>,
|
|
17
|
+
<Table.Tr>
|
|
18
|
+
<Table.Td>Alfreds Futterkiste</Table.Td>
|
|
19
|
+
<Table.Td>Maria Anders</Table.Td>
|
|
20
|
+
<Table.Td>Germany</Table.Td>
|
|
21
|
+
</Table.Tr>,
|
|
22
|
+
<Table.Tr>
|
|
23
|
+
<Table.Td>Centro comercial Moctezuma</Table.Td>
|
|
24
|
+
<Table.Td>Francisco Chang</Table.Td>
|
|
25
|
+
<Table.Td>Mexico</Table.Td>
|
|
26
|
+
</Table.Tr>,
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Icon } from "@/components";
|
|
2
|
+
import { IconName } from "@/components/Icon/types";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
|
|
5
|
+
type TableHeaderProps = {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
leftIcon?: IconName;
|
|
8
|
+
rightIcon?: IconName;
|
|
9
|
+
};
|
|
10
|
+
const StyledHeader = styled.th`
|
|
11
|
+
padding: 8px 16px;
|
|
12
|
+
background-color: ${props =>
|
|
13
|
+
props.theme.click.table.header.color.background.default};
|
|
14
|
+
font: ${props => props.theme.click.table.header.title.default};
|
|
15
|
+
color: ${props => props.theme.click.table.header.color.title.default};
|
|
16
|
+
gap: 4px;
|
|
17
|
+
text-align: left;
|
|
18
|
+
|
|
19
|
+
&:first-of-type {
|
|
20
|
+
border-top-left-radius: ${props => props.theme.click.table.radii.all};
|
|
21
|
+
}
|
|
22
|
+
&:last-of-type {
|
|
23
|
+
border-top-right-radius: ${props => props.theme.click.table.radii.all};
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
const HeaderContentWrapper = styled.div`
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
justify-content: start;
|
|
31
|
+
gap: 4px;
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
const TableHeader = ({
|
|
35
|
+
leftIcon,
|
|
36
|
+
rightIcon,
|
|
37
|
+
children,
|
|
38
|
+
...delegated
|
|
39
|
+
}: TableHeaderProps) => (
|
|
40
|
+
<StyledHeader {...delegated}>
|
|
41
|
+
<HeaderContentWrapper>
|
|
42
|
+
{leftIcon && <Icon name={leftIcon} width="12px" height="12px" />}
|
|
43
|
+
{children}
|
|
44
|
+
{rightIcon && <Icon name={rightIcon} width="12px" height="12px" />}
|
|
45
|
+
</HeaderContentWrapper>
|
|
46
|
+
</StyledHeader>
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const TableRow = styled.tr`
|
|
50
|
+
background-color: ${props =>
|
|
51
|
+
props.theme.click.table.row.color.background.default};
|
|
52
|
+
border-bottom: 1px solid
|
|
53
|
+
${props => props.theme.click.table.row.color.stroke.default};
|
|
54
|
+
|
|
55
|
+
&:has(${StyledHeader}) {
|
|
56
|
+
border-bottom: revert;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&:active {
|
|
60
|
+
background-color: ${props =>
|
|
61
|
+
props.theme.click.table.row.color.background.active};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&:hover {
|
|
65
|
+
background-color: ${props =>
|
|
66
|
+
props.theme.click.table.row.color.background.hover};
|
|
67
|
+
}
|
|
68
|
+
`;
|
|
69
|
+
|
|
70
|
+
const TableData = styled.td`
|
|
71
|
+
font: ${props => props.theme.click.table.cell.label.default};
|
|
72
|
+
padding: 16px;
|
|
73
|
+
border: 1px solid
|
|
74
|
+
${props => props.theme.click.table.global.color.stroke.default};
|
|
75
|
+
border-top: none;
|
|
76
|
+
|
|
77
|
+
:not(:last-of-type) {
|
|
78
|
+
border-right: none;
|
|
79
|
+
}
|
|
80
|
+
:not(:first-of-type) {
|
|
81
|
+
border-left: none;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
${TableRow}:last-of-type &:first-of-type {
|
|
85
|
+
border-bottom-left-radius: ${props => props.theme.click.table.radii.all};
|
|
86
|
+
}
|
|
87
|
+
${TableRow}:last-of-type &:last-of-type {
|
|
88
|
+
border-bottom-right-radius: ${props => props.theme.click.table.radii.all};
|
|
89
|
+
}
|
|
90
|
+
`;
|
|
91
|
+
|
|
92
|
+
const Table = (props: React.HTMLAttributes<HTMLTableElement>) => (
|
|
93
|
+
<StyledTable {...props} />
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const StyledTable = styled.table`
|
|
97
|
+
border-spacing: 0;
|
|
98
|
+
`;
|
|
99
|
+
|
|
100
|
+
TableHeader.displayName = "Table.Th";
|
|
101
|
+
Table.Th = TableHeader;
|
|
102
|
+
|
|
103
|
+
TableData.displayName = "Table.Td";
|
|
104
|
+
Table.Td = TableData;
|
|
105
|
+
|
|
106
|
+
TableRow.displayName = "Table.Tr";
|
|
107
|
+
Table.Tr = TableRow;
|
|
108
|
+
|
|
109
|
+
export { Table };
|
|
@@ -3,7 +3,7 @@ import type { StoryObj } from "@storybook/react";
|
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
component: Tabs,
|
|
6
|
-
title: "Tabs",
|
|
6
|
+
title: "Display/Tabs",
|
|
7
7
|
tags: ["tabs", "autodocs"],
|
|
8
8
|
};
|
|
9
9
|
|
|
@@ -33,39 +33,4 @@ export const Default: Story = {
|
|
|
33
33
|
</>
|
|
34
34
|
),
|
|
35
35
|
},
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export const Hover = {
|
|
39
|
-
args: {
|
|
40
|
-
children: [
|
|
41
|
-
<>
|
|
42
|
-
<Tabs.TriggersList>
|
|
43
|
-
<Tabs.Trigger value="tab1" key="tab1">
|
|
44
|
-
tab1
|
|
45
|
-
</Tabs.Trigger>
|
|
46
|
-
</Tabs.TriggersList>
|
|
47
|
-
<Tabs.Content value="tab1">Tab 1 content</Tabs.Content>
|
|
48
|
-
</>,
|
|
49
|
-
],
|
|
50
|
-
},
|
|
51
|
-
parameters: {
|
|
52
|
-
pseudo: {
|
|
53
|
-
hover: true,
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export const Selected = {
|
|
59
|
-
args: {
|
|
60
|
-
children: [
|
|
61
|
-
<>
|
|
62
|
-
<Tabs.TriggersList>
|
|
63
|
-
<Tabs.Trigger value="tab1" data-state="active" key="tab1">
|
|
64
|
-
tab1
|
|
65
|
-
</Tabs.Trigger>
|
|
66
|
-
</Tabs.TriggersList>
|
|
67
|
-
<Tabs.Content value="tab1">Tab 1 content</Tabs.Content>
|
|
68
|
-
</>,
|
|
69
|
-
],
|
|
70
|
-
},
|
|
71
|
-
};
|
|
36
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { TooltipProps } from "@radix-ui/react-tooltip";
|
|
2
|
+
import { Tooltip, TooltipProvider } from "./Tooltip";
|
|
3
|
+
|
|
4
|
+
interface Props extends TooltipProps {
|
|
5
|
+
showArrow?: boolean;
|
|
6
|
+
delayDuration?: number;
|
|
7
|
+
skipDelayDuration?: number;
|
|
8
|
+
disableHoverableContent?: boolean;
|
|
9
|
+
side: "top" | "right" | "left" | "bottom";
|
|
10
|
+
}
|
|
11
|
+
const TooltipExample = ({
|
|
12
|
+
delayDuration,
|
|
13
|
+
skipDelayDuration,
|
|
14
|
+
showArrow,
|
|
15
|
+
disableHoverableContent,
|
|
16
|
+
side,
|
|
17
|
+
...props
|
|
18
|
+
}: Props) => {
|
|
19
|
+
return (
|
|
20
|
+
<div
|
|
21
|
+
style={{
|
|
22
|
+
display: "grid",
|
|
23
|
+
placeItems: "center",
|
|
24
|
+
width: "100%",
|
|
25
|
+
height: "100%",
|
|
26
|
+
}}
|
|
27
|
+
>
|
|
28
|
+
<TooltipProvider
|
|
29
|
+
delayDuration={delayDuration}
|
|
30
|
+
disableHoverableContent={disableHoverableContent}
|
|
31
|
+
skipDelayDuration={skipDelayDuration}
|
|
32
|
+
>
|
|
33
|
+
<Tooltip {...props}>
|
|
34
|
+
<Tooltip.Trigger>
|
|
35
|
+
<div>Tooltip Trigger(Hover)</div>
|
|
36
|
+
</Tooltip.Trigger>
|
|
37
|
+
<Tooltip.Content
|
|
38
|
+
showArrow={showArrow}
|
|
39
|
+
side={side}
|
|
40
|
+
>
|
|
41
|
+
Tooltip content
|
|
42
|
+
</Tooltip.Content>
|
|
43
|
+
</Tooltip>
|
|
44
|
+
</TooltipProvider>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
export default {
|
|
49
|
+
component: TooltipExample,
|
|
50
|
+
title: "Display/Tooltip",
|
|
51
|
+
tags: ["form-field", "tooltip", "autodocs"],
|
|
52
|
+
argTypes: {
|
|
53
|
+
open: { control: "inline-radio", options: [undefined, true, false] },
|
|
54
|
+
defaultOpen: { control: "boolean" },
|
|
55
|
+
showArrow: { control: "boolean" },
|
|
56
|
+
delayDuration: { control: "number" },
|
|
57
|
+
skipDelayDuration: { control: "number" },
|
|
58
|
+
disableHoverableContent: { control: "boolean" },
|
|
59
|
+
side: { control: "select", options: ["top", "right", "left", "bottom"] },
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const Playground = {
|
|
64
|
+
args: {
|
|
65
|
+
side: "bottom",
|
|
66
|
+
showArrow: true,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ThemeProvider } from "styled-components";
|
|
2
|
+
import { themes } from "../../theme";
|
|
3
|
+
import { TooltipProps } from "@radix-ui/react-tooltip";
|
|
4
|
+
import { Tooltip, TooltipProvider } from "..";
|
|
5
|
+
import { render, waitFor } from "@testing-library/react";
|
|
6
|
+
import userEvent from "@testing-library/user-event";
|
|
7
|
+
|
|
8
|
+
describe("Tooltip", () => {
|
|
9
|
+
const renderTooltip = (props: TooltipProps) =>
|
|
10
|
+
render(
|
|
11
|
+
<ThemeProvider theme={themes.dark}>
|
|
12
|
+
<TooltipProvider delayDuration={0}>
|
|
13
|
+
<Tooltip {...props}>
|
|
14
|
+
<Tooltip.Trigger>
|
|
15
|
+
<div>Hover Here</div>
|
|
16
|
+
</Tooltip.Trigger>
|
|
17
|
+
<Tooltip.Content data-testid="tooltip-content">
|
|
18
|
+
Tooltip content
|
|
19
|
+
</Tooltip.Content>
|
|
20
|
+
</Tooltip>
|
|
21
|
+
</TooltipProvider>
|
|
22
|
+
</ThemeProvider>
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
it("should open tooltip on hover", async () => {
|
|
26
|
+
const { getAllByText } = renderTooltip({});
|
|
27
|
+
const TooltipTrigger = getAllByText("Hover Here");
|
|
28
|
+
expect(TooltipTrigger.length).toEqual(1);
|
|
29
|
+
await userEvent.hover(TooltipTrigger[0]);
|
|
30
|
+
expect(getAllByText("Tooltip content")).not.toBeNull();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("should close hover card on pointerLeave", async () => {
|
|
34
|
+
const { getByText, getAllByText, getByTestId } = renderTooltip({});
|
|
35
|
+
const TooltipTrigger = getByText("Hover Here");
|
|
36
|
+
expect(TooltipTrigger).not.toBeNull();
|
|
37
|
+
await userEvent.hover(TooltipTrigger);
|
|
38
|
+
expect(getAllByText("Tooltip content")).not.toBeNull();
|
|
39
|
+
await userEvent.unhover(TooltipTrigger);
|
|
40
|
+
waitFor(() => {
|
|
41
|
+
expect(getByTestId("tooltip-content")).toBeNull();
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|