cleanplate 0.1.7 → 0.1.8
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 +15 -0
- package/dist/components/accordion/Accordion.d.ts.map +1 -0
- package/dist/components/accordion/index.d.ts +3 -0
- package/dist/components/accordion/index.d.ts.map +1 -0
- package/dist/components/alert/Alert.d.ts +20 -0
- package/dist/components/alert/Alert.d.ts.map +1 -0
- package/dist/components/alert/index.d.ts +3 -0
- package/dist/components/alert/index.d.ts.map +1 -0
- package/dist/components/animated/Animated.d.ts +21 -0
- package/dist/components/animated/Animated.d.ts.map +1 -0
- package/dist/components/animated/index.d.ts +3 -0
- package/dist/components/animated/index.d.ts.map +1 -0
- package/dist/components/app-shell/AppShell.d.ts +5 -0
- package/dist/components/app-shell/AppShell.d.ts.map +1 -0
- package/dist/components/app-shell/index.d.ts +3 -0
- package/dist/components/app-shell/index.d.ts.map +1 -0
- package/dist/components/avatar/Avatar.d.ts +22 -0
- package/dist/components/avatar/Avatar.d.ts.map +1 -0
- package/dist/components/avatar/index.d.ts +3 -0
- package/dist/components/avatar/index.d.ts.map +1 -0
- package/dist/components/badge/Badge.d.ts +13 -0
- package/dist/components/badge/Badge.d.ts.map +1 -0
- package/dist/components/badge/index.d.ts +3 -0
- package/dist/components/badge/index.d.ts.map +1 -0
- package/dist/components/bottom-sheet/BottomSheet.d.ts +18 -0
- package/dist/components/bottom-sheet/BottomSheet.d.ts.map +1 -0
- package/dist/components/bottom-sheet/index.d.ts +3 -0
- package/dist/components/bottom-sheet/index.d.ts.map +1 -0
- package/dist/components/breadcrumb/AppShell.d.ts +5 -0
- package/dist/components/breadcrumb/AppShell.d.ts.map +1 -0
- package/dist/components/breadcrumb/index.d.ts +3 -0
- package/dist/components/breadcrumb/index.d.ts.map +1 -0
- package/dist/components/button/Button.d.ts +21 -0
- package/dist/components/button/Button.d.ts.map +1 -0
- package/dist/components/button/index.d.ts +4 -0
- package/dist/components/button/index.d.ts.map +1 -0
- package/dist/components/confirm-dialog/ConfirmDialog.d.ts +38 -0
- package/dist/components/confirm-dialog/ConfirmDialog.d.ts.map +1 -0
- package/dist/components/confirm-dialog/index.d.ts +3 -0
- package/dist/components/confirm-dialog/index.d.ts.map +1 -0
- package/dist/components/container/Container.d.ts +30 -0
- package/dist/components/container/Container.d.ts.map +1 -0
- package/dist/components/container/index.d.ts +3 -0
- package/dist/components/container/index.d.ts.map +1 -0
- package/dist/components/dropdown/Dropdown.d.ts +32 -0
- package/dist/components/dropdown/Dropdown.d.ts.map +1 -0
- package/dist/components/dropdown/index.d.ts +3 -0
- package/dist/components/dropdown/index.d.ts.map +1 -0
- package/dist/components/footer/Footer.d.ts +22 -0
- package/dist/components/footer/Footer.d.ts.map +1 -0
- package/dist/components/footer/index.d.ts +3 -0
- package/dist/components/footer/index.d.ts.map +1 -0
- package/dist/components/form-controls/Checkbox.d.ts +14 -0
- package/dist/components/form-controls/Checkbox.d.ts.map +1 -0
- package/dist/components/form-controls/Date.d.ts +11 -0
- package/dist/components/form-controls/Date.d.ts.map +1 -0
- package/dist/components/form-controls/File.d.ts +15 -0
- package/dist/components/form-controls/File.d.ts.map +1 -0
- package/dist/components/form-controls/Input.d.ts +18 -0
- package/dist/components/form-controls/Input.d.ts.map +1 -0
- package/dist/components/form-controls/Radio.d.ts +15 -0
- package/dist/components/form-controls/Radio.d.ts.map +1 -0
- package/dist/components/form-controls/Select.d.ts +18 -0
- package/dist/components/form-controls/Select.d.ts.map +1 -0
- package/dist/components/form-controls/Stepper.d.ts +17 -0
- package/dist/components/form-controls/Stepper.d.ts.map +1 -0
- package/dist/components/form-controls/TextArea.d.ts +16 -0
- package/dist/components/form-controls/TextArea.d.ts.map +1 -0
- package/dist/components/form-controls/Toggle.d.ts +15 -0
- package/dist/components/form-controls/Toggle.d.ts.map +1 -0
- package/dist/components/form-controls/index.d.ts +22 -0
- package/dist/components/form-controls/index.d.ts.map +1 -0
- package/dist/components/header/Header.d.ts +30 -0
- package/dist/components/header/Header.d.ts.map +1 -0
- package/dist/components/header/index.d.ts +3 -0
- package/dist/components/header/index.d.ts.map +1 -0
- package/dist/components/icon/Icon.d.ts +12 -0
- package/dist/components/icon/Icon.d.ts.map +1 -0
- package/dist/components/icon/index.d.ts +4 -0
- package/dist/components/icon/index.d.ts.map +1 -0
- package/dist/components/media-object/MediaObject.d.ts +18 -0
- package/dist/components/media-object/MediaObject.d.ts.map +1 -0
- package/dist/components/media-object/index.d.ts +4 -0
- package/dist/components/media-object/index.d.ts.map +1 -0
- package/dist/components/menu-list/MenuList.d.ts +24 -0
- package/dist/components/menu-list/MenuList.d.ts.map +1 -0
- package/dist/components/menu-list/index.d.ts +3 -0
- package/dist/components/menu-list/index.d.ts.map +1 -0
- package/dist/components/modal/Modal.d.ts +40 -0
- package/dist/components/modal/Modal.d.ts.map +1 -0
- package/dist/components/modal/index.d.ts +3 -0
- package/dist/components/modal/index.d.ts.map +1 -0
- package/dist/components/page-header/PageHeader.d.ts +5 -0
- package/dist/components/page-header/PageHeader.d.ts.map +1 -0
- package/dist/components/page-header/index.d.ts +3 -0
- package/dist/components/page-header/index.d.ts.map +1 -0
- package/dist/components/pagination/Pagination.d.ts +30 -0
- package/dist/components/pagination/Pagination.d.ts.map +1 -0
- package/dist/components/pagination/index.d.ts +3 -0
- package/dist/components/pagination/index.d.ts.map +1 -0
- package/dist/components/pills/Pills.d.ts +24 -0
- package/dist/components/pills/Pills.d.ts.map +1 -0
- package/dist/components/pills/index.d.ts +3 -0
- package/dist/components/pills/index.d.ts.map +1 -0
- package/dist/components/progress-bar/ProgressBar.d.ts +20 -0
- package/dist/components/progress-bar/ProgressBar.d.ts.map +1 -0
- package/dist/components/progress-bar/index.d.ts +3 -0
- package/dist/components/progress-bar/index.d.ts.map +1 -0
- package/dist/components/spinner/Spinner.d.ts +15 -0
- package/dist/components/spinner/Spinner.d.ts.map +1 -0
- package/dist/components/spinner/index.d.ts +3 -0
- package/dist/components/spinner/index.d.ts.map +1 -0
- package/dist/components/stepper/Stepper.d.ts +16 -0
- package/dist/components/stepper/Stepper.d.ts.map +1 -0
- package/dist/components/stepper/index.d.ts +3 -0
- package/dist/components/stepper/index.d.ts.map +1 -0
- package/dist/components/table/Table.d.ts +37 -0
- package/dist/components/table/Table.d.ts.map +1 -0
- package/dist/components/table/index.d.ts +3 -0
- package/dist/components/table/index.d.ts.map +1 -0
- package/dist/components/toast/Toast.d.ts +15 -0
- package/dist/components/toast/Toast.d.ts.map +1 -0
- package/dist/components/toast/index.d.ts +3 -0
- package/dist/components/toast/index.d.ts.map +1 -0
- package/dist/components/typography/Typography.d.ts +20 -0
- package/dist/components/typography/Typography.d.ts.map +1 -0
- package/dist/components/typography/index.d.ts +4 -0
- package/dist/components/typography/index.d.ts.map +1 -0
- package/dist/constants/common.d.ts +17 -0
- package/dist/constants/common.d.ts.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.es.js +3 -3
- package/dist/index.js +3 -3
- package/dist/utils/common.d.ts +9 -0
- package/dist/utils/common.d.ts.map +1 -0
- package/dist/utils/get-class-names.d.ts +2 -0
- package/dist/utils/get-class-names.d.ts.map +1 -0
- package/docs/Button.md +175 -0
- package/docs/Icon.md +194 -0
- package/docs/MediaObject.md +303 -0
- package/docs/Typography.md +226 -0
- package/docs-template-sample.md +67 -0
- package/llms.txt +76 -0
- package/package.json +12 -3
- package/tsconfig.json +26 -0
package/docs/Button.md
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# Button Component
|
|
2
|
+
|
|
3
|
+
Purpose: A highly customizable and interactive UI element designed to handle user actions with various styles, sizes, and variants. Supports loading states, disabled states, and click events.
|
|
4
|
+
|
|
5
|
+
## Props / Inputs
|
|
6
|
+
|
|
7
|
+
| Prop | Type | Required | Default | Description |
|
|
8
|
+
| --- | --- | --- | --- | --- |
|
|
9
|
+
| children | React.ReactNode | no | — | Content to display inside the button. |
|
|
10
|
+
| isLoading | boolean | no | false | Shows a loading spinner and disables the button. |
|
|
11
|
+
| isDisabled | boolean | no | false | Disables the button and prevents click events. |
|
|
12
|
+
| isFluid | boolean | no | false | Makes the button take full width of its container. |
|
|
13
|
+
| size | "small" \| "medium" | no | "medium" | Size variant of the button. |
|
|
14
|
+
| variant | "solid" \| "outline" \| "ghost" \| "icon" | no | "solid" | Visual style variant of the button. |
|
|
15
|
+
| margin | string \| string[] | no | "m-0" | Spacing utility token(s), such as `m-0` or `["m-1", "m-b-2"]`. |
|
|
16
|
+
| onClick | function | no | — | Called with the click event when button is clicked. Prevents execution if `isDisabled` or `isLoading` is true. |
|
|
17
|
+
| className | string | no | "" | Additional class names for the root element. |
|
|
18
|
+
| type | "button" \| "submit" \| "reset" | no | "button" | HTML button type attribute. |
|
|
19
|
+
| ...rest | React.ButtonHTMLAttributes | no | — | All other standard HTML button attributes are supported. |
|
|
20
|
+
|
|
21
|
+
## Types
|
|
22
|
+
|
|
23
|
+
### ButtonSize
|
|
24
|
+
```typescript
|
|
25
|
+
type ButtonSize = "small" | "medium";
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### ButtonVariant
|
|
29
|
+
```typescript
|
|
30
|
+
type ButtonVariant = "solid" | "outline" | "ghost" | "icon";
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### ButtonMargin
|
|
34
|
+
```typescript
|
|
35
|
+
type ButtonMargin = string | SpacingOption[];
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### SpacingOption
|
|
39
|
+
```typescript
|
|
40
|
+
type SpacingOption = typeof SPACING_OPTIONS[number];
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### ButtonProps
|
|
44
|
+
```typescript
|
|
45
|
+
interface ButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "type" | "onClick"> {
|
|
46
|
+
children?: React.ReactNode;
|
|
47
|
+
isLoading?: boolean;
|
|
48
|
+
isDisabled?: boolean;
|
|
49
|
+
isFluid?: boolean;
|
|
50
|
+
size?: ButtonSize;
|
|
51
|
+
variant?: ButtonVariant;
|
|
52
|
+
margin?: ButtonMargin;
|
|
53
|
+
onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
54
|
+
className?: string;
|
|
55
|
+
type?: "button" | "submit" | "reset";
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Usage Examples
|
|
60
|
+
|
|
61
|
+
### Basic button
|
|
62
|
+
|
|
63
|
+
```jsx
|
|
64
|
+
import { Button } from "cleanplate";
|
|
65
|
+
|
|
66
|
+
export const Example = () => (
|
|
67
|
+
<Button onClick={() => console.log("Clicked")}>
|
|
68
|
+
Click me
|
|
69
|
+
</Button>
|
|
70
|
+
);
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Variants
|
|
74
|
+
|
|
75
|
+
```jsx
|
|
76
|
+
import { Button } from "cleanplate";
|
|
77
|
+
|
|
78
|
+
export const Example = () => (
|
|
79
|
+
<>
|
|
80
|
+
<Button variant="solid">Solid</Button>
|
|
81
|
+
<Button variant="outline">Outline</Button>
|
|
82
|
+
<Button variant="ghost">Ghost</Button>
|
|
83
|
+
<Button variant="icon">Icon</Button>
|
|
84
|
+
</>
|
|
85
|
+
);
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Sizes
|
|
89
|
+
|
|
90
|
+
```jsx
|
|
91
|
+
import { Button } from "cleanplate";
|
|
92
|
+
|
|
93
|
+
export const Example = () => (
|
|
94
|
+
<>
|
|
95
|
+
<Button size="small">Small</Button>
|
|
96
|
+
<Button size="medium">Medium</Button>
|
|
97
|
+
</>
|
|
98
|
+
);
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Loading state
|
|
102
|
+
|
|
103
|
+
```jsx
|
|
104
|
+
import { Button } from "cleanplate";
|
|
105
|
+
|
|
106
|
+
export const Example = () => (
|
|
107
|
+
<Button isLoading>
|
|
108
|
+
Loading...
|
|
109
|
+
</Button>
|
|
110
|
+
);
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Disabled state
|
|
114
|
+
|
|
115
|
+
```jsx
|
|
116
|
+
import { Button } from "cleanplate";
|
|
117
|
+
|
|
118
|
+
export const Example = () => (
|
|
119
|
+
<Button isDisabled>
|
|
120
|
+
Disabled
|
|
121
|
+
</Button>
|
|
122
|
+
);
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Fluid button
|
|
126
|
+
|
|
127
|
+
```jsx
|
|
128
|
+
import { Button } from "cleanplate";
|
|
129
|
+
|
|
130
|
+
export const Example = () => (
|
|
131
|
+
<Button isFluid>
|
|
132
|
+
Full Width Button
|
|
133
|
+
</Button>
|
|
134
|
+
);
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### With margin spacing
|
|
138
|
+
|
|
139
|
+
```jsx
|
|
140
|
+
import { Button } from "cleanplate";
|
|
141
|
+
|
|
142
|
+
export const Example = () => (
|
|
143
|
+
<>
|
|
144
|
+
<Button margin="m-2">With margin</Button>
|
|
145
|
+
<Button margin={["m-1", "m-b-3"]}>With multiple margins</Button>
|
|
146
|
+
</>
|
|
147
|
+
);
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Submit button
|
|
151
|
+
|
|
152
|
+
```jsx
|
|
153
|
+
import { Button } from "cleanplate";
|
|
154
|
+
|
|
155
|
+
export const Example = () => (
|
|
156
|
+
<form onSubmit={(e) => { e.preventDefault(); console.log("Submitted"); }}>
|
|
157
|
+
<Button type="submit">Submit</Button>
|
|
158
|
+
</form>
|
|
159
|
+
);
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Behavior Notes
|
|
163
|
+
|
|
164
|
+
- When `isLoading` is true, a progress spinner icon is displayed and the button is automatically disabled.
|
|
165
|
+
- When `isDisabled` is true, click events are prevented and the button appears visually disabled.
|
|
166
|
+
- If both `isDisabled` and `isLoading` are true, the button is disabled and the loading spinner is shown.
|
|
167
|
+
- The `onClick` handler is not called if the button is disabled or loading, even if the event is triggered.
|
|
168
|
+
- The button extends standard HTML button attributes, so you can use props like `aria-label`, `data-*`, etc.
|
|
169
|
+
- The `type` prop defaults to `"button"` to prevent accidental form submissions. Use `type="submit"` for form submission buttons.
|
|
170
|
+
- Margin spacing accepts either a single string token (e.g., `"m-2"`) or an array of tokens (e.g., `["m-1", "m-b-3"]`).
|
|
171
|
+
|
|
172
|
+
## Related Components / Links
|
|
173
|
+
|
|
174
|
+
- Icon (used internally for loading spinner)
|
|
175
|
+
- FormControls (often used alongside buttons in forms)
|
package/docs/Icon.md
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
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 | string | no | "" | The name of the Material Symbol icon to display. See [Google Material Icons](https://fonts.google.com/icons) for available icon names. |
|
|
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?: string;
|
|
31
|
+
size?: IconSize;
|
|
32
|
+
className?: string;
|
|
33
|
+
color?: IconColor;
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
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`:
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" />
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Usage Examples
|
|
46
|
+
|
|
47
|
+
### Basic icon
|
|
48
|
+
|
|
49
|
+
```jsx
|
|
50
|
+
import { Icon } from "cleanplate";
|
|
51
|
+
|
|
52
|
+
export const Example = () => (
|
|
53
|
+
<Icon name="settings" />
|
|
54
|
+
);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Different sizes
|
|
58
|
+
|
|
59
|
+
```jsx
|
|
60
|
+
import { Icon } from "cleanplate";
|
|
61
|
+
|
|
62
|
+
export const Example = () => (
|
|
63
|
+
<>
|
|
64
|
+
<Icon name="home" size="small" />
|
|
65
|
+
<Icon name="home" size="medium" />
|
|
66
|
+
<Icon name="home" size="large" />
|
|
67
|
+
</>
|
|
68
|
+
);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Different colors
|
|
72
|
+
|
|
73
|
+
```jsx
|
|
74
|
+
import { Icon } from "cleanplate";
|
|
75
|
+
|
|
76
|
+
export const Example = () => (
|
|
77
|
+
<>
|
|
78
|
+
<Icon name="favorite" color="black" />
|
|
79
|
+
<Icon name="favorite" color="red" />
|
|
80
|
+
<Icon name="favorite" color="blue" />
|
|
81
|
+
<Icon name="favorite" color="green" />
|
|
82
|
+
</>
|
|
83
|
+
);
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Common icons
|
|
87
|
+
|
|
88
|
+
```jsx
|
|
89
|
+
import { Icon } from "cleanplate";
|
|
90
|
+
|
|
91
|
+
export const Example = () => (
|
|
92
|
+
<>
|
|
93
|
+
<Icon name="home" />
|
|
94
|
+
<Icon name="settings" />
|
|
95
|
+
<Icon name="search" />
|
|
96
|
+
<Icon name="menu" />
|
|
97
|
+
<Icon name="close" />
|
|
98
|
+
<Icon name="add" />
|
|
99
|
+
<Icon name="delete" />
|
|
100
|
+
<Icon name="edit" />
|
|
101
|
+
<Icon name="download" />
|
|
102
|
+
<Icon name="cloud_upload" />
|
|
103
|
+
</>
|
|
104
|
+
);
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### With custom className
|
|
108
|
+
|
|
109
|
+
```jsx
|
|
110
|
+
import { Icon } from "cleanplate";
|
|
111
|
+
|
|
112
|
+
export const Example = () => (
|
|
113
|
+
<Icon
|
|
114
|
+
name="star"
|
|
115
|
+
className="custom-icon-class"
|
|
116
|
+
size="large"
|
|
117
|
+
color="yellow"
|
|
118
|
+
/>
|
|
119
|
+
);
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### With HTML attributes
|
|
123
|
+
|
|
124
|
+
```jsx
|
|
125
|
+
import { Icon } from "cleanplate";
|
|
126
|
+
|
|
127
|
+
export const Example = () => (
|
|
128
|
+
<>
|
|
129
|
+
<Icon
|
|
130
|
+
name="info"
|
|
131
|
+
aria-label="Information icon"
|
|
132
|
+
data-testid="info-icon"
|
|
133
|
+
onClick={() => console.log("Icon clicked")}
|
|
134
|
+
/>
|
|
135
|
+
<Icon
|
|
136
|
+
name="error"
|
|
137
|
+
id="error-icon"
|
|
138
|
+
title="Error occurred"
|
|
139
|
+
/>
|
|
140
|
+
</>
|
|
141
|
+
);
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### In buttons
|
|
145
|
+
|
|
146
|
+
```jsx
|
|
147
|
+
import { Icon } from "cleanplate";
|
|
148
|
+
import { Button } from "cleanplate";
|
|
149
|
+
|
|
150
|
+
export const Example = () => (
|
|
151
|
+
<>
|
|
152
|
+
<Button>
|
|
153
|
+
<Icon name="save" size="small" />
|
|
154
|
+
Save
|
|
155
|
+
</Button>
|
|
156
|
+
<Button>
|
|
157
|
+
<Icon name="download" />
|
|
158
|
+
Download
|
|
159
|
+
</Button>
|
|
160
|
+
</>
|
|
161
|
+
);
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### With Typography
|
|
165
|
+
|
|
166
|
+
```jsx
|
|
167
|
+
import { Icon } from "cleanplate";
|
|
168
|
+
import { Typography } from "cleanplate";
|
|
169
|
+
|
|
170
|
+
export const Example = () => (
|
|
171
|
+
<Typography variant="p">
|
|
172
|
+
<Icon name="check_circle" color="green" size="small" />
|
|
173
|
+
{" "}Task completed
|
|
174
|
+
</Typography>
|
|
175
|
+
);
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Behavior Notes
|
|
179
|
+
|
|
180
|
+
- The component uses Google Material Symbols (Material Icons) font, which must be included in your project for icons to display correctly.
|
|
181
|
+
- Icon names should match the exact names from the [Google Material Icons library](https://fonts.google.com/icons). Use underscores instead of spaces (e.g., `cloud_upload` not `cloud upload`).
|
|
182
|
+
- The component renders as a `<span>` element, making it an inline element by default.
|
|
183
|
+
- If no `name` is provided, the icon will render as an empty span.
|
|
184
|
+
- The `color` prop applies predefined color classes. For custom colors, use the `className` prop with your own CSS.
|
|
185
|
+
- All standard HTML span attributes (like `onClick`, `aria-label`, `data-*`, etc.) are supported and passed through.
|
|
186
|
+
- Icons are scalable and will inherit the font size from their container if custom sizing is needed.
|
|
187
|
+
- The component is designed to work seamlessly with other CleanPlate components like Button, Typography, and Alert.
|
|
188
|
+
|
|
189
|
+
## Related Components / Links
|
|
190
|
+
|
|
191
|
+
- Button (commonly uses icons for visual enhancement)
|
|
192
|
+
- Typography (often combined with icons for inline content)
|
|
193
|
+
- Alert (uses icons to indicate different alert types)
|
|
194
|
+
- [Google Material Icons](https://fonts.google.com/icons) - Browse available icon names
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
# MediaObject Component
|
|
2
|
+
|
|
3
|
+
Purpose: A flexible layout pattern that combines media (icon, image, or avatar) with content (title and description). Perfect for displaying user profiles, product cards, notifications, and any content that needs a media element alongside text.
|
|
4
|
+
|
|
5
|
+
## Props / Inputs
|
|
6
|
+
|
|
7
|
+
| Prop | Type | Required | Default | Description |
|
|
8
|
+
| --- | --- | --- | --- | --- |
|
|
9
|
+
| title | string | yes | — | The main title text displayed in the content area. |
|
|
10
|
+
| mediaIcon | string | no | "" | Icon name from Material Symbols to display as the media element. |
|
|
11
|
+
| mediaImage | string | no | "" | Image URL to display as the media element. |
|
|
12
|
+
| mediaAvatar | string | no | "" | Name used to generate an avatar with initials and background color. |
|
|
13
|
+
| description | string | no | — | Secondary text displayed below the title. |
|
|
14
|
+
| margin | string \| string[] | no | "0" | Spacing utility token(s) for outer margin, such as `m-0` or `["m-1", "m-b-2"]`. |
|
|
15
|
+
| padding | string \| string[] | no | "0" | Spacing utility token(s) for inner padding, such as `p-0` or `["p-1", "p-b-2"]`. |
|
|
16
|
+
| className | string | no | "media-object" | Additional class names for the root element. |
|
|
17
|
+
| onClick | function | no | — | Called with the click event when the media object is clicked. |
|
|
18
|
+
| ...rest | React.HTMLAttributes<HTMLDivElement> | no | — | All other standard HTML div attributes are supported and passed through to the rendered element. |
|
|
19
|
+
|
|
20
|
+
## Types
|
|
21
|
+
|
|
22
|
+
### MediaObjectMargin
|
|
23
|
+
```typescript
|
|
24
|
+
type MediaObjectMargin = string | SpacingOption[];
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### MediaObjectPadding
|
|
28
|
+
```typescript
|
|
29
|
+
type MediaObjectPadding = string | SpacingOption[];
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### SpacingOption
|
|
33
|
+
```typescript
|
|
34
|
+
type SpacingOption = typeof SPACING_OPTIONS[number];
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### MediaObjectProps
|
|
38
|
+
```typescript
|
|
39
|
+
interface MediaObjectProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
40
|
+
mediaIcon?: string;
|
|
41
|
+
mediaImage?: string;
|
|
42
|
+
mediaAvatar?: string;
|
|
43
|
+
title: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
margin?: MediaObjectMargin;
|
|
46
|
+
padding?: MediaObjectPadding;
|
|
47
|
+
className?: string;
|
|
48
|
+
onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Usage Examples
|
|
53
|
+
|
|
54
|
+
### With icon
|
|
55
|
+
|
|
56
|
+
```jsx
|
|
57
|
+
import { MediaObject } from "cleanplate";
|
|
58
|
+
|
|
59
|
+
export const Example = () => (
|
|
60
|
+
<MediaObject
|
|
61
|
+
mediaIcon="person"
|
|
62
|
+
title="User Profile"
|
|
63
|
+
description="Manage your account settings and preferences"
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### With image
|
|
69
|
+
|
|
70
|
+
```jsx
|
|
71
|
+
import { MediaObject } from "cleanplate";
|
|
72
|
+
|
|
73
|
+
export const Example = () => (
|
|
74
|
+
<MediaObject
|
|
75
|
+
mediaImage="https://example.com/avatar.jpg"
|
|
76
|
+
title="John Doe"
|
|
77
|
+
description="Senior Developer at Tech Corp"
|
|
78
|
+
/>
|
|
79
|
+
);
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### With avatar (initials)
|
|
83
|
+
|
|
84
|
+
```jsx
|
|
85
|
+
import { MediaObject } from "cleanplate";
|
|
86
|
+
|
|
87
|
+
export const Example = () => (
|
|
88
|
+
<MediaObject
|
|
89
|
+
mediaAvatar="John Doe"
|
|
90
|
+
title="John Doe"
|
|
91
|
+
description="Senior Developer with 5+ years of experience"
|
|
92
|
+
/>
|
|
93
|
+
);
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Title only
|
|
97
|
+
|
|
98
|
+
```jsx
|
|
99
|
+
import { MediaObject } from "cleanplate";
|
|
100
|
+
|
|
101
|
+
export const Example = () => (
|
|
102
|
+
<MediaObject
|
|
103
|
+
mediaIcon="settings"
|
|
104
|
+
title="Settings"
|
|
105
|
+
/>
|
|
106
|
+
);
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### With margin and padding
|
|
110
|
+
|
|
111
|
+
```jsx
|
|
112
|
+
import { MediaObject } from "cleanplate";
|
|
113
|
+
|
|
114
|
+
export const Example = () => (
|
|
115
|
+
<>
|
|
116
|
+
<MediaObject
|
|
117
|
+
mediaIcon="star"
|
|
118
|
+
title="Featured Item"
|
|
119
|
+
description="This item has custom spacing"
|
|
120
|
+
margin="m-3"
|
|
121
|
+
padding="p-2"
|
|
122
|
+
/>
|
|
123
|
+
<MediaObject
|
|
124
|
+
mediaIcon="heart"
|
|
125
|
+
title="Another Item"
|
|
126
|
+
description="With multiple margin tokens"
|
|
127
|
+
margin={["m-1", "m-b-3"]}
|
|
128
|
+
padding={["p-1", "p-x-2"]}
|
|
129
|
+
/>
|
|
130
|
+
</>
|
|
131
|
+
);
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Clickable media object
|
|
135
|
+
|
|
136
|
+
```jsx
|
|
137
|
+
import { MediaObject } from "cleanplate";
|
|
138
|
+
|
|
139
|
+
export const Example = () => (
|
|
140
|
+
<MediaObject
|
|
141
|
+
mediaImage="https://example.com/product.jpg"
|
|
142
|
+
title="Wireless Headphones"
|
|
143
|
+
description="High-quality wireless headphones"
|
|
144
|
+
onClick={() => console.log("Media object clicked")}
|
|
145
|
+
/>
|
|
146
|
+
);
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### User profile card
|
|
150
|
+
|
|
151
|
+
```jsx
|
|
152
|
+
import { MediaObject } from "cleanplate";
|
|
153
|
+
import { Button } from "cleanplate";
|
|
154
|
+
|
|
155
|
+
export const Example = () => (
|
|
156
|
+
<div style={{
|
|
157
|
+
border: "1px solid #e0e0e0",
|
|
158
|
+
borderRadius: "8px",
|
|
159
|
+
padding: "16px"
|
|
160
|
+
}}>
|
|
161
|
+
<MediaObject
|
|
162
|
+
mediaImage="https://example.com/avatar.jpg"
|
|
163
|
+
title="John Doe"
|
|
164
|
+
description="Senior Developer • john.doe@example.com"
|
|
165
|
+
/>
|
|
166
|
+
<Button variant="outline" size="small" margin="m-t-3">
|
|
167
|
+
Edit Profile
|
|
168
|
+
</Button>
|
|
169
|
+
</div>
|
|
170
|
+
);
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Product card
|
|
174
|
+
|
|
175
|
+
```jsx
|
|
176
|
+
import { MediaObject } from "cleanplate";
|
|
177
|
+
import { Typography } from "cleanplate";
|
|
178
|
+
import { Button } from "cleanplate";
|
|
179
|
+
|
|
180
|
+
export const Example = () => (
|
|
181
|
+
<div style={{
|
|
182
|
+
border: "1px solid #e0e0e0",
|
|
183
|
+
borderRadius: "8px",
|
|
184
|
+
padding: "16px"
|
|
185
|
+
}}>
|
|
186
|
+
<MediaObject
|
|
187
|
+
mediaImage="https://example.com/product.jpg"
|
|
188
|
+
title="Wireless Headphones"
|
|
189
|
+
description="High-quality wireless headphones with noise cancellation"
|
|
190
|
+
/>
|
|
191
|
+
<div style={{ marginTop: "12px", display: "flex", justifyContent: "space-between", alignItems: "center" }}>
|
|
192
|
+
<Typography variant="h5">$199.99</Typography>
|
|
193
|
+
<Button size="small" variant="outline">Add to Cart</Button>
|
|
194
|
+
</div>
|
|
195
|
+
</div>
|
|
196
|
+
);
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Notification list
|
|
200
|
+
|
|
201
|
+
```jsx
|
|
202
|
+
import { MediaObject } from "cleanplate";
|
|
203
|
+
|
|
204
|
+
export const Example = () => (
|
|
205
|
+
<div>
|
|
206
|
+
<MediaObject
|
|
207
|
+
mediaIcon="notifications"
|
|
208
|
+
title="New Message"
|
|
209
|
+
description="You have received a new message from Jane Smith"
|
|
210
|
+
margin="m-b-2"
|
|
211
|
+
/>
|
|
212
|
+
<MediaObject
|
|
213
|
+
mediaIcon="schedule"
|
|
214
|
+
title="Meeting Reminder"
|
|
215
|
+
description="Team standup in 30 minutes"
|
|
216
|
+
margin="m-b-2"
|
|
217
|
+
/>
|
|
218
|
+
<MediaObject
|
|
219
|
+
mediaIcon="done"
|
|
220
|
+
title="Task Completed"
|
|
221
|
+
description="Your project 'Website Redesign' has been updated"
|
|
222
|
+
/>
|
|
223
|
+
</div>
|
|
224
|
+
);
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Settings items
|
|
228
|
+
|
|
229
|
+
```jsx
|
|
230
|
+
import { MediaObject } from "cleanplate";
|
|
231
|
+
|
|
232
|
+
export const Example = () => (
|
|
233
|
+
<div>
|
|
234
|
+
<MediaObject
|
|
235
|
+
mediaIcon="settings"
|
|
236
|
+
title="Account Settings"
|
|
237
|
+
description="Manage your account preferences and security settings"
|
|
238
|
+
margin="m-b-2"
|
|
239
|
+
/>
|
|
240
|
+
<MediaObject
|
|
241
|
+
mediaIcon="lock"
|
|
242
|
+
title="Privacy & Security"
|
|
243
|
+
description="Control your privacy settings and security options"
|
|
244
|
+
margin="m-b-2"
|
|
245
|
+
/>
|
|
246
|
+
<MediaObject
|
|
247
|
+
mediaIcon="notifications"
|
|
248
|
+
title="Notifications"
|
|
249
|
+
description="Configure how and when you receive notifications"
|
|
250
|
+
/>
|
|
251
|
+
</div>
|
|
252
|
+
);
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### List of users
|
|
256
|
+
|
|
257
|
+
```jsx
|
|
258
|
+
import { MediaObject } from "cleanplate";
|
|
259
|
+
|
|
260
|
+
export const Example = () => {
|
|
261
|
+
const users = [
|
|
262
|
+
{ name: "John Doe", role: "Developer", avatar: "https://example.com/avatar1.jpg" },
|
|
263
|
+
{ name: "Jane Smith", role: "Designer", avatar: "https://example.com/avatar2.jpg" },
|
|
264
|
+
{ name: "Mike Johnson", role: "Manager", avatar: "https://example.com/avatar3.jpg" }
|
|
265
|
+
];
|
|
266
|
+
|
|
267
|
+
return (
|
|
268
|
+
<div>
|
|
269
|
+
{users.map((user, index) => (
|
|
270
|
+
<MediaObject
|
|
271
|
+
key={index}
|
|
272
|
+
mediaImage={user.avatar}
|
|
273
|
+
title={user.name}
|
|
274
|
+
description={user.role}
|
|
275
|
+
margin={index < users.length - 1 ? "m-b-2" : "m-0"}
|
|
276
|
+
/>
|
|
277
|
+
))}
|
|
278
|
+
</div>
|
|
279
|
+
);
|
|
280
|
+
};
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
## Behavior Notes
|
|
284
|
+
|
|
285
|
+
- The `title` prop is required and will always be displayed in bold text.
|
|
286
|
+
- The `description` prop is optional. If not provided, only the title will be displayed.
|
|
287
|
+
- You can provide one of `mediaIcon`, `mediaImage`, or `mediaAvatar` to display the media element. If multiple are provided, the component will prioritize in this order: `mediaAvatar` > `mediaImage` > `mediaIcon`.
|
|
288
|
+
- The component uses the `Avatar` component internally to render the media element, which supports icons, images, and generated avatars with initials.
|
|
289
|
+
- The component uses the `Typography` component internally for the title and description text.
|
|
290
|
+
- The title is rendered with `isBold={true}` by default.
|
|
291
|
+
- The description is rendered with `variant="small"`.
|
|
292
|
+
- The component renders as a `<div>` element with a flex layout structure.
|
|
293
|
+
- Margin and padding spacing accept either a single string token (e.g., `"m-2"`) or an array of tokens (e.g., `["m-1", "m-b-3"]`).
|
|
294
|
+
- The `onClick` handler makes the entire media object clickable, useful for interactive lists or cards.
|
|
295
|
+
- All standard HTML div attributes can be passed through, allowing for custom `id`, `data-*`, `aria-*`, and other attributes.
|
|
296
|
+
- The component is designed to be responsive and adapts to different screen sizes.
|
|
297
|
+
|
|
298
|
+
## Related Components / Links
|
|
299
|
+
|
|
300
|
+
- Avatar (used internally for the media element)
|
|
301
|
+
- Typography (used internally for title and description)
|
|
302
|
+
- Button (often used alongside MediaObject in cards)
|
|
303
|
+
- Container (commonly used to wrap MediaObject components)
|