|
1 | | -import { Meta } from "@storybook/blocks"; |
2 | | -import { Link, Tip } from "vibe-storybook-components"; |
3 | | -import { Dropdown } from "@vibe/core/next"; |
4 | | -import * as DropdownStories from "./Dropdown.stories"; |
| 1 | +import { Canvas, Meta } from "@storybook/blocks"; |
| 2 | +import { Link, Tip, StorybookLink } from "vibe-storybook-components"; |
| 3 | +import { Overview as BasicDropdownPreview } from "./DropdownBasicDropdown.stories"; |
| 4 | +import { Overview as BoxModePreview } from "./DropdownBoxMode.stories"; |
5 | 5 | import do1 from "./assets/do1.png"; |
6 | 6 | import dont1 from "./assets/dont1.png"; |
7 | 7 |
|
8 | | -<Meta of={DropdownStories} /> |
| 8 | +<Meta title="Components/Dropdown [New]" /> |
9 | 9 |
|
10 | 10 | # Dropdown |
11 | 11 |
|
12 | | -Dropdown present a list of options from which a user can select one or several. |
13 | | - |
14 | | -<br /> |
| 12 | +Select component present a list of options from which a user can select one or several. |
15 | 13 |
|
16 | 14 | <Tip title="Migration Guide Available" emoji="🚀"> |
17 | 15 | Migrating from the old Dropdown? Check out our comprehensive{" "} |
18 | 16 | <Link href="/?path=/docs/components-dropdown-new-migration-guide--docs">Dropdown Migration Guide</Link> for |
19 | 17 | step-by-step instructions, breaking changes, and new features. |
20 | 18 | </Tip> |
21 | 19 |
|
22 | | -<Canvas of={DropdownStories.Overview} /> |
23 | | - |
24 | 20 | ### Import |
25 | 21 |
|
| 22 | +All the Dropdown-related components can be imported from `@vibe/core/next`. |
| 23 | + |
26 | 24 | ```js |
27 | 25 | import { Dropdown } from "@vibe/core/next"; |
28 | 26 | ``` |
29 | 27 |
|
30 | | -## Props |
| 28 | +### Basic dropdown |
31 | 29 |
|
32 | | -<PropsTable /> |
| 30 | +The <StorybookLink page="Components/Dropdown [New]/Basic dropdown">Basic dropdown</StorybookLink> present a popup list of options from which a user can select one or several. |
33 | 31 |
|
34 | | -## Usage |
| 32 | +<Canvas of={BasicDropdownPreview} sourceState="none" /> |
35 | 33 |
|
36 | | -<UsageGuidelines |
37 | | - guidelines={[ |
38 | | - "Dropdown menus are typically used when you have 5-8 items to choose from. They're used for navigation or command menus, where an action is initiated based on the selection.", |
39 | | - "Use a consistent size of form components on the same page. For example, if you are using a medium size dropdown also use the same size text inputs, buttons, and so on.", |
40 | | - "Avoid having multiple lines of text in a dropdown. If the text is too long for one line, add an ellipsis (…).", |
41 | | - "When the menu is open, each option in the menu should be the same height as the field.", |
42 | | - "When organizing dropdown menu items, sort the list in a logical order by putting the most selected option at the top." |
43 | | - ]} |
44 | | -/> |
| 34 | +### Dropdown box mode |
| 35 | + |
| 36 | +The <StorybookLink page="Components/Dropdown [New]/Dropdown box mode">Dropdown box mode</StorybookLink> is an always open Dropdown, with the same properties as the basic Dropdown. |
| 37 | + |
| 38 | +<Canvas of={BoxModePreview} sourceState="none" /> |
45 | 39 |
|
46 | | -## Accessibility |
| 40 | +## Usage |
47 | 41 |
|
48 | 42 | <UsageGuidelines |
49 | 43 | guidelines={[ |
50 | | - <> |
51 | | - Using an <code>id</code> is highly recommended for all instances to ensure proper label association. |
52 | | - </>, |
53 | | - <> |
54 | | - Always provide a <code>label</code> prop to ensure the dropdown's purpose is clear to all users. |
55 | | - </>, |
56 | | - <> |
57 | | - Use <code>ariaLabel</code> prop when you need to provide a custom accessible name for the dropdown. |
58 | | - </>, |
59 | | - <> |
60 | | - Use <code>clearAriaLabel</code> prop when dropdown is clearable. |
61 | | - </>, |
62 | | - <> |
63 | | - Use <code>inputAriaLabel</code> prop when you need to provide a specific accessible name for the input field in |
64 | | - searchable dropdowns. |
65 | | - </>, |
66 | | - <> |
67 | | - Use <code>menuAriaLabel</code> prop when you need to provide a custom accessible name for the dropdown menu. |
68 | | - </>, |
69 | | - <> |
70 | | - Use <code>autoFocus</code> prop when the dropdown should receive initial focus for keyboard navigation. |
71 | | - </> |
| 44 | + "When the user needs to choose one or multiple values from a fixed set of options.", |
| 45 | + "When the selected value needs to be visible after selection.", |
| 46 | + "When the selection is part of a form, filter, or preference setting." |
72 | 47 | ]} |
73 | 48 | /> |
74 | 49 |
|
75 | | -## Variants |
76 | | - |
77 | | -### Sizes |
78 | | - |
79 | | -There are three sizes available: Small, Medium, and Large |
80 | | - |
81 | | -<Canvas of={DropdownStories.Sizes} /> |
82 | | - |
83 | | -### States |
84 | | - |
85 | | -<Canvas of={DropdownStories.States} /> |
86 | | - |
87 | | -### Multi-select |
88 | | - |
89 | | -The Dropdown component supports multi select option that display as chips. The selected items can be shown in either a single line (with additional option for hidden list), or multiple line. This mode also supports all standard dropdown states. |
90 | | - |
91 | | -<Canvas of={DropdownStories.MultiSelect} /> |
92 | | - |
93 | | -### Dropdown with icon or avatar |
94 | | - |
95 | | -<Canvas of={DropdownStories.DropdownWithIconOrAvatar} /> |
96 | | - |
97 | | -## Do’s and Don’ts |
| 50 | +## Do's and Don'ts |
98 | 51 |
|
99 | 52 | <ComponentRules |
100 | 53 | rules={[ |
101 | 54 | { |
102 | 55 | positive: { |
103 | 56 | component: <img src={do1} alt="do1" style={{ width: "300px" }} />, |
104 | | - description: |
105 | | - "Use the dropdown as a closed component. Users should normally be allowed only to click on the items; search is not recommended, though possible." |
| 57 | + description: "Use the select when theres a need to choose one or multiple options from a predefined list." |
106 | 58 | }, |
107 | 59 | negative: { |
108 | 60 | component: <img src={dont1} alt="dont1" style={{ width: "200px" }} />, |
109 | 61 | description: ( |
110 | 62 | <> |
111 | | - Don't keep the dropdown component in open mode as permanent state. If this is a design requirement consider |
112 | | - use <StorybookLink page="Components/Combobox">Combo box</StorybookLink> instead. |
| 63 | + Use select when the purpose of the list is to provide actions or navigation options. Use a{" "} |
| 64 | + <StorybookLink page="Components/Menu">menu</StorybookLink> instead. |
113 | 65 | </> |
114 | 66 | ) |
115 | 67 | } |
116 | 68 | } |
117 | 69 | ]} |
118 | 70 | /> |
119 | 71 |
|
120 | | -## Use cases and examples |
121 | | - |
122 | | -### Searchable dropdown |
123 | | - |
124 | | -The dropdown can also function as a search for a specific item within the list. |
125 | | - |
126 | | -<Canvas of={DropdownStories.Searchable} /> |
127 | | - |
128 | | -### Dropdown with groups |
129 | | - |
130 | | -Dropdown menu can be organized into groups, either with titled sections or dividers. Group titles can be configured to remain sticky or non-sticky. |
131 | | - |
132 | | -<Canvas of={DropdownStories.DropdownWithGroups} /> |
133 | | - |
134 | | -### Dropdown item with elements |
135 | | - |
136 | | -The dropdown item can contain start element or end element. This are the options: |
137 | | - |
138 | | -<Canvas of={DropdownStories.DropdownItemWithElements} /> |
139 | | - |
140 | | -### Hide selected items |
141 | | - |
142 | | -You can choose to hide selected items within the dropdown list, so users can see only the available options. |
143 | | - |
144 | | -<Canvas of={DropdownStories.DropdownHideSelectedItems} /> |
145 | | - |
146 | | -### Dropdown with tooltips |
147 | | - |
148 | | -<Canvas of={DropdownStories.DropdownWithTooltips} /> |
149 | | - |
150 | | -### Dropdown with virtualization |
151 | | - |
152 | | -For performance optimization with large datasets, the Dropdown supports virtualization through the menuRenderer prop. You can integrate any virtualization library of your choice - this example demonstrates implementation using <a href="https://github.com/bvaughn/react-window" target="_blank">react-window</a>. |
153 | | - |
154 | | -<Canvas of={DropdownStories.DropdownWithVirtualization} /> |
155 | | - |
156 | | -### Dropdown in box mode |
157 | | - |
158 | | -The Dropdown component supports box mode, which displays the dropdown in a box-like container. This mode is useful when you want to display the dropdown in a fixed-width container, such as a modal or a card. |
159 | | - |
160 | | -<Canvas of={DropdownStories.BoxMode} /> |
161 | | - |
162 | 72 | ## Related components |
163 | 73 |
|
164 | 74 | <RelatedComponents componentsNames={["Combobox", "SplitButton", "Menu"]} /> |
0 commit comments