@clickhouse/click-ui 0.0.0
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 +32 -0
- package/.github/workflows/deployment.yml +34 -0
- package/.storybook/main.ts +18 -0
- package/.storybook/preview-head.html +4 -0
- package/.storybook/preview.tsx +67 -0
- package/README.md +11 -0
- package/app/.babelrc +27 -0
- package/app/.eslintrc.json +6 -0
- package/app/.storybook/main.ts +17 -0
- package/app/.storybook/preview.tsx +26 -0
- package/app/README.md +38 -0
- package/app/next.config.js +6 -0
- package/app/package-lock.json +28711 -0
- package/app/package.json +44 -0
- package/app/public/favicon.ico +0 -0
- package/app/public/next.svg +1 -0
- package/app/public/vercel.svg +1 -0
- package/app/src/assets/RightArrow/right-arrow.tsx +17 -0
- package/app/src/assets/S3Logo/s3-logo.tsx +31 -0
- package/app/src/assets/amazon_s3.svg +9 -0
- package/app/src/assets/arrow.svg +3 -0
- package/app/src/globals.d.ts +4 -0
- package/app/src/pages/_app.tsx +8 -0
- package/app/src/pages/_document.tsx +17 -0
- package/app/src/pages/api/hello.ts +13 -0
- package/app/src/pages/index.tsx +141 -0
- package/app/src/pages/label.tsx +27 -0
- package/app/src/stories/assets/code-brackets.svg +1 -0
- package/app/src/stories/assets/colors.svg +1 -0
- package/app/src/stories/assets/comments.svg +1 -0
- package/app/src/stories/assets/direction.svg +1 -0
- package/app/src/stories/assets/flow.svg +1 -0
- package/app/src/stories/assets/plugin.svg +1 -0
- package/app/src/stories/assets/repo.svg +1 -0
- package/app/src/stories/assets/stackalt.svg +1 -0
- package/app/src/styles/Home.module.css +235 -0
- package/app/src/styles/globals.css +111 -0
- package/app/src/styles/types.ts +1031 -0
- package/app/src/styles/variables.classic.css +16 -0
- package/app/src/styles/variables.classic.json +31 -0
- package/app/src/styles/variables.css +763 -0
- package/app/src/styles/variables.dark.css +135 -0
- package/app/src/styles/variables.dark.json +339 -0
- package/app/src/styles/variables.json +1029 -0
- package/app/src/styles/variables.light.css +203 -0
- package/app/src/styles/variables.light.json +478 -0
- package/app/tokens/themes/$metadata.json +9 -0
- package/app/tokens/themes/$themes.json +1 -0
- package/app/tokens/themes/classic.json +58 -0
- package/app/tokens/themes/component.json +868 -0
- package/app/tokens/themes/dark.json +937 -0
- package/app/tokens/themes/light.json +1380 -0
- package/app/tokens/themes/primitives.json +859 -0
- package/app/tsconfig.json +23 -0
- package/build-tokens.js +131 -0
- package/index.html +17 -0
- package/jest.config.ts +11 -0
- package/package.json +77 -0
- package/public/vite.svg +1 -0
- package/src/App.css +1 -0
- package/src/App.module.css +235 -0
- package/src/App.tsx +154 -0
- package/src/assets/RightArrow/RightArrow.tsx +17 -0
- package/src/assets/S3Logo/S3Logo.tsx +31 -0
- package/src/assets/react.svg +1 -0
- package/src/components/Accordion/Accordion.stories.tsx +78 -0
- package/src/components/Accordion/Accordion.test.tsx +46 -0
- package/src/components/Accordion/Accordion.tsx +118 -0
- package/src/components/Badge/Badge.stories.ts +14 -0
- package/src/components/Badge/Badge.test.tsx +11 -0
- package/src/components/Badge/Badge.tsx +24 -0
- package/src/components/BigStat/BigStat.stories.ts +15 -0
- package/src/components/BigStat/BigStat.tsx +37 -0
- package/src/components/Button/Button.stories.ts +82 -0
- package/src/components/Button/Button.test.tsx +32 -0
- package/src/components/Button/Button.tsx +97 -0
- package/src/components/ButtonGroup/ButtonGroup.stories.ts +14 -0
- package/src/components/ButtonGroup/ButtonGroup.tsx +78 -0
- package/src/components/Card/Card.stories.ts +19 -0
- package/src/components/Card/Card.tsx +107 -0
- package/src/components/FormField/FormField.stories.ts +14 -0
- package/src/components/FormField/FormField.tsx +22 -0
- package/src/components/Icon/Icon.stories.ts +46 -0
- package/src/components/Icon/Icon.tsx +90 -0
- package/src/components/Icon/types.ts +18 -0
- package/src/components/IconButton/IconButton.stories.ts +16 -0
- package/src/components/IconButton/IconButton.tsx +94 -0
- package/src/components/SidebarNavigationItem/SidebarNavigationItem.stories.tsx +28 -0
- package/src/components/SidebarNavigationItem/SidebarNavigationItem.tsx +112 -0
- package/src/components/Switch/Switch.stories.ts +14 -0
- package/src/components/Switch/Switch.tsx +106 -0
- package/src/components/Tabs/Tabs.stories.tsx +71 -0
- package/src/components/Tabs/Tabs.test.tsx +86 -0
- package/src/components/Tabs/Tabs.tsx +82 -0
- package/src/components/icons/ChatIcon.tsx +22 -0
- package/src/components/icons/ChevronDown.tsx +6 -0
- package/src/components/icons/ChevronRight.tsx +20 -0
- package/src/components/icons/DatabaseIcon.tsx +33 -0
- package/src/components/icons/FilterIcon.tsx +24 -0
- package/src/components/icons/Flags/EuropeanUnion.tsx +174 -0
- package/src/components/icons/Flags/Germany.tsx +25 -0
- package/src/components/icons/Flags/India.tsx +48 -0
- package/src/components/icons/Flags/Ireland.tsx +32 -0
- package/src/components/icons/Flags/Netherlands.tsx +29 -0
- package/src/components/icons/Flags/Singapore.tsx +43 -0
- package/src/components/icons/Flags/UnitedKingdom.tsx +32 -0
- package/src/components/icons/Flags/UnitedStates.tsx +26 -0
- package/src/components/icons/Flags/index.tsx +46 -0
- package/src/components/icons/HistoryIcon.tsx +28 -0
- package/src/components/icons/Icons.mdx +36 -0
- package/src/components/icons/InsertRowIcon.tsx +36 -0
- package/src/components/icons/SortAltIcon.tsx +24 -0
- package/src/components/icons/UserIcon.tsx +17 -0
- package/src/components/icons/UsersIcon.tsx +43 -0
- package/src/components/index.ts +14 -0
- package/src/components/types.ts +1 -0
- package/src/index.css +9 -0
- package/src/index.ts +2 -0
- package/src/main.tsx +11 -0
- package/src/stories/assets/code-brackets.svg +1 -0
- package/src/stories/assets/colors.svg +1 -0
- package/src/stories/assets/comments.svg +1 -0
- package/src/stories/assets/direction.svg +1 -0
- package/src/stories/assets/flow.svg +1 -0
- package/src/stories/assets/plugin.svg +1 -0
- package/src/stories/assets/repo.svg +1 -0
- package/src/stories/assets/stackalt.svg +1 -0
- package/src/styles/Home.module.css +235 -0
- package/src/styles/globals.css +111 -0
- package/src/styles/types.ts +1669 -0
- package/src/styles/variables.classic.css +16 -0
- package/src/styles/variables.classic.json +31 -0
- package/src/styles/variables.css +763 -0
- package/src/styles/variables.dark.css +135 -0
- package/src/styles/variables.dark.json +576 -0
- package/src/styles/variables.json +1667 -0
- package/src/styles/variables.light.css +203 -0
- package/src/styles/variables.light.json +789 -0
- package/src/theme/index.ts +22 -0
- package/src/theme/theme.tsx +28 -0
- package/src/vite-env.d.ts +1 -0
- package/tokens/themes/$metadata.json +9 -0
- package/tokens/themes/$themes.json +1 -0
- package/tokens/themes/classic.json +58 -0
- package/tokens/themes/component.json +1567 -0
- package/tokens/themes/dark.json +1450 -0
- package/tokens/themes/light.json +2059 -0
- package/tokens/themes/primitives.json +863 -0
- package/tsconfig.json +27 -0
- package/tsconfig.node.json +10 -0
- package/vite.config.ts +38 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Accordion } from "./Accordion";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
component: Accordion,
|
|
5
|
+
title: "Accordion",
|
|
6
|
+
tags: ["accordion"],
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const children = (
|
|
10
|
+
<div style={{ padding: "8px", border: "1px solid #f1f1f1" }}>
|
|
11
|
+
<h2>Content</h2>
|
|
12
|
+
<p>
|
|
13
|
+
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
|
|
14
|
+
Lorem Ipsum has been the industry's standard Lorem Ipsum is simply dummy
|
|
15
|
+
text of the printing and typesetting industry. Lorem Ipsum has been the
|
|
16
|
+
industry's standard Lorem Ipsum is simply dummy text of the printing and
|
|
17
|
+
typesetting industry. Lorem Ipsum has been the industry's standard
|
|
18
|
+
</p>
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
export const Default = {
|
|
22
|
+
args: {
|
|
23
|
+
title: "Accordion title",
|
|
24
|
+
size: "medium",
|
|
25
|
+
children,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const Icon = {
|
|
30
|
+
args: {
|
|
31
|
+
title: "Accordion title",
|
|
32
|
+
size: "medium",
|
|
33
|
+
icon: "user",
|
|
34
|
+
children,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const Large = {
|
|
39
|
+
args: {
|
|
40
|
+
title: "Accordion title",
|
|
41
|
+
size: "large",
|
|
42
|
+
children,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const Small = {
|
|
47
|
+
args: {
|
|
48
|
+
title: "Accordion title",
|
|
49
|
+
size: "small",
|
|
50
|
+
children,
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const Hover = {
|
|
55
|
+
args: {
|
|
56
|
+
title: "Accordion title",
|
|
57
|
+
size: "large",
|
|
58
|
+
children,
|
|
59
|
+
},
|
|
60
|
+
parameters: {
|
|
61
|
+
pseudo: {
|
|
62
|
+
hover: true,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const Active = {
|
|
68
|
+
args: {
|
|
69
|
+
title: "Accordion title",
|
|
70
|
+
size: "large",
|
|
71
|
+
children,
|
|
72
|
+
},
|
|
73
|
+
parameters: {
|
|
74
|
+
pseudo: {
|
|
75
|
+
active: true,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { render, fireEvent } from "@testing-library/react";
|
|
2
|
+
import { Accordion } from "./Accordion";
|
|
3
|
+
import { ThemeProvider } from "styled-components";
|
|
4
|
+
import { themes } from "../../theme";
|
|
5
|
+
|
|
6
|
+
interface RenderAccordionProps {
|
|
7
|
+
title: string;
|
|
8
|
+
content?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
describe("Accordion", () => {
|
|
12
|
+
const renderAccordion = ({ title, content }: RenderAccordionProps) =>
|
|
13
|
+
render(
|
|
14
|
+
<ThemeProvider theme={themes.dark}>
|
|
15
|
+
<Accordion title={title}>
|
|
16
|
+
<div>{content}</div>
|
|
17
|
+
</Accordion>
|
|
18
|
+
</ThemeProvider>
|
|
19
|
+
);
|
|
20
|
+
it("given no arguments, should render the accordion", () => {
|
|
21
|
+
const title = "Test accordion";
|
|
22
|
+
const rendered = renderAccordion({ title });
|
|
23
|
+
|
|
24
|
+
const accordion = rendered.getByText(title);
|
|
25
|
+
expect(accordion).toBeTruthy;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("given a title, should render the accordion's title", () => {
|
|
29
|
+
const title = "Test title";
|
|
30
|
+
const rendered = renderAccordion({ title });
|
|
31
|
+
|
|
32
|
+
const accordion = rendered.getByText(title);
|
|
33
|
+
expect(accordion.textContent).toEqual(title);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("given some content, should render the content when clicked", () => {
|
|
37
|
+
const content = "Accordion content";
|
|
38
|
+
const title = "Test title";
|
|
39
|
+
const rendered = renderAccordion({ title, content });
|
|
40
|
+
|
|
41
|
+
const accordion = rendered.getByText(title);
|
|
42
|
+
fireEvent.click(accordion);
|
|
43
|
+
const accordionContent = rendered.getByText(content);
|
|
44
|
+
expect(accordionContent.textContent).toEqual(content);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import * as RadixAccordion from "@radix-ui/react-accordion";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import { IconName } from "@/components/Icon/types";
|
|
4
|
+
import { Icon } from "@/components";
|
|
5
|
+
|
|
6
|
+
type Size = "small" | "medium" | "large";
|
|
7
|
+
export interface AccordionProps extends SizeProp {
|
|
8
|
+
title: string;
|
|
9
|
+
icon?: IconName;
|
|
10
|
+
iconSize?: Size;
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface TriggerProps extends RadixAccordion.AccordionTriggerProps, SizeProp {}
|
|
15
|
+
interface SizeProp {
|
|
16
|
+
size?: Size;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const Accordion = ({
|
|
20
|
+
title,
|
|
21
|
+
size = "medium",
|
|
22
|
+
icon,
|
|
23
|
+
iconSize,
|
|
24
|
+
children,
|
|
25
|
+
...delegated
|
|
26
|
+
}: AccordionProps) => (
|
|
27
|
+
<AccordionRoot type="single" collapsible {...delegated}>
|
|
28
|
+
<AccordionItem value="item">
|
|
29
|
+
<AccordionTrigger size={size}>
|
|
30
|
+
<AccordionIconsWrapper>
|
|
31
|
+
<AccordionIconWrapper>
|
|
32
|
+
<Icon name="chevron-right" size={iconSize || size} />
|
|
33
|
+
</AccordionIconWrapper>
|
|
34
|
+
{icon ? <Icon name={icon} size={iconSize || size} /> : null}
|
|
35
|
+
</AccordionIconsWrapper>
|
|
36
|
+
<p>{title}</p>
|
|
37
|
+
</AccordionTrigger>
|
|
38
|
+
<AccordionContent>{children}</AccordionContent>
|
|
39
|
+
</AccordionItem>
|
|
40
|
+
</AccordionRoot>
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const AccordionRoot = styled(RadixAccordion.Root)``;
|
|
44
|
+
|
|
45
|
+
const AccordionItem = styled(RadixAccordion.Item)``;
|
|
46
|
+
|
|
47
|
+
const AccordionTrigger = styled(RadixAccordion.Trigger)<TriggerProps>`
|
|
48
|
+
border: none;
|
|
49
|
+
padding: 0;
|
|
50
|
+
background-color: transparent;
|
|
51
|
+
display: flex;
|
|
52
|
+
align-items: center;
|
|
53
|
+
gap: ${props =>
|
|
54
|
+
props.theme.click.accordion[props.size || "medium"].space.gap};
|
|
55
|
+
|
|
56
|
+
color: ${props => props.theme.click.accordion.color.label.default};
|
|
57
|
+
font: ${props =>
|
|
58
|
+
props.theme.click.accordion[props.size || "medium"].typography.label
|
|
59
|
+
.default};
|
|
60
|
+
|
|
61
|
+
&:active {
|
|
62
|
+
color: ${props => props.theme.click.accordion.color.label.active};
|
|
63
|
+
font: ${props =>
|
|
64
|
+
props.theme.click.accordion[props.size || "medium"].typography.label
|
|
65
|
+
.active};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&:hover {
|
|
69
|
+
color: ${props => props.theme.click.accordion.color.label.hover};
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
72
|
+
|
|
73
|
+
const AccordionIconWrapper = styled.div`
|
|
74
|
+
display: flex;
|
|
75
|
+
align-items: center;
|
|
76
|
+
justify-content: center;
|
|
77
|
+
transition: transform 200ms cubic-bezier(0.87, 0, 0.13, 1);
|
|
78
|
+
|
|
79
|
+
${AccordionTrigger}[data-state='open'] & {
|
|
80
|
+
transform: rotate(90deg);
|
|
81
|
+
}
|
|
82
|
+
`;
|
|
83
|
+
const AccordionIconsWrapper = styled.div`
|
|
84
|
+
display: flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
justify-content: center;
|
|
87
|
+
`;
|
|
88
|
+
|
|
89
|
+
const AccordionContent = styled(RadixAccordion.Content)``;
|
|
90
|
+
|
|
91
|
+
const SidebarAccordion = styled(Accordion)`
|
|
92
|
+
${AccordionTrigger} {
|
|
93
|
+
gap: ${props =>
|
|
94
|
+
props.theme.click.sidebar.navigation.item.default.space.gap};
|
|
95
|
+
}
|
|
96
|
+
p {
|
|
97
|
+
margin: 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
${AccordionIconWrapper} {
|
|
101
|
+
visibility: hidden;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
&:hover ${AccordionIconWrapper} {
|
|
105
|
+
visibility: revert;
|
|
106
|
+
}
|
|
107
|
+
&:active ${AccordionIconWrapper} {
|
|
108
|
+
visibility: revert;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
${AccordionTrigger}[data-state='open'] ${AccordionIconWrapper} {
|
|
112
|
+
visibility: revert;
|
|
113
|
+
}
|
|
114
|
+
`;
|
|
115
|
+
// This allows the Accordion to be referenced inside other
|
|
116
|
+
// components css
|
|
117
|
+
const AccordionToExport = styled(Accordion)``;
|
|
118
|
+
export { AccordionToExport as Accordion, SidebarAccordion };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { render } from "@testing-library/react";
|
|
2
|
+
import { Badge } from "./Badge";
|
|
3
|
+
|
|
4
|
+
describe("Badge", () => {
|
|
5
|
+
test("given a text, should render it", () => {
|
|
6
|
+
const text = "text to render";
|
|
7
|
+
const rendered = render(<Badge text={text} />);
|
|
8
|
+
|
|
9
|
+
expect(rendered.getByText(text).textContent).toEqual(text);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
|
|
3
|
+
export type BadgeState = "default" | "success" | "neutral" | "danger" | "disabled";
|
|
4
|
+
|
|
5
|
+
export interface BadgeProps {
|
|
6
|
+
text: string;
|
|
7
|
+
state?: BadgeState;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const Wrapper = styled.div<Pick<BadgeProps, "state">>`
|
|
11
|
+
background-color: ${({state}) => `var(--click-badge-color-background-${state})`};
|
|
12
|
+
color: ${({state}) => `var(--click-badge-color-text-${state})`};
|
|
13
|
+
font: var(--click-badge-typography-label-default);
|
|
14
|
+
border-radius: var(--click-badge-radii-all);
|
|
15
|
+
border: ${({state}) => `var(--sizes-1) solid var(--click-badge-color-stroke-${state})`};
|
|
16
|
+
padding: var(--click-badge-space-y) var(--click-badge-space-x);
|
|
17
|
+
|
|
18
|
+
display: inline-block;
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
export function Badge({text, state = "default"}: BadgeProps) {
|
|
22
|
+
return <Wrapper state={state}>{text}</Wrapper>
|
|
23
|
+
}
|
|
24
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BigStat } from "./BigStat";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
component: BigStat,
|
|
5
|
+
title: "Big Stat",
|
|
6
|
+
tags: ["big-stat"],
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const Default = {
|
|
10
|
+
args: {
|
|
11
|
+
label: "big stat label",
|
|
12
|
+
largeValue: "Big Stat",
|
|
13
|
+
state: "default",
|
|
14
|
+
},
|
|
15
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
|
|
3
|
+
export type bigStatState = "default";
|
|
4
|
+
|
|
5
|
+
export interface BigStatProps {
|
|
6
|
+
label: string;
|
|
7
|
+
largeValue: string;
|
|
8
|
+
state?: bigStatState;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const Wrapper = styled.div<Pick<BigStatProps, "state">>`
|
|
12
|
+
background-color: ${({state}) => `var(--click-big-stat-color-background-${state})`};
|
|
13
|
+
border-radius: var(--click-big-stat-radii-all);
|
|
14
|
+
border: ${({state}) => `var(--click-big-stat-stroke) solid var(--click-big-stat-color-stroke-${state})`};
|
|
15
|
+
gap: var(--click-big-stat-space-gap);
|
|
16
|
+
padding: var(--click-big-stat-space-all);
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
const Label = styled.div<Pick<BigStatProps, "state">>`
|
|
22
|
+
color: ${({state}) => `var(--click-big-stat-color-label-${state})`};
|
|
23
|
+
font: ${({state}) => `var(--click-big-stat-typography-label-${state})`};
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
const LargeValue = styled.div<Pick<BigStatProps, "state">>`
|
|
27
|
+
color: ${({state}) => `var(--click-big-stat-color-large-value-${state})`};
|
|
28
|
+
font: ${({state}) => `var(--click-big-stat-typography-title-${state})`};
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
export function BigStat({label, largeValue, state = "default"}: BigStatProps) {
|
|
32
|
+
return <Wrapper state={state}>
|
|
33
|
+
<Label state={state}>{label}</Label>
|
|
34
|
+
<LargeValue state={state}>{largeValue}</LargeValue>
|
|
35
|
+
</Wrapper>
|
|
36
|
+
}
|
|
37
|
+
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Button } from "./Button";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
component: Button,
|
|
5
|
+
title: "Button",
|
|
6
|
+
tags: ["button"],
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const Primary = {
|
|
10
|
+
args: {
|
|
11
|
+
type: "primary",
|
|
12
|
+
disabled: false,
|
|
13
|
+
label: "Button",
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const Secondary = {
|
|
18
|
+
args: {
|
|
19
|
+
type: "secondary",
|
|
20
|
+
disabled: false,
|
|
21
|
+
label: "Button",
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const Hover = {
|
|
26
|
+
args: {
|
|
27
|
+
type: "primary",
|
|
28
|
+
disabled: false,
|
|
29
|
+
label: "Button",
|
|
30
|
+
},
|
|
31
|
+
parameters: {
|
|
32
|
+
pseudo: {
|
|
33
|
+
hover: true,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const Active = {
|
|
39
|
+
args: {
|
|
40
|
+
type: "primary",
|
|
41
|
+
disabled: false,
|
|
42
|
+
label: "Button",
|
|
43
|
+
},
|
|
44
|
+
parameters: {
|
|
45
|
+
pseudo: {
|
|
46
|
+
active: true,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const IconLeft = {
|
|
52
|
+
args: {
|
|
53
|
+
type: "primary",
|
|
54
|
+
label: "Button",
|
|
55
|
+
iconLeft: "user",
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const IconRight = {
|
|
60
|
+
args: {
|
|
61
|
+
type: "primary",
|
|
62
|
+
label: "Button",
|
|
63
|
+
iconRight: "user",
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
export const IconLeftRight = {
|
|
67
|
+
args: {
|
|
68
|
+
type: "primary",
|
|
69
|
+
label: "Button",
|
|
70
|
+
iconRight: "user",
|
|
71
|
+
iconLeft: "database",
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
export const AlignLeft = {
|
|
75
|
+
args: {
|
|
76
|
+
type: "secondary",
|
|
77
|
+
label: "Button",
|
|
78
|
+
iconLeft: "database",
|
|
79
|
+
align: "left",
|
|
80
|
+
width: "270px",
|
|
81
|
+
},
|
|
82
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ThemeProvider } from "styled-components";
|
|
2
|
+
import { Button, ButtonProps } from "./Button";
|
|
3
|
+
import { themes } from "../../theme";
|
|
4
|
+
import { render, fireEvent } from "@testing-library/react";
|
|
5
|
+
|
|
6
|
+
describe("Button", () => {
|
|
7
|
+
const renderButton = (props: ButtonProps) =>
|
|
8
|
+
render(
|
|
9
|
+
<ThemeProvider theme={themes.dark}>
|
|
10
|
+
<Button {...props} />
|
|
11
|
+
</ThemeProvider>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
it("should render the button", () => {
|
|
15
|
+
const { getByText } = renderButton({ children: "Hello" });
|
|
16
|
+
expect(getByText("Hello").textContent).toBe("Hello");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("should execute action on click", () => {
|
|
20
|
+
let counter = 0;
|
|
21
|
+
const hanldeClick = () => (counter = 1);
|
|
22
|
+
const { getByText } = renderButton({
|
|
23
|
+
onClick: hanldeClick,
|
|
24
|
+
label: "Button",
|
|
25
|
+
});
|
|
26
|
+
const button = getByText("Button");
|
|
27
|
+
button.focus();
|
|
28
|
+
fireEvent.click(button);
|
|
29
|
+
|
|
30
|
+
expect(counter).toEqual(1);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Icon } from "@/components";
|
|
2
|
+
import { IconName } from "@/components/Icon/types";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
|
|
5
|
+
type ButtonType = "primary" | "secondary";
|
|
6
|
+
type Alignment = "left";
|
|
7
|
+
export interface ButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
|
|
8
|
+
type?: ButtonType;
|
|
9
|
+
label?: string;
|
|
10
|
+
iconLeft?: IconName;
|
|
11
|
+
iconRight?: IconName;
|
|
12
|
+
align?: Alignment;
|
|
13
|
+
width?: string;
|
|
14
|
+
height?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface StyledButtonProps {
|
|
18
|
+
styleType: ButtonType;
|
|
19
|
+
align?: Alignment;
|
|
20
|
+
width?: string;
|
|
21
|
+
height?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const Button = ({
|
|
25
|
+
type = "primary",
|
|
26
|
+
iconLeft,
|
|
27
|
+
iconRight,
|
|
28
|
+
label,
|
|
29
|
+
align,
|
|
30
|
+
children,
|
|
31
|
+
...delegated
|
|
32
|
+
}: ButtonProps) => (
|
|
33
|
+
<StyledButton styleType={type} align={align} {...delegated}>
|
|
34
|
+
{iconLeft && <Icon name={iconLeft} size="small" />}
|
|
35
|
+
{label ? label : children}
|
|
36
|
+
{iconRight && <Icon name={iconRight} size="small" />}
|
|
37
|
+
</StyledButton>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const BaseButton = styled.button`
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-direction: row;
|
|
43
|
+
justify-content: center;
|
|
44
|
+
align-items: center;
|
|
45
|
+
|
|
46
|
+
padding-left: ${props => props.theme.click.button.basic.space.x};
|
|
47
|
+
padding-right: ${props => props.theme.click.button.basic.space.x};
|
|
48
|
+
padding-top: ${props => props.theme.click.button.basic.space.y};
|
|
49
|
+
padding-bottom: ${props => props.theme.click.button.basic.space.y};
|
|
50
|
+
border-radius: ${props => props.theme.click.button.radii.all};
|
|
51
|
+
gap: ${props => props.theme.click.button.basic.space.gap};
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
`;
|
|
54
|
+
|
|
55
|
+
const StyledButton = styled(BaseButton)<StyledButtonProps>`
|
|
56
|
+
width: ${props => props.width};
|
|
57
|
+
height: ${props => props.height};
|
|
58
|
+
|
|
59
|
+
display: flex;
|
|
60
|
+
align-items: center;
|
|
61
|
+
justify-content: ${props =>
|
|
62
|
+
props.align === "left" ? "flex-start" : "center"};
|
|
63
|
+
|
|
64
|
+
border: 1px solid
|
|
65
|
+
${props =>
|
|
66
|
+
props.theme.click.button.basic.color[props.styleType].stroke.default};
|
|
67
|
+
background-color: ${props =>
|
|
68
|
+
props.theme.click.button.basic.color[props.styleType].background.default};
|
|
69
|
+
color: ${props =>
|
|
70
|
+
props.theme.click.button.basic.color[props.styleType].text.default};
|
|
71
|
+
font: ${props => props.theme.click.button.basic.typography.label.default};
|
|
72
|
+
|
|
73
|
+
&:active {
|
|
74
|
+
border: 1px solid
|
|
75
|
+
${props =>
|
|
76
|
+
props.theme.click.button.basic.color[props.styleType].stroke.active};
|
|
77
|
+
background-color: ${props =>
|
|
78
|
+
props.theme.click.button.basic.color[props.styleType].background.active};
|
|
79
|
+
font: ${props => props.theme.click.button.basic.typography.label.active};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
&:hover {
|
|
83
|
+
border: 1px solid
|
|
84
|
+
${props =>
|
|
85
|
+
props.theme.click.button.basic.color[props.styleType].stroke.hover};
|
|
86
|
+
background-color: ${props =>
|
|
87
|
+
props.theme.click.button.basic.color[props.styleType].background.hover};
|
|
88
|
+
font: ${props => props.theme.click.button.basic.typography.label.hover};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
&[disabled] {
|
|
92
|
+
background-color: ${props =>
|
|
93
|
+
props.theme.click.button.basic.color.disabled.background.default};
|
|
94
|
+
color: ${props =>
|
|
95
|
+
props.theme.click.button.basic.color.disabled.text.default};
|
|
96
|
+
}
|
|
97
|
+
`;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ButtonGroup } from "./ButtonGroup";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
component: ButtonGroup,
|
|
5
|
+
title: "ButtonGroup",
|
|
6
|
+
tags: ["buttons"],
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const Default = {
|
|
10
|
+
args: {
|
|
11
|
+
labels: ["Button 1", "Button 2", "Button 3"],
|
|
12
|
+
activeIndex: 2,
|
|
13
|
+
},
|
|
14
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
|
|
3
|
+
export interface ButtonGroupProps {
|
|
4
|
+
labels: string[];
|
|
5
|
+
activeIndex?: number;
|
|
6
|
+
onClick?: (index: number) => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const ButtonGroup = ({
|
|
10
|
+
labels,
|
|
11
|
+
activeIndex,
|
|
12
|
+
onClick,
|
|
13
|
+
}: ButtonGroupProps) => {
|
|
14
|
+
const btns = labels.map((label, index) => {
|
|
15
|
+
const position: ButtonPosition =
|
|
16
|
+
index === 0 ? "left" : index === labels.length - 1 ? "right" : "center";
|
|
17
|
+
return (
|
|
18
|
+
<Button
|
|
19
|
+
key={index}
|
|
20
|
+
active={index === activeIndex}
|
|
21
|
+
position={position}
|
|
22
|
+
onClick={() => onClick?.(index)}
|
|
23
|
+
>
|
|
24
|
+
{label}
|
|
25
|
+
</Button>
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
return <ButtonGroupWrapper>{btns}</ButtonGroupWrapper>;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
type ButtonPosition = "left" | "center" | "right";
|
|
32
|
+
interface ButtonProps {
|
|
33
|
+
active: boolean;
|
|
34
|
+
position: ButtonPosition;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const ButtonGroupWrapper = styled.div`
|
|
38
|
+
box-sizing: border-box;
|
|
39
|
+
display: flex;
|
|
40
|
+
flex-direction: row;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
align-items: center;
|
|
43
|
+
padding: 0px 1px;
|
|
44
|
+
border: var(--click-button-group-color-stroke-panel);
|
|
45
|
+
background: var(--click-button-group-color-background-panel);
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
const endRadii = "var(--click-button-button-group-radii-end)";
|
|
49
|
+
const leftBorderRadius = `${endRadii} 0px 0px ${endRadii}`;
|
|
50
|
+
const rightBorderRadius = `0px ${endRadii} ${endRadii} 0px`;
|
|
51
|
+
const centerBorderRadius = "var(--click-button-button-group-radii-center)";
|
|
52
|
+
|
|
53
|
+
const Button = styled.button<ButtonProps>`
|
|
54
|
+
box-sizing: border-box;
|
|
55
|
+
display: flex;
|
|
56
|
+
flex-direction: row;
|
|
57
|
+
justify-content: center;
|
|
58
|
+
align-items: center;
|
|
59
|
+
border: none;
|
|
60
|
+
padding: var(--click-button-basic-space-y) var(--click-button-basic-space-x);
|
|
61
|
+
gap: 10px;
|
|
62
|
+
|
|
63
|
+
background: ${({ active }: ButtonProps) =>
|
|
64
|
+
active
|
|
65
|
+
? "var(--click-button-group-color-background-active)"
|
|
66
|
+
: "var(--click-button-group-color-background-default)"};
|
|
67
|
+
|
|
68
|
+
border-radius: ${({ position }: ButtonProps) =>
|
|
69
|
+
position === "left"
|
|
70
|
+
? leftBorderRadius
|
|
71
|
+
: position === "right"
|
|
72
|
+
? rightBorderRadius
|
|
73
|
+
: centerBorderRadius};
|
|
74
|
+
|
|
75
|
+
&:hover {
|
|
76
|
+
background: var(--click-button-group-color-background-hover);
|
|
77
|
+
}
|
|
78
|
+
`;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Card } from "./Card";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
component: Card,
|
|
5
|
+
title: "Card",
|
|
6
|
+
tags: ["card"],
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const Default = {
|
|
10
|
+
args: {
|
|
11
|
+
title: "Card title",
|
|
12
|
+
badgeText: "experiment",
|
|
13
|
+
description:
|
|
14
|
+
"A description very interesting that presumably relates to the card",
|
|
15
|
+
infoUrl: "#",
|
|
16
|
+
infoText: "Read More",
|
|
17
|
+
state: "active",
|
|
18
|
+
},
|
|
19
|
+
};
|