@hyphen/hyphen-components 2.22.1 → 2.24.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/dist/components/Collapsible/Collapsible.d.ts +5 -0
- package/dist/components/Collapsible/Collapsible.stories.d.ts +9 -0
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +25 -0
- package/dist/components/DropdownMenu/DropdownMenu.stories.d.ts +9 -0
- package/dist/css/utilities.css +62 -1
- package/dist/css/variables.css +15 -2
- package/dist/hyphen-components.cjs.development.js +9 -0
- package/dist/hyphen-components.cjs.development.js.map +1 -1
- package/dist/hyphen-components.cjs.production.min.js +1 -1
- package/dist/hyphen-components.cjs.production.min.js.map +1 -1
- package/dist/hyphen-components.esm.js +6 -1
- package/dist/hyphen-components.esm.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/lib/tokens.d.ts +2 -2
- package/package.json +7 -4
- package/src/components/Collapsible/Collapsible.mdx +21 -0
- package/src/components/Collapsible/Collapsible.stories.tsx +104 -0
- package/src/components/Collapsible/Collapsible.tsx +9 -0
- package/src/components/DropdownMenu/DropdownMenu.mdx +21 -0
- package/src/components/DropdownMenu/DropdownMenu.stories.tsx +150 -0
- package/src/components/DropdownMenu/DropdownMenu.tsx +164 -0
- package/src/index.ts +1 -0
- package/src/styles/utilities.scss +4 -0
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './components/Button/Button';
|
|
|
5
5
|
export * from './components/Card/Card';
|
|
6
6
|
export * from './components/CheckboxInput/components/Checkbox';
|
|
7
7
|
export * from './components/CheckboxInput/CheckboxInput';
|
|
8
|
+
export * from './components/Collapsible/Collapsible';
|
|
8
9
|
export * from './components/DateInput/DateInput';
|
|
9
10
|
export * from './components/DatePicker/DatePicker';
|
|
10
11
|
export * from './components/Details/Details';
|
package/dist/lib/tokens.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BorderRadiusSize, Breakpoint, BreakpointSizeWithBase } from '../types';
|
|
2
|
-
export declare const ICON_NAMES: ("add" | "alarm-disable" | "alarm" | "analytics" | "arrow-down" | "arrow-left" | "arrow-right" | "arrow-up" | "arrows-maximize" | "at" | "ban" | "block" | "blocks" | "book-open" | "c-add" | "c-check" | "c-delete" | "c-in-progress" | "c-info" | "c-question" | "c-remove" | "c-warning" | "calendar-create" | "calendar" | "camera" | "caret-down" | "caret-left" | "caret-right" | "caret-sm-down" | "caret-sm-left" | "caret-sm-right" | "caret-sm-up" | "caret-up" | "chart-bar" | "chart-line" | "chat" | "check" | "checkbox-btn-checked" | "checkbox-btn-indeterminate" | "checkbox-btn" | "circle-filled" | "circle" | "clipboard" | "cloud" | "contact" | "copy-document" | "dashboard" | "database" | "document" | "dots" | "download" | "electricity-bolt" | "exclamation-mark" | "eye-slash" | "eye" | "filter" | "flag" | "gear" | "grab" | "hash-mark" | "heart-o" | "heart" | "home" | "info" | "integrations" | "key" | "launch-app" | "lightbulb" | "link" | "list" | "lock" | "logo-env" | "logo-link" | "logo-toggle" | "mail" | "menu" | "minus" | "moon" | "paperclip" | "path-intersect" | "pause" | "pc" | "pencil" | "phone" | "photo" | "play" | "radio-btn-checked" | "radio-btn-unchecked" | "refresh" | "remove" | "rewind" | "search" | "send" | "settings" | "skip" | "stack" | "star-o" | "star" | "stopwatch" | "subtract" | "sun" | "t-warning" | "tag" | "terminal" | "time-alarm" | "time-clock" | "trash" | "unlocked" | "upload" | "user-create" | "user" | "users" | "wifi-off" | "wifi" | "zoom-in" | "zoom-out")[];
|
|
2
|
+
export declare const ICON_NAMES: ("add" | "alarm-disable" | "alarm" | "analytics" | "arrow-down" | "arrow-left" | "arrow-right" | "arrow-up" | "arrows-maximize" | "at" | "ban" | "block" | "blocks" | "book-open" | "c-add" | "c-check" | "c-delete" | "c-in-progress" | "c-info" | "c-question" | "c-remove" | "c-warning" | "calendar-create" | "calendar" | "camera" | "caret-down" | "caret-left" | "caret-right" | "caret-sm-down" | "caret-sm-left" | "caret-sm-right" | "caret-sm-up" | "caret-up-down" | "caret-up" | "chart-bar" | "chart-line" | "chat" | "check" | "checkbox-btn-checked" | "checkbox-btn-indeterminate" | "checkbox-btn" | "circle-filled" | "circle" | "clipboard" | "cloud" | "contact" | "copy-document" | "dashboard" | "database" | "dock-left" | "document" | "dots" | "download" | "electricity-bolt" | "exclamation-mark" | "eye-slash" | "eye" | "filter" | "flag" | "gear" | "grab" | "hash-mark" | "heart-o" | "heart" | "home" | "info" | "integrations" | "key" | "launch-app" | "lightbulb" | "link" | "list" | "lock" | "logo-env" | "logo-link" | "logo-toggle" | "logout" | "mail" | "menu" | "minus" | "moon" | "paperclip" | "path-intersect" | "pause" | "pc" | "pencil" | "phone" | "photo" | "play" | "radio-btn-checked" | "radio-btn-unchecked" | "refresh" | "remove" | "rewind" | "search" | "send" | "settings" | "skip" | "stack" | "star-o" | "star" | "stopwatch" | "subtract" | "sun" | "t-warning" | "tag" | "terminal" | "time-alarm" | "time-clock" | "trash" | "unlocked" | "upload" | "user-create" | "user" | "users" | "wifi-off" | "wifi" | "zoom-in" | "zoom-out")[];
|
|
3
3
|
export declare const BORDER_RADIUS_OPTIONS: BorderRadiusSize[];
|
|
4
4
|
export declare const BORDER_SIZE_OPTIONS: ("0" | "sm" | "md" | "lg")[];
|
|
5
5
|
export declare const BREAKPOINT_OPTIONS: BreakpointSizeWithBase[];
|
|
@@ -14,7 +14,7 @@ export declare const FONT_FAMILY_OPTIONS: ("monospace" | "body" | "brand")[];
|
|
|
14
14
|
export declare const FONT_WEIGHT_OPTIONS: ("light" | "normal" | "medium" | "semibold" | "bold")[];
|
|
15
15
|
export declare const HEADING_SIZE_OPTIONS: ("sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl")[];
|
|
16
16
|
export declare const HEIGHT_OPTIONS: ("0" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "2xs" | "4xl" | "5xl" | "6xl" | "7xl" | "8xl" | "9xl" | "10xl" | "10" | "15" | "20" | "25" | "30" | "33" | "34" | "40" | "50" | "60" | "70" | "75" | "80" | "90" | "100")[];
|
|
17
|
-
export declare const LINE_HEIGHT_OPTIONS: ("base" | "input" | "heading" | "text")[];
|
|
17
|
+
export declare const LINE_HEIGHT_OPTIONS: ("base" | "none" | "input" | "heading" | "text")[];
|
|
18
18
|
export declare const SPACING_OPTIONS: ("0" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "2xs" | "4xl" | "5xl" | "auto")[];
|
|
19
19
|
export declare const WIDTH_OPTIONS: ("0" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "2xs" | "4xl" | "5xl" | "6xl" | "7xl" | "8xl" | "9xl" | "10xl" | "10" | "15" | "20" | "25" | "30" | "33" | "34" | "40" | "50" | "60" | "70" | "75" | "80" | "90" | "100")[];
|
|
20
20
|
export declare const Z_INDEX_OPTIONS: ("0" | "modal" | "popover" | "overlay" | "drawer" | "sticky")[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyphen/hyphen-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.24.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "@hyphen"
|
|
@@ -65,13 +65,13 @@
|
|
|
65
65
|
"@chromatic-com/storybook": "^1.8.0",
|
|
66
66
|
"@semantic-release/commit-analyzer": "^11.1.0",
|
|
67
67
|
"@size-limit/preset-small-lib": "^11.1.4",
|
|
68
|
-
"@storybook/addon-essentials": "^8.2
|
|
68
|
+
"@storybook/addon-essentials": "^8.4.2",
|
|
69
69
|
"@storybook/addon-interactions": "^8.3.5",
|
|
70
70
|
"@storybook/addon-themes": "^8.2.9",
|
|
71
71
|
"@storybook/blocks": "^8.2.9",
|
|
72
72
|
"@storybook/manager-api": "^8.2.9",
|
|
73
73
|
"@storybook/react": "^8.2.9",
|
|
74
|
-
"@storybook/react-vite": "^8.2
|
|
74
|
+
"@storybook/react-vite": "^8.4.2",
|
|
75
75
|
"@storybook/test": "^8.3.5",
|
|
76
76
|
"@storybook/theming": "^8.2.9",
|
|
77
77
|
"@testing-library/jest-dom": "^6.5.0",
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
"@testing-library/user-event": "^14.5.2",
|
|
80
80
|
"@tsconfig/recommended": "^1.0.7",
|
|
81
81
|
"@tsconfig/vite-react": "^3.0.2",
|
|
82
|
+
"@types/node": "^22.9.0",
|
|
82
83
|
"@types/react": "^18.3.5",
|
|
83
84
|
"@types/react-datepicker": "^6.2.0",
|
|
84
85
|
"@types/react-dom": "^18.3.0",
|
|
@@ -121,8 +122,10 @@
|
|
|
121
122
|
"@rollup/rollup-linux-x64-gnu": "^4.21.2"
|
|
122
123
|
},
|
|
123
124
|
"dependencies": {
|
|
124
|
-
"@hyphen/hyphen-design-tokens": "^4.
|
|
125
|
+
"@hyphen/hyphen-design-tokens": "^4.18.0",
|
|
125
126
|
"@popperjs/core": "^2.11.8",
|
|
127
|
+
"@radix-ui/react-collapsible": "^1.1.1",
|
|
128
|
+
"@radix-ui/react-dropdown-menu": "^2.1.2",
|
|
126
129
|
"@types/react-modal": "^3.16.3",
|
|
127
130
|
"classnames": "^2.5.1",
|
|
128
131
|
"date-fns": "^2.16.1",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Canvas, Meta, ArgTypes } from '@storybook/blocks';
|
|
2
|
+
import { Collapsible, CollapsibleTrigger } from './Collapsible';
|
|
3
|
+
import * as Stories from './Collapsible.stories';
|
|
4
|
+
|
|
5
|
+
<Meta of={Stories} />
|
|
6
|
+
|
|
7
|
+
# Collapsible
|
|
8
|
+
|
|
9
|
+
Collapsible components are used to hide or show content based on user interaction.
|
|
10
|
+
|
|
11
|
+
This component is extended from [Radix](https://www.radix-ui.com/primitives/docs/components/collapsible).
|
|
12
|
+
|
|
13
|
+
[API Reference](https://www.radix-ui.com/primitives/docs/components/collapsible#api-reference)
|
|
14
|
+
|
|
15
|
+
<Canvas of={Stories.Uncontrolled} />
|
|
16
|
+
|
|
17
|
+
## Controlled
|
|
18
|
+
|
|
19
|
+
The `open` prop can be used to control the state of the collapsible component.
|
|
20
|
+
|
|
21
|
+
<Canvas of={Stories.Controlled} />
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import {
|
|
4
|
+
Collapsible,
|
|
5
|
+
CollapsibleTrigger,
|
|
6
|
+
CollapsibleContent,
|
|
7
|
+
} from './Collapsible';
|
|
8
|
+
import { Button } from '../Button/Button';
|
|
9
|
+
import { Box } from '../Box/Box';
|
|
10
|
+
import { userEvent, within, expect } from '@storybook/test';
|
|
11
|
+
|
|
12
|
+
const meta: Meta<typeof Collapsible> = {
|
|
13
|
+
title: 'Components/Collapsible',
|
|
14
|
+
component: Collapsible,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default meta;
|
|
18
|
+
type Story = StoryObj<typeof Collapsible>;
|
|
19
|
+
|
|
20
|
+
export const Uncontrolled = () => (
|
|
21
|
+
<Collapsible>
|
|
22
|
+
<CollapsibleTrigger asChild>
|
|
23
|
+
<Button variant="primary">Can I use this in my project?</Button>
|
|
24
|
+
</CollapsibleTrigger>
|
|
25
|
+
<CollapsibleContent>
|
|
26
|
+
Yes. Free to use for personal and commercial projects. No attribution
|
|
27
|
+
required.
|
|
28
|
+
</CollapsibleContent>
|
|
29
|
+
</Collapsible>
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
export function Controlled() {
|
|
33
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Collapsible
|
|
37
|
+
open={isOpen}
|
|
38
|
+
onOpenChange={setIsOpen}
|
|
39
|
+
className="display-flex flex-direction-column g-sm w-9xl"
|
|
40
|
+
>
|
|
41
|
+
<Box
|
|
42
|
+
alignItems="center"
|
|
43
|
+
justifyContent="space-between"
|
|
44
|
+
padding="sm 0"
|
|
45
|
+
direction="row"
|
|
46
|
+
>
|
|
47
|
+
<h4 className="text-sm font-semibold">
|
|
48
|
+
@peduarte starred 3 repositories
|
|
49
|
+
</h4>
|
|
50
|
+
<CollapsibleTrigger asChild>
|
|
51
|
+
<Button
|
|
52
|
+
variant="tertiary"
|
|
53
|
+
iconPrefix={isOpen ? 'remove' : 'caret-up-down'}
|
|
54
|
+
size="sm"
|
|
55
|
+
aria-label="toggle"
|
|
56
|
+
/>
|
|
57
|
+
</CollapsibleTrigger>
|
|
58
|
+
</Box>
|
|
59
|
+
<Box
|
|
60
|
+
fontFamily="monospace"
|
|
61
|
+
radius="sm"
|
|
62
|
+
padding="md"
|
|
63
|
+
fontSize="sm"
|
|
64
|
+
borderWidth="sm"
|
|
65
|
+
borderColor="default"
|
|
66
|
+
>
|
|
67
|
+
@radix-ui/primitives
|
|
68
|
+
</Box>
|
|
69
|
+
<CollapsibleContent className="display-flex flex-direction-column g-sm">
|
|
70
|
+
<Box
|
|
71
|
+
fontFamily="monospace"
|
|
72
|
+
radius="sm"
|
|
73
|
+
padding="md"
|
|
74
|
+
fontSize="sm"
|
|
75
|
+
borderWidth="sm"
|
|
76
|
+
borderColor="default"
|
|
77
|
+
>
|
|
78
|
+
@radix-ui/colors
|
|
79
|
+
</Box>
|
|
80
|
+
<Box
|
|
81
|
+
fontFamily="monospace"
|
|
82
|
+
radius="sm"
|
|
83
|
+
padding="md"
|
|
84
|
+
fontSize="sm"
|
|
85
|
+
borderWidth="sm"
|
|
86
|
+
borderColor="default"
|
|
87
|
+
>
|
|
88
|
+
@stitches/react
|
|
89
|
+
</Box>
|
|
90
|
+
</CollapsibleContent>
|
|
91
|
+
</Collapsible>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export const ClickOpenCollapsible: Story = {
|
|
96
|
+
play: async ({ canvasElement, mount }) => {
|
|
97
|
+
await mount(<Controlled />);
|
|
98
|
+
const canvas = within(canvasElement);
|
|
99
|
+
|
|
100
|
+
await userEvent.click(canvas.getByLabelText('toggle'));
|
|
101
|
+
|
|
102
|
+
await expect(canvas.getByText('@radix-ui/colors')).toBeInTheDocument();
|
|
103
|
+
},
|
|
104
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
|
|
2
|
+
|
|
3
|
+
const Collapsible = CollapsiblePrimitive.Root;
|
|
4
|
+
|
|
5
|
+
const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger;
|
|
6
|
+
|
|
7
|
+
const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent;
|
|
8
|
+
|
|
9
|
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Canvas, Meta, ArgTypes } from '@storybook/blocks';
|
|
2
|
+
import { DropdownMenu } from './DropdownMenu';
|
|
3
|
+
import * as Stories from './DropdownMenu.stories';
|
|
4
|
+
|
|
5
|
+
<Meta of={Stories} />
|
|
6
|
+
|
|
7
|
+
# DropdownMenu
|
|
8
|
+
|
|
9
|
+
DropdownMenu components are used to hide or show content based on user interaction.
|
|
10
|
+
|
|
11
|
+
This component is extended from [Radix](https://www.radix-ui.com/primitives/docs/components/dropdown-menu).
|
|
12
|
+
|
|
13
|
+
[API Reference](https://www.radix-ui.com/primitives/docs/components/dropdown-menu#api-reference)
|
|
14
|
+
|
|
15
|
+
<Canvas of={Stories.Uncontrolled} />
|
|
16
|
+
|
|
17
|
+
## Controlled
|
|
18
|
+
|
|
19
|
+
The `open` prop can be used to control the state of the DropdownMenu component.
|
|
20
|
+
|
|
21
|
+
<Canvas of={Stories.Controlled} />
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { Button } from '../Button/Button';
|
|
4
|
+
import { userEvent, within, expect } from '@storybook/test';
|
|
5
|
+
import {
|
|
6
|
+
DropdownMenu,
|
|
7
|
+
DropdownMenuTrigger,
|
|
8
|
+
DropdownMenuContent,
|
|
9
|
+
DropdownMenuLabel,
|
|
10
|
+
DropdownMenuSeparator,
|
|
11
|
+
DropdownMenuGroup,
|
|
12
|
+
DropdownMenuItem,
|
|
13
|
+
DropdownMenuSub,
|
|
14
|
+
DropdownMenuSubContent,
|
|
15
|
+
DropdownMenuSubTrigger,
|
|
16
|
+
DropdownMenuPortal,
|
|
17
|
+
} from './DropdownMenu';
|
|
18
|
+
import { DropdownMenuShortcut } from './DropdownMenu';
|
|
19
|
+
|
|
20
|
+
const meta: Meta<typeof DropdownMenu> = {
|
|
21
|
+
title: 'Components/DropdownMenu',
|
|
22
|
+
component: DropdownMenu,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default meta;
|
|
26
|
+
type Story = StoryObj<typeof DropdownMenu>;
|
|
27
|
+
|
|
28
|
+
export const Uncontrolled = () => (
|
|
29
|
+
<DropdownMenu>
|
|
30
|
+
<DropdownMenuTrigger asChild>
|
|
31
|
+
<Button variant="secondary">Open</Button>
|
|
32
|
+
</DropdownMenuTrigger>
|
|
33
|
+
<DropdownMenuContent
|
|
34
|
+
className="w-9xl"
|
|
35
|
+
align="start"
|
|
36
|
+
side="bottom"
|
|
37
|
+
sideOffset={4}
|
|
38
|
+
>
|
|
39
|
+
<DropdownMenuLabel>My Account</DropdownMenuLabel>
|
|
40
|
+
<DropdownMenuSeparator />
|
|
41
|
+
<DropdownMenuGroup>
|
|
42
|
+
<DropdownMenuItem>
|
|
43
|
+
<span>Profile</span>
|
|
44
|
+
<DropdownMenuShortcut>⇧⌘P</DropdownMenuShortcut>
|
|
45
|
+
</DropdownMenuItem>
|
|
46
|
+
<DropdownMenuItem>
|
|
47
|
+
<span>Billing</span>
|
|
48
|
+
<DropdownMenuShortcut>⌘B</DropdownMenuShortcut>
|
|
49
|
+
</DropdownMenuItem>
|
|
50
|
+
<DropdownMenuItem>
|
|
51
|
+
<span>Settings</span>
|
|
52
|
+
<DropdownMenuShortcut>⌘S</DropdownMenuShortcut>
|
|
53
|
+
</DropdownMenuItem>
|
|
54
|
+
<DropdownMenuItem>
|
|
55
|
+
<span>Keyboard shortcuts</span>
|
|
56
|
+
<DropdownMenuShortcut>⌘K</DropdownMenuShortcut>
|
|
57
|
+
</DropdownMenuItem>
|
|
58
|
+
</DropdownMenuGroup>
|
|
59
|
+
<DropdownMenuSeparator />
|
|
60
|
+
<DropdownMenuGroup>
|
|
61
|
+
<DropdownMenuItem>
|
|
62
|
+
<span>Team</span>
|
|
63
|
+
</DropdownMenuItem>
|
|
64
|
+
<DropdownMenuSub>
|
|
65
|
+
<DropdownMenuSubTrigger>
|
|
66
|
+
<span>Invite users</span>
|
|
67
|
+
</DropdownMenuSubTrigger>
|
|
68
|
+
<DropdownMenuPortal>
|
|
69
|
+
<DropdownMenuSubContent>
|
|
70
|
+
<DropdownMenuItem>
|
|
71
|
+
<span>Email</span>
|
|
72
|
+
</DropdownMenuItem>
|
|
73
|
+
<DropdownMenuItem>
|
|
74
|
+
<span>Message</span>
|
|
75
|
+
</DropdownMenuItem>
|
|
76
|
+
<DropdownMenuSeparator />
|
|
77
|
+
<DropdownMenuItem>
|
|
78
|
+
<span>More...</span>
|
|
79
|
+
</DropdownMenuItem>
|
|
80
|
+
</DropdownMenuSubContent>
|
|
81
|
+
</DropdownMenuPortal>
|
|
82
|
+
</DropdownMenuSub>
|
|
83
|
+
<DropdownMenuItem>
|
|
84
|
+
<span>New Team</span>
|
|
85
|
+
<DropdownMenuShortcut>⌘+T</DropdownMenuShortcut>
|
|
86
|
+
</DropdownMenuItem>
|
|
87
|
+
</DropdownMenuGroup>
|
|
88
|
+
<DropdownMenuSeparator />
|
|
89
|
+
<DropdownMenuItem>
|
|
90
|
+
<span>Support</span>
|
|
91
|
+
</DropdownMenuItem>
|
|
92
|
+
<DropdownMenuItem disabled>
|
|
93
|
+
<span>API</span>
|
|
94
|
+
</DropdownMenuItem>
|
|
95
|
+
<DropdownMenuSeparator />
|
|
96
|
+
<DropdownMenuItem>
|
|
97
|
+
<span>Log out</span>
|
|
98
|
+
<DropdownMenuShortcut>⇧⌘Q</DropdownMenuShortcut>
|
|
99
|
+
</DropdownMenuItem>
|
|
100
|
+
</DropdownMenuContent>
|
|
101
|
+
</DropdownMenu>
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
export const Controlled = () => {
|
|
105
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<div>
|
|
109
|
+
<p>{`Dropdown is ${isOpen ? 'open' : 'closed'}`}</p>
|
|
110
|
+
<DropdownMenu open={isOpen} onOpenChange={setIsOpen}>
|
|
111
|
+
<DropdownMenuTrigger asChild>
|
|
112
|
+
<Button variant="secondary">Dropdown</Button>
|
|
113
|
+
</DropdownMenuTrigger>
|
|
114
|
+
<DropdownMenuContent
|
|
115
|
+
className="w-9xl"
|
|
116
|
+
align="start"
|
|
117
|
+
side="bottom"
|
|
118
|
+
sideOffset={4}
|
|
119
|
+
>
|
|
120
|
+
<DropdownMenuItem>
|
|
121
|
+
<span>Profile</span>
|
|
122
|
+
<DropdownMenuShortcut>⇧⌘P</DropdownMenuShortcut>
|
|
123
|
+
</DropdownMenuItem>
|
|
124
|
+
<DropdownMenuItem>
|
|
125
|
+
<span>Billing</span>
|
|
126
|
+
<DropdownMenuShortcut>⌘B</DropdownMenuShortcut>
|
|
127
|
+
</DropdownMenuItem>
|
|
128
|
+
<DropdownMenuItem>
|
|
129
|
+
<span>Settings</span>
|
|
130
|
+
<DropdownMenuShortcut>⌘S</DropdownMenuShortcut>
|
|
131
|
+
</DropdownMenuItem>
|
|
132
|
+
<DropdownMenuItem>
|
|
133
|
+
<span>Keyboard shortcuts</span>
|
|
134
|
+
<DropdownMenuShortcut>⌘K</DropdownMenuShortcut>
|
|
135
|
+
</DropdownMenuItem>
|
|
136
|
+
</DropdownMenuContent>
|
|
137
|
+
</DropdownMenu>
|
|
138
|
+
</div>
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export const ClickOpenDropdown: Story = {
|
|
143
|
+
play: async ({ canvasElement, mount }) => {
|
|
144
|
+
await mount(<Controlled />);
|
|
145
|
+
const canvas = within(canvasElement);
|
|
146
|
+
await expect(canvas.getByText('Dropdown is closed')).toBeInTheDocument();
|
|
147
|
+
await userEvent.click(canvas.getByText('Dropdown'));
|
|
148
|
+
await expect(canvas.getByText('Dropdown is open')).toBeInTheDocument();
|
|
149
|
+
},
|
|
150
|
+
};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
3
|
+
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import { Icon } from '../Icon/Icon';
|
|
6
|
+
|
|
7
|
+
const DropdownMenu = DropdownMenuPrimitive.Root;
|
|
8
|
+
|
|
9
|
+
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
10
|
+
|
|
11
|
+
const DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
|
12
|
+
|
|
13
|
+
const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
|
|
14
|
+
|
|
15
|
+
const DropdownMenuSub = DropdownMenuPrimitive.Sub;
|
|
16
|
+
|
|
17
|
+
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
18
|
+
|
|
19
|
+
const DropdownMenuItem = React.forwardRef<
|
|
20
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
|
|
21
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
|
|
22
|
+
inset?: boolean;
|
|
23
|
+
}
|
|
24
|
+
>(({ className, inset, ...props }, ref) => (
|
|
25
|
+
<DropdownMenuPrimitive.Item
|
|
26
|
+
ref={ref}
|
|
27
|
+
className={classNames(
|
|
28
|
+
'font-size-sm position-relative cursor-default display-flex br-sm align-items-center p-sm g-sm outline-none hover:background-color-secondary focus:background-color-secondary',
|
|
29
|
+
inset && 'p-left-md',
|
|
30
|
+
className
|
|
31
|
+
)}
|
|
32
|
+
{...props}
|
|
33
|
+
/>
|
|
34
|
+
));
|
|
35
|
+
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
|
|
36
|
+
|
|
37
|
+
const DropdownMenuContent = React.forwardRef<
|
|
38
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
|
|
39
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
|
|
40
|
+
>(({ className, sideOffset = 4, ...props }, ref) => (
|
|
41
|
+
<DropdownMenuPrimitive.Portal>
|
|
42
|
+
<DropdownMenuPrimitive.Content
|
|
43
|
+
ref={ref}
|
|
44
|
+
sideOffset={sideOffset}
|
|
45
|
+
className={classNames(
|
|
46
|
+
'z-index-popover p-xs minw-7xl overflow-hidden br-sm bw-sm border-color-subtle background-color-primary font-color-base shadow-md',
|
|
47
|
+
className
|
|
48
|
+
)}
|
|
49
|
+
style={{
|
|
50
|
+
width: 'var(--radix-dropdown-menu-trigger-width)',
|
|
51
|
+
}}
|
|
52
|
+
{...props}
|
|
53
|
+
/>
|
|
54
|
+
</DropdownMenuPrimitive.Portal>
|
|
55
|
+
));
|
|
56
|
+
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
|
57
|
+
|
|
58
|
+
const DropdownMenuLabel = React.forwardRef<
|
|
59
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
|
|
60
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
|
|
61
|
+
inset?: boolean;
|
|
62
|
+
}
|
|
63
|
+
>(({ className, inset, ...props }, ref) => (
|
|
64
|
+
<DropdownMenuPrimitive.Label
|
|
65
|
+
ref={ref}
|
|
66
|
+
className={classNames(
|
|
67
|
+
'display-flex align-items-center br-sm p-h-sm p-v-xs font-color-secondary font-size-xs font-weight-medium outline-none',
|
|
68
|
+
inset && 'p-left-md',
|
|
69
|
+
className
|
|
70
|
+
)}
|
|
71
|
+
{...props}
|
|
72
|
+
/>
|
|
73
|
+
));
|
|
74
|
+
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
|
|
75
|
+
|
|
76
|
+
const DropdownMenuSeparator = React.forwardRef<
|
|
77
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
|
|
78
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
|
|
79
|
+
>(({ className, ...props }, ref) => (
|
|
80
|
+
<DropdownMenuPrimitive.Separator
|
|
81
|
+
ref={ref}
|
|
82
|
+
className={classNames(
|
|
83
|
+
'h-2xs m-v-xs bw-top-sm border-color-subtle',
|
|
84
|
+
className
|
|
85
|
+
)}
|
|
86
|
+
style={{
|
|
87
|
+
marginLeft: 'calc(var(--size-spacing-md)*-1)',
|
|
88
|
+
marginRight: 'calc(var(--size-spacing-md)*-1)',
|
|
89
|
+
}}
|
|
90
|
+
{...props}
|
|
91
|
+
/>
|
|
92
|
+
));
|
|
93
|
+
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
|
|
94
|
+
|
|
95
|
+
const DropdownMenuShortcut = ({
|
|
96
|
+
className,
|
|
97
|
+
...props
|
|
98
|
+
}: React.HTMLAttributes<HTMLSpanElement>) => {
|
|
99
|
+
return (
|
|
100
|
+
<span
|
|
101
|
+
className={classNames(
|
|
102
|
+
'm-left-auto font-size-xs font-color-tertiary',
|
|
103
|
+
className
|
|
104
|
+
)}
|
|
105
|
+
style={{ letterSpacing: '0.5px' }}
|
|
106
|
+
{...props}
|
|
107
|
+
/>
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
DropdownMenuShortcut.displayName = 'DropdownMenuShortcut';
|
|
111
|
+
|
|
112
|
+
const DropdownMenuSubTrigger = React.forwardRef<
|
|
113
|
+
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
|
|
114
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
|
|
115
|
+
inset?: boolean;
|
|
116
|
+
}
|
|
117
|
+
>(({ className, inset, children, ...props }, ref) => (
|
|
118
|
+
<DropdownMenuPrimitive.SubTrigger
|
|
119
|
+
ref={ref}
|
|
120
|
+
className={classNames(
|
|
121
|
+
'display-flex cursor-default gap-xl align-items-center br-sm p-sm g-sm font-size-sm outline-none focus:background-color-secondary',
|
|
122
|
+
inset && 'p-left-md',
|
|
123
|
+
className
|
|
124
|
+
)}
|
|
125
|
+
{...props}
|
|
126
|
+
>
|
|
127
|
+
{children}
|
|
128
|
+
<Icon name="caret-sm-right" className="m-left-auto" />
|
|
129
|
+
</DropdownMenuPrimitive.SubTrigger>
|
|
130
|
+
));
|
|
131
|
+
DropdownMenuSubTrigger.displayName =
|
|
132
|
+
DropdownMenuPrimitive.SubTrigger.displayName;
|
|
133
|
+
|
|
134
|
+
const DropdownMenuSubContent = React.forwardRef<
|
|
135
|
+
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
|
|
136
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
|
|
137
|
+
>(({ className, ...props }, ref) => (
|
|
138
|
+
<DropdownMenuPrimitive.SubContent
|
|
139
|
+
ref={ref}
|
|
140
|
+
className={classNames(
|
|
141
|
+
'z-index-popover minw-7xl overflow-hidden br-sm border-color-subtle bw-sm background-color-primary p-xs font-color-primary shadow-lg',
|
|
142
|
+
className
|
|
143
|
+
)}
|
|
144
|
+
{...props}
|
|
145
|
+
/>
|
|
146
|
+
));
|
|
147
|
+
DropdownMenuSubContent.displayName =
|
|
148
|
+
DropdownMenuPrimitive.SubContent.displayName;
|
|
149
|
+
|
|
150
|
+
export {
|
|
151
|
+
DropdownMenu,
|
|
152
|
+
DropdownMenuTrigger,
|
|
153
|
+
DropdownMenuContent,
|
|
154
|
+
DropdownMenuItem,
|
|
155
|
+
DropdownMenuLabel,
|
|
156
|
+
DropdownMenuSeparator,
|
|
157
|
+
DropdownMenuShortcut,
|
|
158
|
+
DropdownMenuSubContent,
|
|
159
|
+
DropdownMenuSubTrigger,
|
|
160
|
+
DropdownMenuGroup,
|
|
161
|
+
DropdownMenuPortal,
|
|
162
|
+
DropdownMenuSub,
|
|
163
|
+
DropdownMenuRadioGroup,
|
|
164
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './components/Button/Button';
|
|
|
5
5
|
export * from './components/Card/Card';
|
|
6
6
|
export * from './components/CheckboxInput/components/Checkbox';
|
|
7
7
|
export * from './components/CheckboxInput/CheckboxInput';
|
|
8
|
+
export * from './components/Collapsible/Collapsible';
|
|
8
9
|
export * from './components/DateInput/DateInput';
|
|
9
10
|
export * from './components/DatePicker/DatePicker';
|
|
10
11
|
export * from './components/Details/Details';
|