@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,114 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
|
|
3
|
+
export const GenericMenuPanel = styled.div<{
|
|
4
|
+
type: "popover" | "dropdown-menu" | "context-menu";
|
|
5
|
+
$showArrow?: boolean;
|
|
6
|
+
}>`
|
|
7
|
+
outline: none;
|
|
8
|
+
max-width: var(--radix-${({ type }) => type}-content-available-width);
|
|
9
|
+
max-height: var(--radix-${({ type }) => type}-content-available-height);
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: flex-start;
|
|
13
|
+
|
|
14
|
+
${({ theme }) => `
|
|
15
|
+
border: 1px solid ${theme.click.genericMenu.panel.color.stroke.default};
|
|
16
|
+
background: ${theme.click.genericMenu.panel.color.background.default};
|
|
17
|
+
box-shadow: ${theme.click.genericMenu.panel.shadow.default};
|
|
18
|
+
border-radius: ${theme.click.genericMenu.panel.radii.all};
|
|
19
|
+
`};
|
|
20
|
+
${({ $showArrow }) =>
|
|
21
|
+
$showArrow
|
|
22
|
+
? `
|
|
23
|
+
&[data-side="bottom"] {
|
|
24
|
+
margin-top: -1px;
|
|
25
|
+
}
|
|
26
|
+
&[data-side="top"] {
|
|
27
|
+
margin-bottom: 1px;
|
|
28
|
+
}
|
|
29
|
+
&[data-side="left"] {
|
|
30
|
+
margin-right: -1px;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
&[data-side="right"] {
|
|
34
|
+
margin-left: -1px;
|
|
35
|
+
}
|
|
36
|
+
`
|
|
37
|
+
: ""};
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
export const GenericPopoverMenuPanel = styled.div<{
|
|
41
|
+
$type: "popover" | "hover-card";
|
|
42
|
+
$showArrow?: boolean;
|
|
43
|
+
}>`
|
|
44
|
+
outline: none;
|
|
45
|
+
max-width: var(--radix-${({ $type }) => $type}-content-available-width);
|
|
46
|
+
max-height: var(--radix-${({ $type }) => $type}-content-available-height);
|
|
47
|
+
overflow: hidden;
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-direction: column;
|
|
50
|
+
align-items: flex-start;
|
|
51
|
+
z-index: 1;
|
|
52
|
+
|
|
53
|
+
${({ theme }) => `
|
|
54
|
+
border: 1px solid ${theme.click.popover.color.panel.stroke.default};
|
|
55
|
+
background: ${theme.click.popover.color.panel.background.default};
|
|
56
|
+
padding: ${theme.click.popover.space.y} ${theme.click.popover.space.x};
|
|
57
|
+
border-radius: ${theme.click.popover.radii.all};
|
|
58
|
+
box-shadow: ${theme.click.popover.shadow.default};
|
|
59
|
+
`}
|
|
60
|
+
${({ $showArrow }) => ($showArrow ? "margin: -1px 0;" : "")};
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
export const Arrow = styled.svg`
|
|
64
|
+
filter: drop-shadow(rgba(0, 0, 0, 0.1) 0px 4px 6px);
|
|
65
|
+
${({ theme }) => `
|
|
66
|
+
fill: ${theme.click.genericMenu.panel.color.background.default};
|
|
67
|
+
stroke: ${theme.click.genericMenu.panel.color.stroke.default};
|
|
68
|
+
`};
|
|
69
|
+
`;
|
|
70
|
+
|
|
71
|
+
export const GenericMenuItem = styled.div`
|
|
72
|
+
display: flex;
|
|
73
|
+
width: -webkit-fill-available;
|
|
74
|
+
align-items: center;
|
|
75
|
+
justify-content: space-between;
|
|
76
|
+
cursor: default;
|
|
77
|
+
overflow: hidden;
|
|
78
|
+
white-space: nowrap;
|
|
79
|
+
text-overflow: ellipsis;
|
|
80
|
+
outline: none;
|
|
81
|
+
&[aria-selected] {
|
|
82
|
+
outline: none;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
${({ theme }) => `
|
|
86
|
+
padding: ${theme.click.genericMenu.item.space.y} ${theme.click.genericMenu.item.space.x};
|
|
87
|
+
gap: ${theme.click.genericMenu.item.space.gap};
|
|
88
|
+
font: ${theme.click.genericMenu.item.typography.label.default};
|
|
89
|
+
background: ${theme.click.genericMenu.item.color.background.default};
|
|
90
|
+
color: ${theme.click.genericMenu.item.color.text.default};
|
|
91
|
+
&[data-highlighted] {
|
|
92
|
+
font: ${theme.click.genericMenu.item.typography.label.hover};
|
|
93
|
+
background: ${theme.click.genericMenu.item.color.background.hover};
|
|
94
|
+
color:${theme.click.genericMenu.item.color.text.hover};
|
|
95
|
+
cursor: pointer;
|
|
96
|
+
}
|
|
97
|
+
&[data-state="open"] {
|
|
98
|
+
background:${theme.click.genericMenu.item.color.background.active};
|
|
99
|
+
color:${theme.click.genericMenu.item.color.text.active};
|
|
100
|
+
font: ${theme.click.genericMenu.item.typography.label.active};
|
|
101
|
+
}
|
|
102
|
+
&[data-disabled] {
|
|
103
|
+
background:${theme.click.genericMenu.item.color.background.disabled};
|
|
104
|
+
color:${theme.click.genericMenu.item.color.text.disabled};
|
|
105
|
+
font: ${theme.click.genericMenu.item.typography.label.disabled};
|
|
106
|
+
pointer-events: none;
|
|
107
|
+
}
|
|
108
|
+
`};
|
|
109
|
+
position: relative;
|
|
110
|
+
&:hover .dropdown-arrow,
|
|
111
|
+
&[data-state="open"] .dropdown-arrow {
|
|
112
|
+
left: 0.5rem;
|
|
113
|
+
}
|
|
114
|
+
`;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Checkbox } from "..";
|
|
2
|
+
import { Title } from "../Typography/Title/Title";
|
|
3
|
+
import { HoverCard } from "./HoverCard";
|
|
4
|
+
|
|
5
|
+
const HoverCardComponent = ({
|
|
6
|
+
open,
|
|
7
|
+
showArrow,
|
|
8
|
+
forceMount,
|
|
9
|
+
title,
|
|
10
|
+
openDelay,
|
|
11
|
+
closeDelay,
|
|
12
|
+
}: {
|
|
13
|
+
open: "default" | "open" | "closed";
|
|
14
|
+
showArrow: boolean;
|
|
15
|
+
forceMount?: boolean;
|
|
16
|
+
title?: string;
|
|
17
|
+
openDelay?: number;
|
|
18
|
+
closeDelay?: number;
|
|
19
|
+
}) => (
|
|
20
|
+
<HoverCard
|
|
21
|
+
open={open === "default" ? undefined : open === "open"}
|
|
22
|
+
openDelay={openDelay}
|
|
23
|
+
closeDelay={closeDelay}
|
|
24
|
+
>
|
|
25
|
+
<HoverCard.Trigger>Hover Here</HoverCard.Trigger>
|
|
26
|
+
<HoverCard.Content
|
|
27
|
+
showArrow={showArrow}
|
|
28
|
+
forceMount={forceMount ? true : undefined}
|
|
29
|
+
title={title}
|
|
30
|
+
>
|
|
31
|
+
<Title
|
|
32
|
+
color="default"
|
|
33
|
+
size="sm"
|
|
34
|
+
type="h5"
|
|
35
|
+
>
|
|
36
|
+
Hover Title
|
|
37
|
+
</Title>
|
|
38
|
+
<div>
|
|
39
|
+
Click on the input element below
|
|
40
|
+
<Checkbox />
|
|
41
|
+
<div>This is a sample data to experiment the popover</div>
|
|
42
|
+
</div>
|
|
43
|
+
</HoverCard.Content>
|
|
44
|
+
</HoverCard>
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
export default {
|
|
48
|
+
component: HoverCardComponent,
|
|
49
|
+
title: "Display/HoverCard",
|
|
50
|
+
tags: ["form-field", "hover-card", "autodocs"],
|
|
51
|
+
argTypes: {
|
|
52
|
+
open: { control: "radio", options: ["default", "open", "closed"] },
|
|
53
|
+
showArrow: { control: "boolean" },
|
|
54
|
+
forceMount: { control: "boolean" },
|
|
55
|
+
openDelay: { control: "number" },
|
|
56
|
+
closeDelay: { control: "number" },
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const Playground = {
|
|
61
|
+
args: {
|
|
62
|
+
open: "default",
|
|
63
|
+
},
|
|
64
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { ThemeProvider } from "styled-components";
|
|
2
|
+
import "@testing-library/jest-dom";
|
|
3
|
+
import { themes } from "../../theme";
|
|
4
|
+
import { HoverCardProps } from "@radix-ui/react-hover-card";
|
|
5
|
+
import { Checkbox, HoverCard } from "@/components";
|
|
6
|
+
import { render, fireEvent, waitFor } from "@testing-library/react";
|
|
7
|
+
// import userEvent from "@testing-library/user-event";
|
|
8
|
+
|
|
9
|
+
describe("HoverCard", () => {
|
|
10
|
+
const renderHoverCard = (props: HoverCardProps) =>
|
|
11
|
+
render(
|
|
12
|
+
<ThemeProvider theme={themes.dark}>
|
|
13
|
+
<HoverCard
|
|
14
|
+
openDelay={0}
|
|
15
|
+
closeDelay={0}
|
|
16
|
+
{...props}
|
|
17
|
+
>
|
|
18
|
+
<HoverCard.Trigger>Hover Here</HoverCard.Trigger>
|
|
19
|
+
<HoverCard.Content data-testid="popover-panel">
|
|
20
|
+
<div>
|
|
21
|
+
Click on the input element below
|
|
22
|
+
<Checkbox />
|
|
23
|
+
<div>This is a sample data to experiment the hoverCard</div>
|
|
24
|
+
</div>
|
|
25
|
+
</HoverCard.Content>
|
|
26
|
+
</HoverCard>
|
|
27
|
+
</ThemeProvider>
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
it("should open hover card on hover", async () => {
|
|
31
|
+
const { getByText } = renderHoverCard({});
|
|
32
|
+
const hoverCardTrigger = getByText("Hover Here");
|
|
33
|
+
expect(hoverCardTrigger).not.toBeNull();
|
|
34
|
+
fireEvent.pointerEnter(hoverCardTrigger);
|
|
35
|
+
await waitFor(() => {
|
|
36
|
+
expect(getByText("Click on the input element below")).not.toBeNull();
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("should not close hoverCard on clicking the checkbox", async () => {
|
|
41
|
+
const { getByTestId, getByText } = renderHoverCard({});
|
|
42
|
+
const hoverCardTrigger = getByText("Hover Here");
|
|
43
|
+
expect(hoverCardTrigger).not.toBeNull();
|
|
44
|
+
fireEvent.pointerOver(hoverCardTrigger);
|
|
45
|
+
|
|
46
|
+
await waitFor(() => {
|
|
47
|
+
expect(getByText("Click on the input element below")).not.toBeNull();
|
|
48
|
+
});
|
|
49
|
+
const checkbox = getByTestId("checkbox");
|
|
50
|
+
fireEvent.click(checkbox);
|
|
51
|
+
expect(getByText("Click on the input element below")).not.toBeNull();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("should close hover card on pointerLeave", async () => {
|
|
55
|
+
const { getByText, queryByText } = renderHoverCard({});
|
|
56
|
+
const hoverCardTrigger = getByText("Hover Here");
|
|
57
|
+
expect(hoverCardTrigger).not.toBeNull();
|
|
58
|
+
fireEvent.pointerOver(hoverCardTrigger);
|
|
59
|
+
|
|
60
|
+
await waitFor(() => {
|
|
61
|
+
expect(getByText("Click on the input element below")).not.toBeNull();
|
|
62
|
+
});
|
|
63
|
+
fireEvent.pointerLeave(hoverCardTrigger);
|
|
64
|
+
await waitFor(() => {
|
|
65
|
+
expect(queryByText("Click on the input element below")).not.toBeInTheDocument();
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("should not close hover card on pointerLeave and focus ", async () => {
|
|
70
|
+
const { getByText, queryByText, getByTestId } = renderHoverCard({});
|
|
71
|
+
const hoverCardTrigger = getByText("Hover Here");
|
|
72
|
+
expect(hoverCardTrigger).not.toBeNull();
|
|
73
|
+
fireEvent.pointerOver(hoverCardTrigger);
|
|
74
|
+
|
|
75
|
+
await waitFor(() => {
|
|
76
|
+
expect(getByText("Click on the input element below")).not.toBeNull();
|
|
77
|
+
});
|
|
78
|
+
const checkbox = getByTestId("checkbox");
|
|
79
|
+
fireEvent.click(checkbox);
|
|
80
|
+
fireEvent.pointerLeave(getByTestId("popover-panel"));
|
|
81
|
+
await waitFor(() => {
|
|
82
|
+
expect(queryByText("Click on the input element below")).not.toBeInTheDocument();
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as RadixHoverCard from "@radix-ui/react-hover-card";
|
|
2
|
+
import { Arrow, GenericPopoverMenuPanel } from "../GenericMenu";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import { ReactNode } from "react";
|
|
5
|
+
import PopoverArrow from "../icons/PopoverArrow";
|
|
6
|
+
|
|
7
|
+
export const HoverCard = ({ children, ...props }: RadixHoverCard.HoverCardProps) => {
|
|
8
|
+
return <RadixHoverCard.Root {...props}>{children}</RadixHoverCard.Root>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const Trigger = styled(RadixHoverCard.Trigger)`
|
|
12
|
+
width: fit-content;
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
const HoverCardTrigger = ({
|
|
16
|
+
children,
|
|
17
|
+
...props
|
|
18
|
+
}: RadixHoverCard.HoverCardTriggerProps) => {
|
|
19
|
+
return <Trigger {...props}>{children}</Trigger>;
|
|
20
|
+
};
|
|
21
|
+
HoverCardTrigger.displayName = "HoverCardTrigger";
|
|
22
|
+
HoverCard.Trigger = HoverCardTrigger;
|
|
23
|
+
|
|
24
|
+
interface HoverCardContentProps extends RadixHoverCard.HoverCardContentProps {
|
|
25
|
+
showArrow?: boolean;
|
|
26
|
+
forceMount?: true;
|
|
27
|
+
container?: HTMLElement | null;
|
|
28
|
+
children: ReactNode;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const HoverCardContent = ({
|
|
32
|
+
children,
|
|
33
|
+
showArrow,
|
|
34
|
+
forceMount,
|
|
35
|
+
container,
|
|
36
|
+
...props
|
|
37
|
+
}: HoverCardContentProps) => {
|
|
38
|
+
return (
|
|
39
|
+
<RadixHoverCard.Portal
|
|
40
|
+
forceMount={forceMount}
|
|
41
|
+
container={container}
|
|
42
|
+
>
|
|
43
|
+
<GenericPopoverMenuPanel
|
|
44
|
+
as={RadixHoverCard.Content}
|
|
45
|
+
$type="hover-card"
|
|
46
|
+
$showArrow={showArrow}
|
|
47
|
+
{...props}
|
|
48
|
+
>
|
|
49
|
+
{showArrow && (
|
|
50
|
+
<Arrow
|
|
51
|
+
asChild
|
|
52
|
+
as={RadixHoverCard.Arrow}
|
|
53
|
+
width={15}
|
|
54
|
+
height={10}
|
|
55
|
+
>
|
|
56
|
+
<PopoverArrow />
|
|
57
|
+
</Arrow>
|
|
58
|
+
)}
|
|
59
|
+
{children}
|
|
60
|
+
</GenericPopoverMenuPanel>
|
|
61
|
+
</RadixHoverCard.Portal>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
HoverCardContent.displayName = "HoverCardContent";
|
|
65
|
+
HoverCard.Content = HoverCardContent;
|
|
@@ -2,45 +2,14 @@ import { Icon } from "./Icon";
|
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
component: Icon,
|
|
5
|
-
title: "Icon",
|
|
6
|
-
tags: ["icon"],
|
|
5
|
+
title: "Display/Icon",
|
|
6
|
+
tags: ["icon","autodocs"],
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
export const
|
|
9
|
+
export const Playground = {
|
|
10
10
|
args: {
|
|
11
11
|
name: "users",
|
|
12
12
|
width: "1rem",
|
|
13
13
|
height: "16px",
|
|
14
14
|
},
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const Color = {
|
|
18
|
-
args: {
|
|
19
|
-
name: "users",
|
|
20
|
-
color: "darkturquoise",
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const Small = {
|
|
25
|
-
args: {
|
|
26
|
-
name: "users",
|
|
27
|
-
color: "darkturquoise",
|
|
28
|
-
size: "small",
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const Medium = {
|
|
33
|
-
args: {
|
|
34
|
-
name: "users",
|
|
35
|
-
color: "darkturquoise",
|
|
36
|
-
size: "medium",
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export const Large = {
|
|
41
|
-
args: {
|
|
42
|
-
name: "users",
|
|
43
|
-
color: "darkturquoise",
|
|
44
|
-
size: "large",
|
|
45
|
-
},
|
|
46
|
-
};
|
|
15
|
+
};
|
|
@@ -8,38 +8,186 @@ import FilterIcon from "../icons/FilterIcon";
|
|
|
8
8
|
import HistoryIcon from "../icons/HistoryIcon";
|
|
9
9
|
import InsertRowIcon from "../icons/InsertRowIcon";
|
|
10
10
|
import SortAltIcon from "../icons/SortAltIcon";
|
|
11
|
+
import SortIcon from "../icons/SortIcon";
|
|
11
12
|
import { IconProps } from "./types";
|
|
12
13
|
import { ChevronRight } from "../icons/ChevronRight";
|
|
13
14
|
import { ChevronDown } from "../icons/ChevronDown";
|
|
15
|
+
import ArrowDown from "@/components/icons/ArrowDown";
|
|
16
|
+
import InfoInCircleIcon from "@/components/icons/InfoInCircleIcon";
|
|
17
|
+
import CheckIcon from "@/components/icons/CheckIcon";
|
|
18
|
+
import InformationIcon from "@/components/icons/InformationIcon";
|
|
19
|
+
import WarningIcon from "@/components/icons/WarningIcon";
|
|
20
|
+
import CrossIcon from "@/components/icons/CrossIcon";
|
|
21
|
+
import ChevronUp from "../icons/ChevronUp";
|
|
22
|
+
import Activity from "../icons/Activity";
|
|
23
|
+
import ArrowRight from "../icons/ArrowRight";
|
|
24
|
+
import ArrowTriangle from "../icons/ArrowTriangle";
|
|
25
|
+
import ArrowUp from "../icons/ArrowUp";
|
|
26
|
+
import BackUps from "../icons/Backups";
|
|
27
|
+
import Blog from "../icons/Blog";
|
|
28
|
+
import Book from "../icons/Book";
|
|
29
|
+
import Brackets from "../icons/Brackets";
|
|
30
|
+
import Briefcase from "../icons/Briefcase";
|
|
31
|
+
import Building from "../icons/Building";
|
|
32
|
+
import BurgerMenu from "../icons/BurgerMenu";
|
|
33
|
+
import Cards from "../icons/Cards";
|
|
34
|
+
import CellTower from "../icons/CellTower";
|
|
35
|
+
import CheckInCircle from "../icons/CheckInCircle";
|
|
36
|
+
import ChevronLeft from "../icons/ChevronLeft";
|
|
37
|
+
import Clock from "../icons/Clock";
|
|
38
|
+
import Cloud from "../icons/Cloud";
|
|
39
|
+
import Code from "../icons/Code";
|
|
40
|
+
import CodeInSquare from "../icons/CodeInSquare";
|
|
41
|
+
import Connect from "../icons/Connect";
|
|
42
|
+
import ConnectAlt from "../icons/ConnectAlt";
|
|
43
|
+
import Console from "../icons/Console";
|
|
44
|
+
import Copy from "../icons/Copy";
|
|
45
|
+
import Data from "../icons/Data";
|
|
46
|
+
import Disk from "../icons/Disk";
|
|
47
|
+
import Display from "../icons/Display";
|
|
48
|
+
import Document from "../icons/Document";
|
|
49
|
+
import DotsVertical from "../icons/DotsVertical";
|
|
50
|
+
import DotsHorizontal from "../icons/DotsHorizontal";
|
|
51
|
+
import Email from "../icons/Email";
|
|
52
|
+
import Empty from "../icons/Empty";
|
|
53
|
+
import Fire from "../icons/Fire";
|
|
54
|
+
import Folder from "../icons/Folder";
|
|
55
|
+
import Gift from "../icons/Gift";
|
|
56
|
+
import Home from "../icons/Home";
|
|
57
|
+
import Http from "../icons/Http";
|
|
58
|
+
import Integrations from "../icons/Integrations";
|
|
59
|
+
import LightBulb from "../icons/LightBulb";
|
|
60
|
+
import Lightening from "../icons/Lightening";
|
|
61
|
+
import Loading from "../icons/Loading";
|
|
62
|
+
import Metrics from "../icons/Metrics";
|
|
63
|
+
import MetricsAlt from "../icons/MetricsAlt";
|
|
64
|
+
import Payment from "../icons/Payment";
|
|
65
|
+
import Pencil from "../icons/Pencil";
|
|
66
|
+
import PieChart from "../icons/PieChart";
|
|
67
|
+
import Play from "../icons/Play";
|
|
68
|
+
import Plus from "../icons/Plus";
|
|
69
|
+
import Popout from "../icons/Popout";
|
|
70
|
+
import Question from "../icons/Question";
|
|
71
|
+
import Refresh from "../icons/Refresh";
|
|
72
|
+
import Search from "../icons/Search";
|
|
73
|
+
import Secure from "../icons/Secure";
|
|
74
|
+
import Services from "../icons/Services";
|
|
75
|
+
import Settings from "../icons/Settings";
|
|
76
|
+
import Share from "../icons/Share";
|
|
77
|
+
import SlideIn from "../icons/SlideIn";
|
|
78
|
+
import SlideOut from "../icons/SlideOut";
|
|
79
|
+
import Sparkle from "../icons/Sparkle";
|
|
80
|
+
import Speaker from "../icons/Speaker";
|
|
81
|
+
import Speed from "../icons/Speed";
|
|
82
|
+
import Star from "../icons/Star";
|
|
83
|
+
import Support from "../icons/Support";
|
|
84
|
+
import Table from "../icons/Table";
|
|
85
|
+
import Taxi from "../icons/Taxi";
|
|
86
|
+
import Trash from "../icons/Trash";
|
|
87
|
+
import Upload from "../icons/Upload";
|
|
88
|
+
import Url from "../icons/Url";
|
|
14
89
|
|
|
15
|
-
const ICONS_MAP = {
|
|
90
|
+
export const ICONS_MAP = {
|
|
91
|
+
activity: Activity,
|
|
92
|
+
"arrow-down": ArrowDown,
|
|
93
|
+
"arrow-right": ArrowRight,
|
|
94
|
+
"arrow-triangle": ArrowTriangle,
|
|
95
|
+
"arrow-up": ArrowUp,
|
|
96
|
+
backups: BackUps,
|
|
97
|
+
blog: Blog,
|
|
98
|
+
book: Book,
|
|
99
|
+
brackets: Brackets,
|
|
100
|
+
briefcase: Briefcase,
|
|
101
|
+
building: Building,
|
|
102
|
+
"burger-menu": BurgerMenu,
|
|
103
|
+
cards: Cards,
|
|
104
|
+
"cell-tower": CellTower,
|
|
16
105
|
chat: ChatIcon,
|
|
17
|
-
|
|
106
|
+
check: CheckIcon,
|
|
107
|
+
"check-in-circle": CheckInCircle,
|
|
18
108
|
"chevron-down": ChevronDown,
|
|
109
|
+
"chevron-left": ChevronLeft,
|
|
110
|
+
"chevron-right": ChevronRight,
|
|
111
|
+
"chevron-up": ChevronUp,
|
|
112
|
+
clock: Clock,
|
|
113
|
+
cloud: Cloud,
|
|
114
|
+
code: Code,
|
|
115
|
+
"code-in-square": CodeInSquare,
|
|
116
|
+
connect: Connect,
|
|
117
|
+
"connect-alt": ConnectAlt,
|
|
118
|
+
console: Console,
|
|
119
|
+
copy: Copy,
|
|
120
|
+
cross: CrossIcon,
|
|
121
|
+
data: Data,
|
|
19
122
|
database: DatabaseIcon,
|
|
123
|
+
disk: Disk,
|
|
124
|
+
display: Display,
|
|
125
|
+
document: Document,
|
|
126
|
+
"dots-horizontal": DotsHorizontal,
|
|
127
|
+
"dots-vertical": DotsVertical,
|
|
128
|
+
email: Email,
|
|
129
|
+
empty: Empty,
|
|
20
130
|
filter: FilterIcon,
|
|
131
|
+
fire: Fire,
|
|
132
|
+
folder: Folder,
|
|
133
|
+
gift: Gift,
|
|
21
134
|
history: HistoryIcon,
|
|
22
|
-
|
|
23
|
-
|
|
135
|
+
home: Home,
|
|
136
|
+
http: Http,
|
|
137
|
+
"info-in-circle": InfoInCircleIcon,
|
|
138
|
+
information: InformationIcon,
|
|
139
|
+
"insert-row": InsertRowIcon,
|
|
140
|
+
integrations: Integrations,
|
|
141
|
+
"light-bulb": LightBulb,
|
|
142
|
+
lightening: Lightening,
|
|
143
|
+
loading: Loading,
|
|
144
|
+
metrics: Metrics,
|
|
145
|
+
"metrics-alt": MetricsAlt,
|
|
146
|
+
payment: Payment,
|
|
147
|
+
pencil: Pencil,
|
|
148
|
+
"pie-chart": PieChart,
|
|
149
|
+
play: Play,
|
|
150
|
+
plus: Plus,
|
|
151
|
+
popout: Popout,
|
|
152
|
+
question: Question,
|
|
153
|
+
refresh: Refresh,
|
|
154
|
+
search: Search,
|
|
155
|
+
secure: Secure,
|
|
156
|
+
services: Services,
|
|
157
|
+
settings: Settings,
|
|
158
|
+
share: Share,
|
|
159
|
+
"slide-in": SlideIn,
|
|
160
|
+
"slide-out": SlideOut,
|
|
161
|
+
"sort-alt": SortAltIcon,
|
|
162
|
+
sort: SortIcon,
|
|
163
|
+
sparkle: Sparkle,
|
|
164
|
+
speaker: Speaker,
|
|
165
|
+
speed: Speed,
|
|
166
|
+
star: Star,
|
|
167
|
+
support: Support,
|
|
168
|
+
table: Table,
|
|
169
|
+
taxi: Taxi,
|
|
170
|
+
trash: Trash,
|
|
171
|
+
upload: Upload,
|
|
172
|
+
url: Url,
|
|
24
173
|
user: UserIcon,
|
|
25
174
|
users: UsersIcon,
|
|
175
|
+
warning: WarningIcon,
|
|
26
176
|
};
|
|
27
177
|
|
|
28
178
|
const SVGIcon = ({ name, ...delegated }: IconProps) => {
|
|
29
179
|
const Component = ICONS_MAP[name];
|
|
180
|
+
|
|
181
|
+
if (!Component) {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
|
|
30
185
|
return <Component {...delegated} />;
|
|
31
186
|
};
|
|
32
187
|
|
|
33
188
|
const withStylesWrapper =
|
|
34
189
|
(IconComponent: ElementType) =>
|
|
35
|
-
({
|
|
36
|
-
color,
|
|
37
|
-
width,
|
|
38
|
-
height,
|
|
39
|
-
className,
|
|
40
|
-
size,
|
|
41
|
-
...props
|
|
42
|
-
}: IconProps): ReactElement =>
|
|
190
|
+
({ color, width, height, className, size, ...props }: IconProps): ReactElement =>
|
|
43
191
|
(
|
|
44
192
|
<SvgWrapper
|
|
45
193
|
color={color}
|
|
@@ -57,30 +205,30 @@ const SvgWrapper = styled.div<Partial<IconProps>>`
|
|
|
57
205
|
align-items: center;
|
|
58
206
|
|
|
59
207
|
& path[stroke] {
|
|
60
|
-
stroke: ${props => props.color || "currentColor"};
|
|
208
|
+
stroke: ${(props) => props.color || "currentColor"};
|
|
61
209
|
}
|
|
62
210
|
|
|
63
211
|
& path[fill] {
|
|
64
|
-
fill: ${props => props.color || "currentColor"};
|
|
212
|
+
fill: ${(props) => props.color || "currentColor"};
|
|
65
213
|
}
|
|
66
214
|
|
|
67
215
|
& svg {
|
|
68
|
-
width: ${props =>
|
|
216
|
+
width: ${(props) =>
|
|
69
217
|
props.width ||
|
|
70
218
|
props.theme.click.image[props.size || "medium"].size.width ||
|
|
71
219
|
"24px"};
|
|
72
|
-
height: ${props =>
|
|
220
|
+
height: ${(props) =>
|
|
73
221
|
props.height ||
|
|
74
222
|
props.theme.click.image[props.size || "medium"].size.height ||
|
|
75
223
|
"24px"};
|
|
76
224
|
}
|
|
77
225
|
|
|
78
226
|
& svg[stroke] {
|
|
79
|
-
stroke: ${props => props.color || "currentColor"};
|
|
227
|
+
stroke: ${(props) => props.color || "currentColor"};
|
|
80
228
|
}
|
|
81
229
|
|
|
82
230
|
& svg[fill]:not([fill="none"]) {
|
|
83
|
-
fill: ${props => props.color || "currentColor"};
|
|
231
|
+
fill: ${(props) => props.color || "currentColor"};
|
|
84
232
|
}
|
|
85
233
|
`;
|
|
86
234
|
|