@clickhouse/click-ui 0.0.2 → 0.0.4
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/dist/click-ui.es.js +15975 -0
- package/dist/click-ui.umd.js +442 -0
- package/package.json +13 -4
- package/.eslintrc.cjs +0 -33
- package/.github/workflows/deployment.yml +0 -34
- package/.prettierrc +0 -14
- package/.storybook/main.ts +0 -19
- package/.storybook/manager.ts +0 -11
- package/.storybook/preview-head.html +0 -2
- package/.storybook/preview.tsx +0 -76
- package/.storybook/theme.ts +0 -16
- package/build-tokens.js +0 -131
- package/index.html +0 -17
- package/jest.config.ts +0 -11
- package/src/App.css +0 -1
- package/src/App.module.css +0 -235
- package/src/App.tsx +0 -217
- package/src/assets/RightArrow/RightArrow.tsx +0 -17
- package/src/assets/S3Logo/S3Logo.tsx +0 -31
- package/src/assets/react.svg +0 -1
- package/src/components/Accordion/Accordion.stories.tsx +0 -28
- package/src/components/Accordion/Accordion.test.tsx +0 -46
- package/src/components/Accordion/Accordion.tsx +0 -119
- package/src/components/Alert/Alert.stories.tsx +0 -14
- package/src/components/Alert/Alert.test.tsx +0 -27
- package/src/components/Alert/Alert.tsx +0 -130
- package/src/components/Avatar/Avatar.stories.tsx +0 -13
- package/src/components/Avatar/Avatar.tsx +0 -64
- package/src/components/Badge/Badge.stories.ts +0 -30
- package/src/components/Badge/Badge.test.tsx +0 -16
- package/src/components/Badge/Badge.tsx +0 -78
- package/src/components/BigStat/BigStat.stories.ts +0 -20
- package/src/components/BigStat/BigStat.tsx +0 -49
- package/src/components/Button/Button.stories.ts +0 -26
- package/src/components/Button/Button.test.tsx +0 -32
- package/src/components/Button/Button.tsx +0 -115
- package/src/components/ButtonGroup/ButtonGroup.stories.ts +0 -14
- package/src/components/ButtonGroup/ButtonGroup.tsx +0 -78
- package/src/components/Card/Card.stories.ts +0 -19
- package/src/components/Card/Card.tsx +0 -107
- package/src/components/Checkbox/Checkbox.stories.tsx +0 -35
- package/src/components/Checkbox/Checkbox.test.tsx +0 -41
- package/src/components/Checkbox/Checkbox.tsx +0 -89
- package/src/components/ContextMenu/ContextMenu.stories.tsx +0 -73
- package/src/components/ContextMenu/ContextMenu.test.tsx +0 -152
- package/src/components/ContextMenu/ContextMenu.tsx +0 -155
- package/src/components/Dropdown/Dropdown.stories.tsx +0 -64
- package/src/components/Dropdown/Dropdown.test.tsx +0 -141
- package/src/components/Dropdown/Dropdown.tsx +0 -149
- package/src/components/FormField/Label.stories.tsx +0 -39
- package/src/components/FormField/Label.tsx +0 -47
- package/src/components/FormField/Select.stories.tsx +0 -48
- package/src/components/FormField/Select.test.tsx +0 -216
- package/src/components/FormField/Select.tsx +0 -574
- package/src/components/FormField/SelectContext.tsx +0 -101
- package/src/components/FormField/commonElement.tsx +0 -42
- package/src/components/GenericMenu.tsx +0 -114
- package/src/components/HoverCard/HoverCard.stories.tsx +0 -64
- package/src/components/HoverCard/HoverCard.test.tsx +0 -85
- package/src/components/HoverCard/HoverCard.tsx +0 -65
- package/src/components/Icon/Icon.stories.ts +0 -15
- package/src/components/Icon/Icon.tsx +0 -238
- package/src/components/Icon/types.ts +0 -95
- package/src/components/IconButton/IconButton.stories.ts +0 -34
- package/src/components/IconButton/IconButton.test.tsx +0 -32
- package/src/components/IconButton/IconButton.tsx +0 -83
- package/src/components/Panel/Panel.stories.tsx +0 -25
- package/src/components/Panel/Panel.tsx +0 -33
- package/src/components/Popover/Popover.stories.tsx +0 -67
- package/src/components/Popover/Popover.test.tsx +0 -46
- package/src/components/Popover/Popover.tsx +0 -115
- package/src/components/RadioGroup/RadioGroup.stories.tsx +0 -43
- package/src/components/RadioGroup/RadioGroup.test.tsx +0 -59
- package/src/components/RadioGroup/RadioGroup.tsx +0 -149
- package/src/components/Separator/Separator.stories.tsx +0 -24
- package/src/components/Separator/Separator.tsx +0 -29
- package/src/components/SidebarNavigationItem/SidebarNavigationItem.stories.tsx +0 -28
- package/src/components/SidebarNavigationItem/SidebarNavigationItem.tsx +0 -112
- package/src/components/Spacer/Spacer.stories.tsx +0 -20
- package/src/components/Spacer/Spacer.tsx +0 -15
- package/src/components/Switch/Switch.stories.ts +0 -14
- package/src/components/Switch/Switch.tsx +0 -107
- package/src/components/Table/Table.stories.tsx +0 -29
- package/src/components/Table/Table.tsx +0 -109
- package/src/components/Tabs/Tabs.stories.tsx +0 -36
- package/src/components/Tabs/Tabs.test.tsx +0 -86
- package/src/components/Tabs/Tabs.tsx +0 -82
- package/src/components/Tooltip/Tooltip.stories.tsx +0 -68
- package/src/components/Tooltip/Tooltip.test.tsx +0 -44
- package/src/components/Tooltip/Tooltip.tsx +0 -67
- package/src/components/Typography/Text/Text.stories.tsx +0 -22
- package/src/components/Typography/Text/Text.test.tsx +0 -16
- package/src/components/Typography/Text/Text.tsx +0 -30
- package/src/components/Typography/Title/Title.stories.tsx +0 -31
- package/src/components/Typography/Title/Title.test.tsx +0 -16
- package/src/components/Typography/Title/Title.tsx +0 -36
- package/src/components/icons/Activity.tsx +0 -30
- package/src/components/icons/ArrowDown.tsx +0 -22
- package/src/components/icons/ArrowRight.tsx +0 -22
- package/src/components/icons/ArrowTriangle.tsx +0 -36
- package/src/components/icons/ArrowUp.tsx +0 -22
- package/src/components/icons/Backups.tsx +0 -29
- package/src/components/icons/Blog.tsx +0 -38
- package/src/components/icons/Book.tsx +0 -30
- package/src/components/icons/Brackets.tsx +0 -22
- package/src/components/icons/Briefcase.tsx +0 -30
- package/src/components/icons/Building.tsx +0 -30
- package/src/components/icons/BurgerMenu.tsx +0 -22
- package/src/components/icons/Cards.tsx +0 -30
- package/src/components/icons/CellTower.tsx +0 -21
- package/src/components/icons/ChatIcon.tsx +0 -22
- package/src/components/icons/CheckIcon.tsx +0 -21
- package/src/components/icons/CheckInCircle.tsx +0 -39
- package/src/components/icons/ChevronDown.tsx +0 -20
- package/src/components/icons/ChevronLeft.tsx +0 -22
- package/src/components/icons/ChevronRight.tsx +0 -20
- package/src/components/icons/ChevronUp.tsx +0 -22
- package/src/components/icons/Clock.tsx +0 -37
- package/src/components/icons/Cloud.tsx +0 -23
- package/src/components/icons/Code.tsx +0 -22
- package/src/components/icons/CodeInSquare.tsx +0 -30
- package/src/components/icons/Connect.tsx +0 -22
- package/src/components/icons/ConnectAlt.tsx +0 -30
- package/src/components/icons/Console.tsx +0 -30
- package/src/components/icons/Copy.tsx +0 -33
- package/src/components/icons/CrossIcon.tsx +0 -29
- package/src/components/icons/Data.tsx +0 -36
- package/src/components/icons/DatabaseIcon.tsx +0 -31
- package/src/components/icons/Disk.tsx +0 -30
- package/src/components/icons/Display.tsx +0 -30
- package/src/components/icons/Document.tsx +0 -30
- package/src/components/icons/DotsHorizontal.tsx +0 -36
- package/src/components/icons/DotsVertical.tsx +0 -33
- package/src/components/icons/Email.tsx +0 -33
- package/src/components/icons/Empty.tsx +0 -14
- package/src/components/icons/FilterIcon.tsx +0 -37
- package/src/components/icons/Fire.tsx +0 -23
- package/src/components/icons/Flags/EuropeanUnion.tsx +0 -174
- package/src/components/icons/Flags/Germany.tsx +0 -25
- package/src/components/icons/Flags/India.tsx +0 -48
- package/src/components/icons/Flags/Ireland.tsx +0 -32
- package/src/components/icons/Flags/Netherlands.tsx +0 -29
- package/src/components/icons/Flags/Singapore.tsx +0 -43
- package/src/components/icons/Flags/UnitedKingdom.tsx +0 -32
- package/src/components/icons/Flags/UnitedStates.tsx +0 -26
- package/src/components/icons/Flags/index.tsx +0 -46
- package/src/components/icons/Folder.tsx +0 -20
- package/src/components/icons/Gift.tsx +0 -21
- package/src/components/icons/HistoryIcon.tsx +0 -28
- package/src/components/icons/Home.tsx +0 -29
- package/src/components/icons/Http.tsx +0 -22
- package/src/components/icons/Icons.mdx +0 -39
- package/src/components/icons/InfoInCircleIcon.tsx +0 -37
- package/src/components/icons/InformationIcon.tsx +0 -34
- package/src/components/icons/InsertRowIcon.tsx +0 -34
- package/src/components/icons/Integrations.tsx +0 -29
- package/src/components/icons/LightBulb.tsx +0 -40
- package/src/components/icons/Lightening.tsx +0 -30
- package/src/components/icons/Loading.tsx +0 -57
- package/src/components/icons/Metrics.tsx +0 -38
- package/src/components/icons/MetricsAlt.tsx +0 -30
- package/src/components/icons/Payment.tsx +0 -23
- package/src/components/icons/Payments/Amex.tsx +0 -44
- package/src/components/icons/Payments/MasterCard.tsx +0 -48
- package/src/components/icons/Payments/Paypal.tsx +0 -41
- package/src/components/icons/Payments/Visa.tsx +0 -36
- package/src/components/icons/Payments/index.tsx +0 -30
- package/src/components/icons/Pencil.tsx +0 -30
- package/src/components/icons/PieChart.tsx +0 -30
- package/src/components/icons/Play.tsx +0 -30
- package/src/components/icons/Plus.tsx +0 -22
- package/src/components/icons/Popout.tsx +0 -22
- package/src/components/icons/PopoverArrow.tsx +0 -22
- package/src/components/icons/Question.tsx +0 -30
- package/src/components/icons/Refresh.tsx +0 -29
- package/src/components/icons/Search.tsx +0 -22
- package/src/components/icons/Secure.tsx +0 -30
- package/src/components/icons/Services.tsx +0 -23
- package/src/components/icons/Settings.tsx +0 -22
- package/src/components/icons/Share.tsx +0 -29
- package/src/components/icons/SlideIn.tsx +0 -28
- package/src/components/icons/SlideOut.tsx +0 -28
- package/src/components/icons/SortAltIcon.tsx +0 -22
- package/src/components/icons/SortIcon.tsx +0 -24
- package/src/components/icons/Sparkle.tsx +0 -23
- package/src/components/icons/Speaker.tsx +0 -30
- package/src/components/icons/Speed.tsx +0 -29
- package/src/components/icons/Star.tsx +0 -23
- package/src/components/icons/Support.tsx +0 -37
- package/src/components/icons/Table.tsx +0 -30
- package/src/components/icons/Taxi.tsx +0 -120
- package/src/components/icons/Trash.tsx +0 -22
- package/src/components/icons/Upload.tsx +0 -29
- package/src/components/icons/Url.tsx +0 -22
- package/src/components/icons/UserIcon.tsx +0 -17
- package/src/components/icons/UsersIcon.tsx +0 -43
- package/src/components/icons/WarningIcon.tsx +0 -30
- package/src/components/index.ts +0 -35
- package/src/components/types.ts +0 -1
- package/src/index.css +0 -9
- package/src/index.ts +0 -2
- package/src/main.tsx +0 -11
- package/src/stories/assets/code-brackets.svg +0 -1
- package/src/stories/assets/colors.svg +0 -1
- package/src/stories/assets/comments.svg +0 -1
- package/src/stories/assets/direction.svg +0 -1
- package/src/stories/assets/flow.svg +0 -1
- package/src/stories/assets/plugin.svg +0 -1
- package/src/stories/assets/repo.svg +0 -1
- package/src/stories/assets/stackalt.svg +0 -1
- package/src/styles/Home.module.css +0 -235
- package/src/styles/globals.css +0 -111
- package/src/styles/types.ts +0 -2089
- package/src/styles/variables.classic.css +0 -16
- package/src/styles/variables.classic.json +0 -202
- package/src/styles/variables.css +0 -763
- package/src/styles/variables.dark.css +0 -135
- package/src/styles/variables.dark.json +0 -894
- package/src/styles/variables.json +0 -2087
- package/src/styles/variables.light.css +0 -203
- package/src/styles/variables.light.json +0 -949
- package/src/theme/index.ts +0 -22
- package/src/theme/theme.tsx +0 -28
- package/src/vite-env.d.ts +0 -1
- package/tokens/themes/$metadata.json +0 -9
- package/tokens/themes/$themes.json +0 -3657
- package/tokens/themes/classic.json +0 -550
- package/tokens/themes/component.json +0 -2252
- package/tokens/themes/dark.json +0 -2563
- package/tokens/themes/light.json +0 -2645
- package/tokens/themes/primitives.json +0 -947
- package/tsconfig.json +0 -27
- package/tsconfig.node.json +0 -10
- package/vite.config.ts +0 -40
- /package/{public → dist}/favicon.ico +0 -0
- /package/{public → dist}/logo.svg +0 -0
- /package/{public → dist}/vite.svg +0 -0
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
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;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { SidebarNavigationItem } from "@/components";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
component: SidebarNavigationItem,
|
|
5
|
-
title: "Display/SidebarNavigationItem",
|
|
6
|
-
tags: ["sidebar", "navigation-item", "autodocs"],
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const Default = {
|
|
10
|
-
args: {
|
|
11
|
-
icon: "user",
|
|
12
|
-
children: <a href="/profile">Profile</a>,
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const Collapsible = {
|
|
17
|
-
args: {
|
|
18
|
-
icon: "user",
|
|
19
|
-
collapsible: true,
|
|
20
|
-
label: "Profile",
|
|
21
|
-
children: (
|
|
22
|
-
<>
|
|
23
|
-
<h2>Content</h2>
|
|
24
|
-
<p>SomeText</p>
|
|
25
|
-
</>
|
|
26
|
-
),
|
|
27
|
-
},
|
|
28
|
-
};
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { Icon } from "@/components";
|
|
2
|
-
import { SidebarAccordion } from "@/components/Accordion/Accordion";
|
|
3
|
-
import { IconName } from "@/components/Icon/types";
|
|
4
|
-
|
|
5
|
-
import styled from "styled-components";
|
|
6
|
-
|
|
7
|
-
interface DefaultSidebarNavigationItemProps
|
|
8
|
-
extends React.HTMLAttributes<HTMLButtonElement> {
|
|
9
|
-
collapsible?: false | undefined | null;
|
|
10
|
-
label?: undefined;
|
|
11
|
-
icon?: IconName;
|
|
12
|
-
children: React.ReactNode;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
interface CollapsibleSidebarNavigationItemProps
|
|
16
|
-
extends React.HTMLAttributes<HTMLButtonElement> {
|
|
17
|
-
collapsible: true;
|
|
18
|
-
label: string;
|
|
19
|
-
icon?: IconName;
|
|
20
|
-
children: React.ReactNode;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type SidebarNavigationItemProps =
|
|
24
|
-
| DefaultSidebarNavigationItemProps
|
|
25
|
-
| CollapsibleSidebarNavigationItemProps;
|
|
26
|
-
|
|
27
|
-
const SidebarNavigationItem = ({
|
|
28
|
-
icon,
|
|
29
|
-
collapsible,
|
|
30
|
-
children,
|
|
31
|
-
label,
|
|
32
|
-
}: SidebarNavigationItemProps) => (
|
|
33
|
-
<>
|
|
34
|
-
{collapsible ? (
|
|
35
|
-
<CollapsibleNavigationItem
|
|
36
|
-
collapsible={collapsible}
|
|
37
|
-
label={label}
|
|
38
|
-
icon={icon}
|
|
39
|
-
children={children}
|
|
40
|
-
/>
|
|
41
|
-
) : (
|
|
42
|
-
<Wrapper>
|
|
43
|
-
<IconsWrapper>
|
|
44
|
-
{/* This icon is only used as a place holder */}
|
|
45
|
-
<Icon name="chevron-right" size="small" visibility="hidden" />
|
|
46
|
-
{icon && <Icon name={icon || "user"} size="small" />}
|
|
47
|
-
</IconsWrapper>
|
|
48
|
-
{children}
|
|
49
|
-
</Wrapper>
|
|
50
|
-
)}
|
|
51
|
-
</>
|
|
52
|
-
);
|
|
53
|
-
const Wrapper = styled.div`
|
|
54
|
-
display: flex;
|
|
55
|
-
align-items: center;
|
|
56
|
-
gap: ${props => props.theme.click.sidebar.navigation.item.default.space.gap};
|
|
57
|
-
|
|
58
|
-
padding: ${props =>
|
|
59
|
-
`${props.theme.click.sidebar.navigation.item.default.space.y} 0`};
|
|
60
|
-
|
|
61
|
-
border-radius: ${props =>
|
|
62
|
-
props.theme.click.sidebar.navigation.item.radii.all};
|
|
63
|
-
font: ${props =>
|
|
64
|
-
props.theme.click.sidebar.navigation.item.typography.default};
|
|
65
|
-
background-color: ${props =>
|
|
66
|
-
props.theme.click.sidebar.navigation.item.color.background.default};
|
|
67
|
-
|
|
68
|
-
&:hover {
|
|
69
|
-
font: ${props =>
|
|
70
|
-
props.theme.click.sidebar.navigation.item.typography.hover};
|
|
71
|
-
background-color: ${props =>
|
|
72
|
-
props.theme.click.sidebar.navigation.item.color.background.hover};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
&:active {
|
|
76
|
-
font: ${props =>
|
|
77
|
-
props.theme.click.sidebar.navigation.item.typography.active};
|
|
78
|
-
background-color: ${props =>
|
|
79
|
-
props.theme.click.sidebar.navigation.item.color.background.active};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
a {
|
|
83
|
-
color: inherit;
|
|
84
|
-
text-decoration: none;
|
|
85
|
-
|
|
86
|
-
&:active {
|
|
87
|
-
color: inherit;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
`;
|
|
91
|
-
const IconsWrapper = styled.div`
|
|
92
|
-
display: flex;
|
|
93
|
-
`;
|
|
94
|
-
const CollapsibleNavigationItem = ({
|
|
95
|
-
collapsible,
|
|
96
|
-
icon,
|
|
97
|
-
label,
|
|
98
|
-
children,
|
|
99
|
-
}: CollapsibleSidebarNavigationItemProps) => (
|
|
100
|
-
<CollapsibleWrapper>
|
|
101
|
-
{label && collapsible && (
|
|
102
|
-
<SidebarAccordion title={label} icon={icon} iconSize="small">
|
|
103
|
-
{children}
|
|
104
|
-
</SidebarAccordion>
|
|
105
|
-
)}
|
|
106
|
-
</CollapsibleWrapper>
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
const CollapsibleWrapper = styled(Wrapper)`
|
|
110
|
-
padding-left: 0;
|
|
111
|
-
`;
|
|
112
|
-
export { SidebarNavigationItem };
|
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
);
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import * as RadixSwitch from "@radix-ui/react-switch";
|
|
2
|
-
import styled, { DefaultTheme } from "styled-components";
|
|
3
|
-
|
|
4
|
-
interface SwitchProps extends RadixSwitch.SwitchProps {
|
|
5
|
-
checked: boolean;
|
|
6
|
-
disabled?: boolean;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
interface RootProps {
|
|
10
|
-
checked: boolean;
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface ThumbProps {
|
|
15
|
-
checked: boolean;
|
|
16
|
-
disabled?: boolean;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function Switch({ checked, disabled, ...props }: SwitchProps) {
|
|
20
|
-
return (
|
|
21
|
-
<SwitchRoot disabled={disabled} checked={checked} {...props}>
|
|
22
|
-
<SwitchThumb checked={checked} />
|
|
23
|
-
</SwitchRoot>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function getRootVars(
|
|
28
|
-
theme: any,
|
|
29
|
-
disabled: boolean | undefined,
|
|
30
|
-
checked: boolean
|
|
31
|
-
) {
|
|
32
|
-
const baseVars = {};
|
|
33
|
-
|
|
34
|
-
if (disabled) {
|
|
35
|
-
return {
|
|
36
|
-
...baseVars,
|
|
37
|
-
backgroundColor: theme.click.switch.color.background.disabled,
|
|
38
|
-
border: `1px solid ${theme.click.switch.color.stroke.disabled}`,
|
|
39
|
-
};
|
|
40
|
-
} else if (checked) {
|
|
41
|
-
return {
|
|
42
|
-
...baseVars,
|
|
43
|
-
backgroundColor: theme.click.switch.color.background.active,
|
|
44
|
-
border: `1px solid ${theme.click.switch.color.stroke.active}`,
|
|
45
|
-
};
|
|
46
|
-
} else {
|
|
47
|
-
return {
|
|
48
|
-
...baseVars,
|
|
49
|
-
backgroundColor: theme.click.switch.color.background.default,
|
|
50
|
-
border: `1px solid ${theme.click.switch.color.stroke.default}`,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function getThumbVars(
|
|
56
|
-
theme: DefaultTheme,
|
|
57
|
-
disabled: boolean | undefined,
|
|
58
|
-
checked: boolean
|
|
59
|
-
) {
|
|
60
|
-
const baseVars = {};
|
|
61
|
-
|
|
62
|
-
if (disabled) {
|
|
63
|
-
return {
|
|
64
|
-
...baseVars,
|
|
65
|
-
backgroundColor: theme.click.switch.color.indicator.disabled,
|
|
66
|
-
};
|
|
67
|
-
} else if (checked) {
|
|
68
|
-
return {
|
|
69
|
-
...baseVars,
|
|
70
|
-
backgroundColor: theme.click.switch.color.indicator.active,
|
|
71
|
-
};
|
|
72
|
-
} else {
|
|
73
|
-
return {
|
|
74
|
-
...baseVars,
|
|
75
|
-
backgroundColor: theme.click.switch.color.indicator.default,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const SwitchRoot = styled(RadixSwitch.Root)<RootProps>((props) => {
|
|
81
|
-
const vars = getRootVars(props.theme, props.disabled, props.checked);
|
|
82
|
-
|
|
83
|
-
return {
|
|
84
|
-
width: props.theme.click.switch.size.width,
|
|
85
|
-
height: props.theme.click.switch.size.height,
|
|
86
|
-
backgroundColor: vars.backgroundColor,
|
|
87
|
-
border: vars.border,
|
|
88
|
-
borderRadius: props.theme.click.switch.radii.all,
|
|
89
|
-
position: "relative",
|
|
90
|
-
padding: 0,
|
|
91
|
-
};
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
const SwitchThumb = styled(RadixSwitch.Thumb)<ThumbProps>((props) => {
|
|
95
|
-
const vars = getThumbVars(props.theme, props.disabled, props.checked);
|
|
96
|
-
|
|
97
|
-
return {
|
|
98
|
-
display: "block",
|
|
99
|
-
width: "12px",
|
|
100
|
-
height: "12px",
|
|
101
|
-
backgroundColor: vars.backgroundColor,
|
|
102
|
-
borderRadius: props.theme.click.switch.radii.all,
|
|
103
|
-
transition: "transform 100ms",
|
|
104
|
-
transform: props.checked ? "translateX(15px)" : "translateX(2px)",
|
|
105
|
-
willChange: "transform",
|
|
106
|
-
};
|
|
107
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,109 +0,0 @@
|
|
|
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 };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Tabs } from "@/components";
|
|
2
|
-
import type { StoryObj } from "@storybook/react";
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
component: Tabs,
|
|
6
|
-
title: "Display/Tabs",
|
|
7
|
-
tags: ["tabs", "autodocs"],
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
type Story = StoryObj<typeof Tabs>;
|
|
11
|
-
|
|
12
|
-
export const Default: Story = {
|
|
13
|
-
args: {
|
|
14
|
-
defaultValue: "tab2",
|
|
15
|
-
onValueChange: s => console.log(s),
|
|
16
|
-
ariaLabel: "a simple tab component",
|
|
17
|
-
children: (
|
|
18
|
-
<>
|
|
19
|
-
<Tabs.TriggersList>
|
|
20
|
-
<Tabs.Trigger value="tab1" key="tab1">
|
|
21
|
-
tab1
|
|
22
|
-
</Tabs.Trigger>
|
|
23
|
-
<Tabs.Trigger value="tab2" key="tab2">
|
|
24
|
-
tab2
|
|
25
|
-
</Tabs.Trigger>
|
|
26
|
-
<Tabs.Trigger value="tab3" key="tab3">
|
|
27
|
-
tab3
|
|
28
|
-
</Tabs.Trigger>
|
|
29
|
-
</Tabs.TriggersList>
|
|
30
|
-
<Tabs.Content value="tab1">Tab 1 content</Tabs.Content>
|
|
31
|
-
<Tabs.Content value="tab2">Tab 2 content</Tabs.Content>
|
|
32
|
-
<Tabs.Content value="tab3">Tab 3 content</Tabs.Content>
|
|
33
|
-
</>
|
|
34
|
-
),
|
|
35
|
-
},
|
|
36
|
-
};
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { ThemeProvider } from "../../theme";
|
|
2
|
-
import { render, waitFor } from "@testing-library/react";
|
|
3
|
-
import userEvent from "@testing-library/user-event";
|
|
4
|
-
import { Tabs } from "./Tabs";
|
|
5
|
-
import { TabsProps } from "@/components/Tabs/Tabs";
|
|
6
|
-
|
|
7
|
-
describe("Tabs", () => {
|
|
8
|
-
const renderTabs = (props: TabsProps) =>
|
|
9
|
-
render(
|
|
10
|
-
<ThemeProvider theme="dark">
|
|
11
|
-
<Tabs {...props} />
|
|
12
|
-
</ThemeProvider>
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
it("should render the Tabs", () => {
|
|
16
|
-
const { getByText } = renderTabs({
|
|
17
|
-
children: <p>Common text</p>,
|
|
18
|
-
defaultValue: "1",
|
|
19
|
-
});
|
|
20
|
-
expect(getByText("Common text").textContent).toBe("Common text");
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("should switch between tabs", () => {
|
|
24
|
-
const { getByText } = renderTabs({
|
|
25
|
-
defaultValue: "tab1",
|
|
26
|
-
ariaLabel: "Tabs",
|
|
27
|
-
children: (
|
|
28
|
-
<>
|
|
29
|
-
<Tabs.TriggersList>
|
|
30
|
-
<Tabs.Trigger value="tab1" key="tab1">
|
|
31
|
-
tab1
|
|
32
|
-
</Tabs.Trigger>
|
|
33
|
-
<Tabs.Trigger value="tab2" key="tab2">
|
|
34
|
-
tab2
|
|
35
|
-
</Tabs.Trigger>
|
|
36
|
-
<Tabs.Trigger value="tab3" key="tab3">
|
|
37
|
-
tab3
|
|
38
|
-
</Tabs.Trigger>
|
|
39
|
-
</Tabs.TriggersList>
|
|
40
|
-
<Tabs.Content value="tab1">Tab 1 content</Tabs.Content>
|
|
41
|
-
<Tabs.Content value="tab2">Tab 2 content</Tabs.Content>
|
|
42
|
-
<Tabs.Content value="tab3">Tab 3 content</Tabs.Content>
|
|
43
|
-
</>
|
|
44
|
-
),
|
|
45
|
-
});
|
|
46
|
-
[1, 2, 3].forEach(async n => {
|
|
47
|
-
const tab = getByText(`tab${n}`);
|
|
48
|
-
userEvent.click(tab);
|
|
49
|
-
await waitFor(() => {
|
|
50
|
-
const content = getByText(`Tab ${n} content`);
|
|
51
|
-
expect(content.textContent).toEqual(`Tab ${n} content`);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it("should execute callback on value change", async () => {
|
|
57
|
-
let counter = 0;
|
|
58
|
-
const { getByText } = renderTabs({
|
|
59
|
-
onValueChange: () => counter++,
|
|
60
|
-
children: (
|
|
61
|
-
<>
|
|
62
|
-
<Tabs.TriggersList>
|
|
63
|
-
<Tabs.Trigger value="tab1" key="tab1">
|
|
64
|
-
tab1
|
|
65
|
-
</Tabs.Trigger>
|
|
66
|
-
<Tabs.Trigger value="tab2" key="tab2">
|
|
67
|
-
tab2
|
|
68
|
-
</Tabs.Trigger>
|
|
69
|
-
<Tabs.Trigger value="tab3" key="tab3">
|
|
70
|
-
tab3
|
|
71
|
-
</Tabs.Trigger>
|
|
72
|
-
</Tabs.TriggersList>
|
|
73
|
-
<Tabs.Content value="tab1">Tab 1 content</Tabs.Content>
|
|
74
|
-
<Tabs.Content value="tab2">Tab 2 content</Tabs.Content>
|
|
75
|
-
<Tabs.Content value="tab3">Tab 3 content</Tabs.Content>
|
|
76
|
-
</>
|
|
77
|
-
),
|
|
78
|
-
defaultValue: "tab1",
|
|
79
|
-
});
|
|
80
|
-
const tab = getByText("tab2");
|
|
81
|
-
userEvent.click(tab);
|
|
82
|
-
await waitFor(() => {
|
|
83
|
-
expect(counter).toEqual(1);
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
});
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import * as RadixTabs from "@radix-ui/react-tabs";
|
|
2
|
-
import styled from "styled-components";
|
|
3
|
-
|
|
4
|
-
export type TabProps = {
|
|
5
|
-
label: React.ReactNode;
|
|
6
|
-
value: string;
|
|
7
|
-
children?: React.ReactNode;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export type TabsProps = {
|
|
11
|
-
defaultValue?: string;
|
|
12
|
-
ariaLabel?: string;
|
|
13
|
-
onValueChange?: (s: string) => unknown;
|
|
14
|
-
children: React.ReactElement<TabProps>[] | React.ReactElement<TabProps>;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const Trigger = styled(RadixTabs.Trigger)`
|
|
18
|
-
border: none;
|
|
19
|
-
padding: ${props =>
|
|
20
|
-
`${props.theme.click.tabs.space.y} ${props.theme.click.tabs.space.x}`};
|
|
21
|
-
|
|
22
|
-
border-top-left-radius: ${props => props.theme.click.tabs.radii.all};
|
|
23
|
-
border-top-right-radius: ${props => props.theme.click.tabs.radii.all};
|
|
24
|
-
|
|
25
|
-
border-bottom: ${props => props.theme.click.tabs.basic.stroke.default};
|
|
26
|
-
background-color: ${props =>
|
|
27
|
-
props.theme.click.tabs.basic.color.background.default};
|
|
28
|
-
color: ${props => props.theme.click.tabs.basic.color.text.default};
|
|
29
|
-
font: ${props => props.theme.click.tabs.typography.label.default};
|
|
30
|
-
cursor: pointer;
|
|
31
|
-
|
|
32
|
-
&[data-state="active"] {
|
|
33
|
-
border-bottom: ${props => props.theme.click.tabs.basic.stroke.active};
|
|
34
|
-
background-color: ${props =>
|
|
35
|
-
props.theme.click.tabs.basic.color.background.active};
|
|
36
|
-
color: ${props => props.theme.click.tabs.basic.color.text.active};
|
|
37
|
-
font: ${props => props.theme.click.tabs.typography.label.active};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
&:hover {
|
|
41
|
-
border-bottom: ${props => props.theme.click.tabs.basic.stroke.hover};
|
|
42
|
-
background-color: ${props =>
|
|
43
|
-
props.theme.click.tabs.basic.color.background.hover};
|
|
44
|
-
color: ${props => props.theme.click.tabs.basic.color.text.hover};
|
|
45
|
-
font: ${props => props.theme.click.tabs.typography.label.hover};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
&:hover[data-state="active"] {
|
|
49
|
-
border-bottom: ${props => props.theme.click.tabs.basic.stroke.active};
|
|
50
|
-
}
|
|
51
|
-
`;
|
|
52
|
-
|
|
53
|
-
const Content = styled(RadixTabs.Content)``;
|
|
54
|
-
|
|
55
|
-
const TriggersList = styled(RadixTabs.List)`
|
|
56
|
-
border-bottom: ${props => props.theme.click.tabs.basic.stroke.global};
|
|
57
|
-
`;
|
|
58
|
-
|
|
59
|
-
const Tabs = ({
|
|
60
|
-
defaultValue,
|
|
61
|
-
children,
|
|
62
|
-
ariaLabel,
|
|
63
|
-
onValueChange,
|
|
64
|
-
...delegated
|
|
65
|
-
}: TabsProps) => {
|
|
66
|
-
return (
|
|
67
|
-
<RadixTabs.Root
|
|
68
|
-
aria-label={ariaLabel}
|
|
69
|
-
defaultValue={defaultValue}
|
|
70
|
-
onValueChange={onValueChange}
|
|
71
|
-
{...delegated}
|
|
72
|
-
>
|
|
73
|
-
{children}
|
|
74
|
-
</RadixTabs.Root>
|
|
75
|
-
);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
Tabs.TriggersList = TriggersList;
|
|
79
|
-
Tabs.Trigger = Trigger;
|
|
80
|
-
Tabs.Content = Content;
|
|
81
|
-
|
|
82
|
-
export { Tabs };
|