cleanplate 0.1.10 → 0.2.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/accordion/Accordion.d.ts +23 -12
- package/dist/components/accordion/Accordion.d.ts.map +1 -1
- package/dist/components/accordion/index.d.ts +2 -1
- package/dist/components/accordion/index.d.ts.map +1 -1
- package/dist/components/animated/Animated.d.ts +18 -16
- package/dist/components/animated/Animated.d.ts.map +1 -1
- package/dist/components/animated/index.d.ts +2 -2
- package/dist/components/animated/index.d.ts.map +1 -1
- package/dist/components/app-shell/AppShell.d.ts +35 -3
- package/dist/components/app-shell/AppShell.d.ts.map +1 -1
- package/dist/components/app-shell/index.d.ts +2 -1
- package/dist/components/app-shell/index.d.ts.map +1 -1
- package/dist/components/bottom-sheet/BottomSheet.d.ts +17 -16
- package/dist/components/bottom-sheet/BottomSheet.d.ts.map +1 -1
- package/dist/components/bottom-sheet/index.d.ts +2 -1
- package/dist/components/bottom-sheet/index.d.ts.map +1 -1
- package/dist/components/breadcrumb/BreadCrumb.d.ts +26 -0
- package/dist/components/breadcrumb/BreadCrumb.d.ts.map +1 -0
- package/dist/components/breadcrumb/index.d.ts +3 -2
- package/dist/components/breadcrumb/index.d.ts.map +1 -1
- package/dist/components/footer/Footer.d.ts +21 -16
- package/dist/components/footer/Footer.d.ts.map +1 -1
- package/dist/components/footer/index.d.ts +2 -1
- package/dist/components/footer/index.d.ts.map +1 -1
- package/dist/components/form-controls/Checkbox.d.ts +10 -8
- package/dist/components/form-controls/Checkbox.d.ts.map +1 -1
- package/dist/components/form-controls/Date.d.ts +6 -4
- package/dist/components/form-controls/Date.d.ts.map +1 -1
- package/dist/components/form-controls/File.d.ts +10 -9
- package/dist/components/form-controls/File.d.ts.map +1 -1
- package/dist/components/form-controls/Input.d.ts +11 -9
- package/dist/components/form-controls/Input.d.ts.map +1 -1
- package/dist/components/form-controls/Radio.d.ts +10 -9
- package/dist/components/form-controls/Radio.d.ts.map +1 -1
- package/dist/components/form-controls/Select.d.ts +12 -6
- package/dist/components/form-controls/Select.d.ts.map +1 -1
- package/dist/components/form-controls/Stepper.d.ts +10 -8
- package/dist/components/form-controls/Stepper.d.ts.map +1 -1
- package/dist/components/form-controls/TextArea.d.ts +10 -8
- package/dist/components/form-controls/TextArea.d.ts.map +1 -1
- package/dist/components/form-controls/Toggle.d.ts +10 -9
- package/dist/components/form-controls/Toggle.d.ts.map +1 -1
- package/dist/components/form-controls/index.d.ts +30 -20
- package/dist/components/form-controls/index.d.ts.map +1 -1
- package/dist/components/header/Header.d.ts +32 -28
- package/dist/components/header/Header.d.ts.map +1 -1
- package/dist/components/header/index.d.ts +2 -1
- package/dist/components/header/index.d.ts.map +1 -1
- package/dist/components/menu-list/MenuList.d.ts +32 -22
- package/dist/components/menu-list/MenuList.d.ts.map +1 -1
- package/dist/components/menu-list/index.d.ts +2 -1
- package/dist/components/menu-list/index.d.ts.map +1 -1
- package/dist/components/page-header/PageHeader.d.ts +22 -3
- package/dist/components/page-header/PageHeader.d.ts.map +1 -1
- package/dist/components/page-header/index.d.ts +2 -1
- package/dist/components/page-header/index.d.ts.map +1 -1
- package/dist/components/toast/Toast.d.ts +20 -12
- package/dist/components/toast/Toast.d.ts.map +1 -1
- package/dist/components/toast/index.d.ts +2 -1
- package/dist/components/toast/index.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.es.css +1 -1
- package/dist/index.es.js +3 -3
- package/dist/index.js +3 -3
- package/package.json +1 -1
- package/docs/Alert.md +0 -131
- package/docs/Avatar.md +0 -130
- package/docs/Badge.md +0 -83
- package/docs/Button.md +0 -175
- package/docs/ConfirmDialog.md +0 -139
- package/docs/Container.md +0 -230
- package/docs/Dropdown.md +0 -175
- package/docs/Icon.md +0 -225
- package/docs/MediaObject.md +0 -303
- package/docs/Modal.md +0 -152
- package/docs/Pagination.md +0 -142
- package/docs/Pills.md +0 -104
- package/docs/Spinner.md +0 -115
- package/docs/Stepper.md +0 -131
- package/docs/Table.md +0 -194
- package/docs/Typography.md +0 -226
- package/llms.txt +0 -171
- package/scripts/generate-icons.js +0 -175
- package/templates/README.md +0 -10
- package/templates/docs-template-sample.md +0 -67
- package/templates/storybook-docs-template.md +0 -236
- package/tsconfig.json +0 -26
package/docs/Container.md
DELETED
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
# Container Component
|
|
2
|
-
|
|
3
|
-
Purpose: A layout wrapper that controls display type, width, spacing (margin, padding, gap), and flex alignment. Use it to structure content, create flex layouts, and apply consistent spacing. Below the mobile breakpoint (600px), width variants collapse to full width for a responsive default.
|
|
4
|
-
|
|
5
|
-
## Props / Inputs
|
|
6
|
-
|
|
7
|
-
| Prop | Type | Required | Default | Description |
|
|
8
|
-
| --- | --- | --- | --- | --- |
|
|
9
|
-
| children | React.ReactNode | no | — | Content to render inside the container. |
|
|
10
|
-
| margin | string \| string[] | no | "m-0" | Spacing **suffix** for outer margin. The component adds the `m-` prefix (e.g. `"0"` → m-0, `"b-2"` → m-b-2). Use a single string or array: `"0"`, `["1", "b-2"]`. |
|
|
11
|
-
| padding | string \| string[] | no | "p-4" | Spacing **suffix** for inner padding. The component adds the `p-` prefix (e.g. `"4"` → p-4, `"x-2"` → p-x-2). Use a single string or array: `"4"`, `["2", "x-4"]`. |
|
|
12
|
-
| display | "block" \| "flex" \| "inline-block" \| "" | no | "" | Layout mode. Use `"flex"` for flexbox; leave empty for no display class. |
|
|
13
|
-
| align | "start" \| "center" \| "end" \| "" | no | "" | Flex align-items. Only applies when `display="flex"`. |
|
|
14
|
-
| justify | "space-between" \| "center" \| "space-around" \| "space-evenly" \| "flex-end" \| "flex-start" \| "" | no | "" | Flex justify-content. Only applies when `display="flex"`. |
|
|
15
|
-
| width | "small" \| "medium" \| "large" \| "extra-large" \| "quarter" \| "half" \| "three-quarters" \| "full" \| "" | no | "" | Width variant. At viewports ≤600px, all variants become full width. |
|
|
16
|
-
| gap | string \| string[] | no | "4" | Spacing **suffix** for gap between flex children. The component adds the `g-` prefix (e.g. `"4"` → g-4). Meaningful when `display="flex"`. Use `"4"` or `["2", "3"]` for multiple. |
|
|
17
|
-
| showBorder | boolean | no | false | When true, shows a border around the container. |
|
|
18
|
-
| className | string | no | "" | Additional class names for the root element. |
|
|
19
|
-
| onClick | function | no | — | Click handler for the root div. |
|
|
20
|
-
| style | React.CSSProperties | no | — | Inline styles for the root element. |
|
|
21
|
-
| ...rest | React.HTMLAttributes<HTMLDivElement> | no | — | Any other div attributes (e.g. `id`, `data-*`, `aria-*`) are forwarded. |
|
|
22
|
-
|
|
23
|
-
## Types
|
|
24
|
-
|
|
25
|
-
### SpacingOption
|
|
26
|
-
```typescript
|
|
27
|
-
type SpacingOption = (typeof SPACING_OPTIONS)[number];
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### ContainerDisplay
|
|
31
|
-
```typescript
|
|
32
|
-
type ContainerDisplay = "inline-block" | "block" | "flex";
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### ContainerWidth
|
|
36
|
-
```typescript
|
|
37
|
-
type ContainerWidth =
|
|
38
|
-
| "small"
|
|
39
|
-
| "medium"
|
|
40
|
-
| "large"
|
|
41
|
-
| "extra-large"
|
|
42
|
-
| "quarter"
|
|
43
|
-
| "half"
|
|
44
|
-
| "three-quarters"
|
|
45
|
-
| "full";
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### ContainerJustify
|
|
49
|
-
```typescript
|
|
50
|
-
type ContainerJustify =
|
|
51
|
-
| "space-between"
|
|
52
|
-
| "center"
|
|
53
|
-
| "space-around"
|
|
54
|
-
| "space-evenly"
|
|
55
|
-
| "flex-end"
|
|
56
|
-
| "flex-start";
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### ContainerAlign
|
|
60
|
-
```typescript
|
|
61
|
-
type ContainerAlign = "start" | "center" | "end";
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### ContainerSpacing
|
|
65
|
-
```typescript
|
|
66
|
-
type ContainerSpacing = string | SpacingOption[];
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### ContainerProps
|
|
70
|
-
```typescript
|
|
71
|
-
interface ContainerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
72
|
-
children?: React.ReactNode;
|
|
73
|
-
margin?: ContainerSpacing;
|
|
74
|
-
padding?: ContainerSpacing;
|
|
75
|
-
display?: ContainerDisplay | "";
|
|
76
|
-
align?: ContainerAlign | "";
|
|
77
|
-
justify?: ContainerJustify | "";
|
|
78
|
-
width?: ContainerWidth | "";
|
|
79
|
-
showBorder?: boolean;
|
|
80
|
-
className?: string;
|
|
81
|
-
onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
82
|
-
style?: React.CSSProperties;
|
|
83
|
-
gap?: ContainerSpacing;
|
|
84
|
-
}
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Usage Examples
|
|
88
|
-
|
|
89
|
-
### Block container
|
|
90
|
-
|
|
91
|
-
```jsx
|
|
92
|
-
import { Container } from "cleanplate";
|
|
93
|
-
|
|
94
|
-
export const Example = () => (
|
|
95
|
-
<Container display="block" padding="4" showBorder>
|
|
96
|
-
<p>Block container: full width, content stacks vertically.</p>
|
|
97
|
-
</Container>
|
|
98
|
-
);
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
### Flex container with alignment
|
|
102
|
-
|
|
103
|
-
```jsx
|
|
104
|
-
import { Container } from "cleanplate";
|
|
105
|
-
import { Button } from "cleanplate";
|
|
106
|
-
|
|
107
|
-
export const Example = () => (
|
|
108
|
-
<Container
|
|
109
|
-
display="flex"
|
|
110
|
-
justify="space-between"
|
|
111
|
-
align="center"
|
|
112
|
-
padding="3"
|
|
113
|
-
gap="2"
|
|
114
|
-
showBorder
|
|
115
|
-
>
|
|
116
|
-
<span>Left</span>
|
|
117
|
-
<Button size="small">Action</Button>
|
|
118
|
-
</Container>
|
|
119
|
-
);
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### Width variants
|
|
123
|
-
|
|
124
|
-
```jsx
|
|
125
|
-
import { Container } from "cleanplate";
|
|
126
|
-
|
|
127
|
-
export const Example = () => (
|
|
128
|
-
<>
|
|
129
|
-
<Container width="small" showBorder padding="3">Small</Container>
|
|
130
|
-
<Container width="medium" showBorder padding="3">Medium</Container>
|
|
131
|
-
<Container width="half" showBorder padding="3">Half</Container>
|
|
132
|
-
<Container width="full" showBorder padding="3">Full</Container>
|
|
133
|
-
</>
|
|
134
|
-
);
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### Inline-block (side by side)
|
|
138
|
-
|
|
139
|
-
```jsx
|
|
140
|
-
import { Container } from "cleanplate";
|
|
141
|
-
|
|
142
|
-
export const Example = () => (
|
|
143
|
-
<Container display="inline-block" showBorder padding="2" margin="r-2">
|
|
144
|
-
Block 1
|
|
145
|
-
</Container>
|
|
146
|
-
<Container display="inline-block" showBorder padding="2">
|
|
147
|
-
Block 2
|
|
148
|
-
</Container>
|
|
149
|
-
);
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
### Margin and padding
|
|
153
|
-
|
|
154
|
-
```jsx
|
|
155
|
-
import { Container } from "cleanplate";
|
|
156
|
-
|
|
157
|
-
export const Example = () => (
|
|
158
|
-
<>
|
|
159
|
-
<Container margin="2" padding="4" showBorder>
|
|
160
|
-
Single suffix values
|
|
161
|
-
</Container>
|
|
162
|
-
<Container margin={["1", "b-3"]} padding={["2", "x-4"]} showBorder>
|
|
163
|
-
Multiple suffixes (component adds m- / p- prefix)
|
|
164
|
-
</Container>
|
|
165
|
-
</>
|
|
166
|
-
);
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
### Flex grid (quarters)
|
|
170
|
-
|
|
171
|
-
```jsx
|
|
172
|
-
import { Container } from "cleanplate";
|
|
173
|
-
|
|
174
|
-
export const Example = () => (
|
|
175
|
-
<Container display="flex" padding="2" gap="2" showBorder>
|
|
176
|
-
<Container width="quarter" showBorder padding="3">1</Container>
|
|
177
|
-
<Container width="quarter" showBorder padding="3">2</Container>
|
|
178
|
-
<Container width="quarter" showBorder padding="3">3</Container>
|
|
179
|
-
<Container width="quarter" showBorder padding="3">4</Container>
|
|
180
|
-
</Container>
|
|
181
|
-
);
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
### Clickable container
|
|
185
|
-
|
|
186
|
-
```jsx
|
|
187
|
-
import { Container } from "cleanplate";
|
|
188
|
-
|
|
189
|
-
export const Example = () => (
|
|
190
|
-
<Container
|
|
191
|
-
showBorder
|
|
192
|
-
padding="4"
|
|
193
|
-
onClick={() => console.log("Clicked")}
|
|
194
|
-
>
|
|
195
|
-
Clickable area
|
|
196
|
-
</Container>
|
|
197
|
-
);
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
### With custom class and style
|
|
201
|
-
|
|
202
|
-
```jsx
|
|
203
|
-
import { Container } from "cleanplate";
|
|
204
|
-
|
|
205
|
-
export const Example = () => (
|
|
206
|
-
<Container
|
|
207
|
-
className="my-wrapper"
|
|
208
|
-
style={{ minHeight: 200 }}
|
|
209
|
-
padding="4"
|
|
210
|
-
showBorder
|
|
211
|
-
>
|
|
212
|
-
Custom wrapper
|
|
213
|
-
</Container>
|
|
214
|
-
);
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
## Behavior Notes
|
|
218
|
-
|
|
219
|
-
- **Responsive width:** For viewport width ≤600px (mobile breakpoint), all `width` variants are overridden to `100%` in CSS. No prop change is required.
|
|
220
|
-
- **Flex:** When `display="flex"`, the root uses `display: flex` and `flex-wrap: wrap`. Use `align` and `justify` to control alignment; use `gap` for spacing between children.
|
|
221
|
-
- **Spacing:** `margin`, `padding`, and `gap` accept the **spacing suffix** (the component adds the `m-`, `p-`, or `g-` prefix via `getSpacingClass`). Use a single string (e.g. `"4"`, `"0"`, `"b-2"`) or an array of suffixes (e.g. `["1", "b-2"]`). Valid suffixes include `"0"`–`"9"`, `"auto"`, and directional forms like `"x-2"`, `"y-3"`, `"t-0"`, `"r-1"`, `"b-2"`, `"l-3"` (see `SPACING_OPTIONS`). **Note:** The component’s default props are currently `"m-0"` and `"p-4"` (full tokens); internally the util expects suffixes, so when passing values explicitly use suffix form (e.g. `"0"`, `"4"`).
|
|
222
|
-
- **Empty layout props:** Passing `""` or omitting `display`, `align`, `justify`, or `width` means no corresponding class is applied.
|
|
223
|
-
- **Border:** `showBorder` only affects border visibility; the container always reserves border space (border is 1px solid, transparent when not shown).
|
|
224
|
-
- The root element is a `div`; all standard HTML div attributes and ref are supported via `...rest`.
|
|
225
|
-
|
|
226
|
-
## Related Components / Links
|
|
227
|
-
|
|
228
|
-
- Typography (often used inside Container for text)
|
|
229
|
-
- Button (commonly placed inside flex Containers)
|
|
230
|
-
- MediaObject (often wrapped in Container for layout)
|
package/docs/Dropdown.md
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
# Dropdown Component
|
|
2
|
-
|
|
3
|
-
Purpose: A floating panel that shows content relative to a trigger. Use it for menus, option lists, or any content that opens on click. Supports 12 placements, optional flip/shift to stay in viewport, and three trigger modes: a `trigger` element, a `renderTrigger` function, or a `triggerLabel` for a default button.
|
|
4
|
-
|
|
5
|
-
## Props / Inputs
|
|
6
|
-
|
|
7
|
-
| Prop | Type | Required | Default | Description |
|
|
8
|
-
| --- | --- | --- | --- | --- |
|
|
9
|
-
| trigger | React.ReactElement | no | — | Trigger element to clone; ref and onClick are attached. Omit when using `renderTrigger` or `triggerLabel`. |
|
|
10
|
-
| content | React.ReactElement | yes | — | Content shown in the floating panel. Receives `onClose` and `className` when cloned. |
|
|
11
|
-
| placement | DropdownPlacement | no | "bottom-end" | Preferred position relative to trigger (e.g. "bottom-end", "top-start"). |
|
|
12
|
-
| offset | number | no | 4 | Gap in pixels between trigger and panel. |
|
|
13
|
-
| shift | boolean | no | true | When true, shift panel to stay inside viewport. |
|
|
14
|
-
| flip | boolean | no | true | When true, flip to opposite side when there is no space. |
|
|
15
|
-
| closeOnClickOutside | boolean | no | true | Close when user clicks outside trigger and panel. |
|
|
16
|
-
| closeOnEscape | boolean | no | true | Close when user presses Escape. |
|
|
17
|
-
| className | string | no | "" | Class name for the wrapper div. |
|
|
18
|
-
| contentClassName | string | no | "" | Class name applied to the cloned content element. |
|
|
19
|
-
| renderTrigger | (params: DropdownRenderTriggerParams) => React.ReactNode | no | — | Render prop for a custom trigger; receives `isOpen`, `isAnimating`, `placement`, `toggle`, `close`, `triggerProps`. |
|
|
20
|
-
| triggerLabel | string | no | — | Label for the default button trigger. Use when neither `trigger` nor `renderTrigger` is provided. |
|
|
21
|
-
|
|
22
|
-
## Types
|
|
23
|
-
|
|
24
|
-
### DropdownPlacement
|
|
25
|
-
```typescript
|
|
26
|
-
type DropdownPlacement =
|
|
27
|
-
| "top" | "top-start" | "top-end"
|
|
28
|
-
| "bottom" | "bottom-start" | "bottom-end"
|
|
29
|
-
| "left" | "left-start" | "left-end"
|
|
30
|
-
| "right" | "right-start" | "right-end";
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### DropdownTriggerProps
|
|
34
|
-
```typescript
|
|
35
|
-
interface DropdownTriggerProps {
|
|
36
|
-
ref: RefObject<HTMLElement | null>;
|
|
37
|
-
onClick: (e: React.MouseEvent<HTMLElement>) => void;
|
|
38
|
-
className: string;
|
|
39
|
-
role: string;
|
|
40
|
-
"aria-expanded": boolean;
|
|
41
|
-
"aria-haspopup": string;
|
|
42
|
-
}
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### DropdownRenderTriggerParams
|
|
46
|
-
```typescript
|
|
47
|
-
interface DropdownRenderTriggerParams {
|
|
48
|
-
isOpen: boolean;
|
|
49
|
-
isAnimating: boolean;
|
|
50
|
-
placement: DropdownPlacement;
|
|
51
|
-
toggle: () => void;
|
|
52
|
-
close: () => void;
|
|
53
|
-
triggerProps: DropdownTriggerProps;
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
### DropdownProps
|
|
58
|
-
```typescript
|
|
59
|
-
interface DropdownProps {
|
|
60
|
-
trigger?: React.ReactElement;
|
|
61
|
-
content: React.ReactElement;
|
|
62
|
-
placement?: DropdownPlacement;
|
|
63
|
-
offset?: number;
|
|
64
|
-
shift?: boolean;
|
|
65
|
-
flip?: boolean;
|
|
66
|
-
closeOnClickOutside?: boolean;
|
|
67
|
-
closeOnEscape?: boolean;
|
|
68
|
-
className?: string;
|
|
69
|
-
contentClassName?: string;
|
|
70
|
-
renderTrigger?: (params: DropdownRenderTriggerParams) => React.ReactNode;
|
|
71
|
-
triggerLabel?: string;
|
|
72
|
-
}
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## Usage Examples
|
|
76
|
-
|
|
77
|
-
### With trigger element
|
|
78
|
-
|
|
79
|
-
```jsx
|
|
80
|
-
import { Dropdown, Button } from "cleanplate";
|
|
81
|
-
|
|
82
|
-
const MenuContent = ({ onClose }) => (
|
|
83
|
-
<div style={{ padding: "var(--space-2)" }}>
|
|
84
|
-
<button onClick={onClose}>Close</button>
|
|
85
|
-
<p>Menu items here</p>
|
|
86
|
-
</div>
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
export const Example = () => (
|
|
90
|
-
<Dropdown
|
|
91
|
-
trigger={<Button>Open Menu</Button>}
|
|
92
|
-
content={<MenuContent />}
|
|
93
|
-
placement="bottom-end"
|
|
94
|
-
/>
|
|
95
|
-
);
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
### With triggerLabel
|
|
99
|
-
|
|
100
|
-
```jsx
|
|
101
|
-
import { Dropdown } from "cleanplate";
|
|
102
|
-
|
|
103
|
-
export const Example = () => (
|
|
104
|
-
<Dropdown
|
|
105
|
-
triggerLabel="Select Option"
|
|
106
|
-
content={<MenuContent />}
|
|
107
|
-
placement="bottom-end"
|
|
108
|
-
/>
|
|
109
|
-
);
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### With renderTrigger
|
|
113
|
-
|
|
114
|
-
```jsx
|
|
115
|
-
import { Dropdown, Button } from "cleanplate";
|
|
116
|
-
|
|
117
|
-
export const Example = () => (
|
|
118
|
-
<Dropdown
|
|
119
|
-
renderTrigger={({ isOpen, triggerProps }) => (
|
|
120
|
-
<Button {...triggerProps}>
|
|
121
|
-
{isOpen ? "Close" : "Open"}
|
|
122
|
-
</Button>
|
|
123
|
-
)}
|
|
124
|
-
content={<MenuContent />}
|
|
125
|
-
/>
|
|
126
|
-
);
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### Placement and offset
|
|
130
|
-
|
|
131
|
-
```jsx
|
|
132
|
-
<Dropdown
|
|
133
|
-
trigger={<Button>Menu</Button>}
|
|
134
|
-
content={<MenuContent />}
|
|
135
|
-
placement="top-start"
|
|
136
|
-
offset={8}
|
|
137
|
-
/>
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
### Disable flip / shift
|
|
141
|
-
|
|
142
|
-
```jsx
|
|
143
|
-
<Dropdown
|
|
144
|
-
trigger={<Button>Menu</Button>}
|
|
145
|
-
content={<MenuContent />}
|
|
146
|
-
placement="top"
|
|
147
|
-
flip={false}
|
|
148
|
-
shift={false}
|
|
149
|
-
/>
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
### Close behavior
|
|
153
|
-
|
|
154
|
-
```jsx
|
|
155
|
-
<Dropdown
|
|
156
|
-
trigger={<Button>Menu</Button>}
|
|
157
|
-
content={<MenuContent />}
|
|
158
|
-
closeOnClickOutside={false}
|
|
159
|
-
closeOnEscape={true}
|
|
160
|
-
/>
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
## Behavior Notes
|
|
164
|
-
|
|
165
|
-
- **Trigger modes:** Exactly one of `trigger`, `renderTrigger`, or `triggerLabel` must be used; the component throws if none are provided.
|
|
166
|
-
- **Content:** The `content` element is cloned; the component injects `onClose` and merges `className` so the panel can close and be styled.
|
|
167
|
-
- **Positioning:** Placement is applied via CSS classes; when `flip` or `shift` are true, the component adjusts placement/position so the panel stays in view.
|
|
168
|
-
- **Accessibility:** The trigger receives `aria-expanded` and `aria-haspopup`; the panel has `role="menu"`. Escape and (optionally) click-outside close the dropdown.
|
|
169
|
-
- **Animation:** Opening/closing uses CSS classes (`dropdown-opening` / `dropdown-closing`); a short delay (e.g. 150ms) is used before unmounting so the close animation can run.
|
|
170
|
-
|
|
171
|
-
## Related Components / Links
|
|
172
|
-
|
|
173
|
-
- Button (commonly used as trigger or inside renderTrigger)
|
|
174
|
-
- MenuList (often used inside dropdown content for menu items)
|
|
175
|
-
- Icon (used in the default trigger when `triggerLabel` is set for arrow icons)
|
package/docs/Icon.md
DELETED
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
# Icon Component
|
|
2
|
-
|
|
3
|
-
Purpose: A versatile and reusable element for displaying scalable vector icons, supporting various sizes, colors, and custom classes. It seamlessly integrates into user interfaces to enhance visual appeal and provide intuitive, meaningful representations using Google Material Symbols.
|
|
4
|
-
|
|
5
|
-
## Props / Inputs
|
|
6
|
-
|
|
7
|
-
| Prop | Type | Required | Default | Description |
|
|
8
|
-
| --- | --- | --- | --- | --- |
|
|
9
|
-
| name | MaterialIconName | no | "" | The name of the Material Symbol icon to display. Use a value from `MATERIAL_ICON_NAMES` or `ICON_CATEGORIES` (see **Icon names and categories** below). |
|
|
10
|
-
| size | "small" \| "medium" \| "large" | no | "medium" | Size variant of the icon. |
|
|
11
|
-
| color | "black" \| "white" \| "gray" \| "blue" \| "green" \| "red" \| "yellow" \| "orange" | no | "black" | Color variant of the icon. |
|
|
12
|
-
| className | string | no | "" | Additional class names for the root element. |
|
|
13
|
-
| ...rest | React.HTMLAttributes<HTMLSpanElement> | no | — | All other standard HTML span attributes are supported and passed through to the rendered element. |
|
|
14
|
-
|
|
15
|
-
## Types
|
|
16
|
-
|
|
17
|
-
### IconSize
|
|
18
|
-
```typescript
|
|
19
|
-
type IconSize = "small" | "medium" | "large";
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
### IconColor
|
|
23
|
-
```typescript
|
|
24
|
-
type IconColor = "black" | "white" | "gray" | "blue" | "green" | "red" | "yellow" | "orange";
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### IconProps
|
|
28
|
-
```typescript
|
|
29
|
-
interface IconProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
30
|
-
name?: MaterialIconName;
|
|
31
|
-
size?: IconSize;
|
|
32
|
-
className?: string;
|
|
33
|
-
color?: IconColor;
|
|
34
|
-
}
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### MaterialIconName
|
|
38
|
-
Icon names are typed as `MaterialIconName` (a union of all valid Material Symbols Outlined names). The package also exports `MATERIAL_ICON_NAMES` (array of all names) and `ICON_CATEGORIES` (icons grouped by purpose) from the Icon component’s generated `material-icon-names` module.
|
|
39
|
-
|
|
40
|
-
## Icon names and categories
|
|
41
|
-
|
|
42
|
-
Icon names are sourced from the generated `material-icon-names` module. Icons are grouped into **categories** to make it easier to pick a name for the `name` prop. Use these when suggesting or choosing icons.
|
|
43
|
-
|
|
44
|
-
| Category | Description | Example icon names |
|
|
45
|
-
| --- | --- | --- |
|
|
46
|
-
| **navigation** | Back, forward, menu, home, close | `arrow_back`, `arrow_forward`, `home`, `menu`, `close` |
|
|
47
|
-
| **action** | Add, edit, delete, search, settings, refresh | `add`, `edit`, `delete`, `search`, `settings`, `refresh` |
|
|
48
|
-
| **communication** | Chat, email, message | `chat`, `chat_bubble`, `email`, `message` |
|
|
49
|
-
| **content** | Copy, cut, paste | `content_copy`, `content_cut`, `content_paste` |
|
|
50
|
-
| **device** | Phone, devices, thermostat | `phone`, `devices`, `device_thermostat`, `phonelink` |
|
|
51
|
-
| **editor** | Format, align, list, bold, italic | `format_bold`, `format_align_center`, `format_list_bulleted` |
|
|
52
|
-
| **file** | Folder, insert, drive | `folder`, `folder_open`, `insert_drive_file`, `insert_photo` |
|
|
53
|
-
| **hardware** | Keyboard, computer | `keyboard`, `computer`, `keyboard_arrow_down` |
|
|
54
|
-
| **image** | Photo, camera, image | `image`, `photo`, `photo_camera`, `photo_library` |
|
|
55
|
-
| **maps** | Map, place | `map`, `place`, `maps_ugc` |
|
|
56
|
-
| **notification** | Notifications, alerts | `notifications`, `notifications_active`, `notification_add` |
|
|
57
|
-
| **social** | Person, group, share | `person`, `person_add`, `group`, `share` |
|
|
58
|
-
| **toggle** | Check, checkbox, toggle | `check`, `check_circle`, `check_box`, `toggle_on` |
|
|
59
|
-
| **av** | Play, pause, volume | `play_arrow`, `pause`, `volume_up`, `volume_off` |
|
|
60
|
-
| **alert** | Error, warning | `error`, `error_outline`, `warning`, `warning_amber` |
|
|
61
|
-
| **other** | All remaining Material Symbols not in the above categories | Many additional names (e.g. `star`, `favorite`, `bookmark`, `progress_activity`) |
|
|
62
|
-
|
|
63
|
-
- Icon names are generated from the **Material Symbols Outlined** variable font (thousands of names). The `material-icon-names` module is generated by the project’s `generate-icons` script.
|
|
64
|
-
- For **full autocomplete** in TypeScript, use the `MaterialIconName` type or import `MATERIAL_ICON_NAMES` / `ICON_CATEGORIES` from `cleanplate` (or from the package’s icon module).
|
|
65
|
-
- Names use **underscores** (e.g. `cloud_upload`), not spaces.
|
|
66
|
-
- See [Google Fonts – Material Symbols & Icons](https://fonts.google.com/icons) for the full visual reference.
|
|
67
|
-
|
|
68
|
-
## Installation
|
|
69
|
-
|
|
70
|
-
Before using the Icon component, you need to include the Material Symbols font in your project. Add the following link tag to the `<head>` of your `index.html`:
|
|
71
|
-
|
|
72
|
-
```html
|
|
73
|
-
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" />
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## Usage Examples
|
|
77
|
-
|
|
78
|
-
### Basic icon
|
|
79
|
-
|
|
80
|
-
```jsx
|
|
81
|
-
import { Icon } from "cleanplate";
|
|
82
|
-
|
|
83
|
-
export const Example = () => (
|
|
84
|
-
<Icon name="settings" />
|
|
85
|
-
);
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### Different sizes
|
|
89
|
-
|
|
90
|
-
```jsx
|
|
91
|
-
import { Icon } from "cleanplate";
|
|
92
|
-
|
|
93
|
-
export const Example = () => (
|
|
94
|
-
<>
|
|
95
|
-
<Icon name="home" size="small" />
|
|
96
|
-
<Icon name="home" size="medium" />
|
|
97
|
-
<Icon name="home" size="large" />
|
|
98
|
-
</>
|
|
99
|
-
);
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### Different colors
|
|
103
|
-
|
|
104
|
-
```jsx
|
|
105
|
-
import { Icon } from "cleanplate";
|
|
106
|
-
|
|
107
|
-
export const Example = () => (
|
|
108
|
-
<>
|
|
109
|
-
<Icon name="favorite" color="black" />
|
|
110
|
-
<Icon name="favorite" color="red" />
|
|
111
|
-
<Icon name="favorite" color="blue" />
|
|
112
|
-
<Icon name="favorite" color="green" />
|
|
113
|
-
</>
|
|
114
|
-
);
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### Common icons
|
|
118
|
-
|
|
119
|
-
```jsx
|
|
120
|
-
import { Icon } from "cleanplate";
|
|
121
|
-
|
|
122
|
-
export const Example = () => (
|
|
123
|
-
<>
|
|
124
|
-
<Icon name="home" />
|
|
125
|
-
<Icon name="settings" />
|
|
126
|
-
<Icon name="search" />
|
|
127
|
-
<Icon name="menu" />
|
|
128
|
-
<Icon name="close" />
|
|
129
|
-
<Icon name="add" />
|
|
130
|
-
<Icon name="delete" />
|
|
131
|
-
<Icon name="edit" />
|
|
132
|
-
<Icon name="download" />
|
|
133
|
-
<Icon name="cloud_upload" />
|
|
134
|
-
</>
|
|
135
|
-
);
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### With custom className
|
|
139
|
-
|
|
140
|
-
```jsx
|
|
141
|
-
import { Icon } from "cleanplate";
|
|
142
|
-
|
|
143
|
-
export const Example = () => (
|
|
144
|
-
<Icon
|
|
145
|
-
name="star"
|
|
146
|
-
className="custom-icon-class"
|
|
147
|
-
size="large"
|
|
148
|
-
color="yellow"
|
|
149
|
-
/>
|
|
150
|
-
);
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
### With HTML attributes
|
|
154
|
-
|
|
155
|
-
```jsx
|
|
156
|
-
import { Icon } from "cleanplate";
|
|
157
|
-
|
|
158
|
-
export const Example = () => (
|
|
159
|
-
<>
|
|
160
|
-
<Icon
|
|
161
|
-
name="info"
|
|
162
|
-
aria-label="Information icon"
|
|
163
|
-
data-testid="info-icon"
|
|
164
|
-
onClick={() => console.log("Icon clicked")}
|
|
165
|
-
/>
|
|
166
|
-
<Icon
|
|
167
|
-
name="error"
|
|
168
|
-
id="error-icon"
|
|
169
|
-
title="Error occurred"
|
|
170
|
-
/>
|
|
171
|
-
</>
|
|
172
|
-
);
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
### In buttons
|
|
176
|
-
|
|
177
|
-
```jsx
|
|
178
|
-
import { Icon } from "cleanplate";
|
|
179
|
-
import { Button } from "cleanplate";
|
|
180
|
-
|
|
181
|
-
export const Example = () => (
|
|
182
|
-
<>
|
|
183
|
-
<Button>
|
|
184
|
-
<Icon name="save" size="small" />
|
|
185
|
-
Save
|
|
186
|
-
</Button>
|
|
187
|
-
<Button>
|
|
188
|
-
<Icon name="download" />
|
|
189
|
-
Download
|
|
190
|
-
</Button>
|
|
191
|
-
</>
|
|
192
|
-
);
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
### With Typography
|
|
196
|
-
|
|
197
|
-
```jsx
|
|
198
|
-
import { Icon } from "cleanplate";
|
|
199
|
-
import { Typography } from "cleanplate";
|
|
200
|
-
|
|
201
|
-
export const Example = () => (
|
|
202
|
-
<Typography variant="p">
|
|
203
|
-
<Icon name="check_circle" color="green" size="small" />
|
|
204
|
-
{" "}Task completed
|
|
205
|
-
</Typography>
|
|
206
|
-
);
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
## Behavior Notes
|
|
210
|
-
|
|
211
|
-
- The component uses the **Material Symbols Outlined** font, which must be included in your project for icons to display correctly.
|
|
212
|
-
- Icon names must match the names from the [Material Symbols set](https://fonts.google.com/icons) (e.g. `progress_activity`, `cloud_upload`). Use underscores instead of spaces. Use the **Icon names and categories** table above to find names by purpose.
|
|
213
|
-
- The component renders as a `<span>` element, making it an inline element by default.
|
|
214
|
-
- If no `name` is provided, the icon will render as an empty span.
|
|
215
|
-
- The `color` prop applies predefined color classes. For custom colors, use the `className` prop with your own CSS.
|
|
216
|
-
- All standard HTML span attributes (like `onClick`, `aria-label`, `data-*`, etc.) are supported and passed through.
|
|
217
|
-
- Icons are scalable and will inherit the font size from their container if custom sizing is needed.
|
|
218
|
-
- The component is designed to work seamlessly with other CleanPlate components like Button, Typography, and Alert.
|
|
219
|
-
|
|
220
|
-
## Related Components / Links
|
|
221
|
-
|
|
222
|
-
- Button (commonly uses icons for visual enhancement)
|
|
223
|
-
- Typography (often combined with icons for inline content)
|
|
224
|
-
- Alert (uses icons to indicate different alert types)
|
|
225
|
-
- [Material Symbols & Icons](https://fonts.google.com/icons) – Browse available icon names (Material Symbols Outlined)
|