cleanplate 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +45 -0
- package/README.md +205 -60
- package/dist/components/icon/material-icon-names.d.ts +5 -5
- package/dist/components/icon/material-icon-names.d.ts.map +1 -1
- package/docs/Accordion.md +125 -0
- package/docs/Alert.md +131 -0
- package/docs/Animated.md +101 -0
- package/docs/AppShell.md +145 -0
- package/docs/Avatar.md +130 -0
- package/docs/Badge.md +83 -0
- package/docs/BottomSheet.md +78 -0
- package/docs/BreadCrumb.md +133 -0
- package/docs/Button.md +189 -0
- package/docs/ConfirmDialog.md +139 -0
- package/docs/Container.md +230 -0
- package/docs/Dropdown.md +175 -0
- package/docs/Footer.md +93 -0
- package/docs/FormControls.md +115 -0
- package/docs/Header.md +115 -0
- package/docs/Icon.md +225 -0
- package/docs/MediaObject.md +303 -0
- package/docs/MenuList.md +113 -0
- package/docs/Modal.md +152 -0
- package/docs/PageHeader.md +134 -0
- package/docs/Pagination.md +142 -0
- package/docs/Pills.md +104 -0
- package/docs/Spinner.md +115 -0
- package/docs/Stepper.md +131 -0
- package/docs/Table.md +194 -0
- package/docs/Toast.md +96 -0
- package/docs/Typography.md +231 -0
- package/llms.txt +293 -0
- package/package.json +7 -2
package/docs/Header.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Header Component
|
|
2
|
+
|
|
3
|
+
Purpose: Responsive navigation header with logo, menu items, and customizable left, center, and right slots. Use for app navigation. Supports sizes, variants, margin spacing, and a responsive mobile menu that slides in from the left. Uses MenuList for nav items; headerLeft, headerCenter, headerRight for custom content.
|
|
4
|
+
|
|
5
|
+
## Props / Inputs
|
|
6
|
+
|
|
7
|
+
| Prop | Type | Required | Default | Description |
|
|
8
|
+
| --- | --- | --- | --- | --- |
|
|
9
|
+
| logoUrl | string | no | — | URL for the logo image (shown when headerLeft is not provided). |
|
|
10
|
+
| activeMenuItem | string | no | — | Value of the currently active menu item (matches item.value). |
|
|
11
|
+
| onMenuItemClick | (item: MenuListItem) => void | no | — | Called when a menu item is clicked; receives the clicked item. |
|
|
12
|
+
| className | string | no | "" | Additional class names for the root element. |
|
|
13
|
+
| headerLeft | ReactNode | no | — | Custom content for the left area (replaces logo when provided). |
|
|
14
|
+
| headerRight | ReactNode | no | — | Custom content for the right area. |
|
|
15
|
+
| headerCenter | ReactNode | no | — | Custom content for the center area (replaces MenuList when provided). |
|
|
16
|
+
| menuItems | MenuListItem[] | yes | — | Menu items for center nav and mobile menu; each has label, value, optional icon. |
|
|
17
|
+
| size | "small" \| "medium" \| "large" | no | — | Size of the header. |
|
|
18
|
+
| variant | "light" \| "dark" | no | — | Visual variant. |
|
|
19
|
+
| margin | string \| SpacingOption[] | no | — | Spacing suffix(s) for outer margin; component adds m- prefix. |
|
|
20
|
+
|
|
21
|
+
## Types
|
|
22
|
+
|
|
23
|
+
### HeaderSize
|
|
24
|
+
```typescript
|
|
25
|
+
type HeaderSize = "small" | "medium" | "large";
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### HeaderVariant
|
|
29
|
+
```typescript
|
|
30
|
+
type HeaderVariant = "light" | "dark";
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### HeaderMargin
|
|
34
|
+
```typescript
|
|
35
|
+
type HeaderMargin = string | SpacingOption[];
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### HeaderProps
|
|
39
|
+
```typescript
|
|
40
|
+
interface HeaderProps {
|
|
41
|
+
logoUrl?: string;
|
|
42
|
+
activeMenuItem?: string;
|
|
43
|
+
onMenuItemClick?: (item: MenuListItem) => void;
|
|
44
|
+
className?: string;
|
|
45
|
+
headerLeft?: React.ReactNode;
|
|
46
|
+
headerRight?: React.ReactNode;
|
|
47
|
+
headerCenter?: React.ReactNode;
|
|
48
|
+
menuItems: MenuListItem[];
|
|
49
|
+
size?: HeaderSize;
|
|
50
|
+
variant?: HeaderVariant;
|
|
51
|
+
margin?: HeaderMargin;
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Usage Examples
|
|
56
|
+
|
|
57
|
+
### Basic
|
|
58
|
+
|
|
59
|
+
```jsx
|
|
60
|
+
import { useState } from "react";
|
|
61
|
+
import { Header, Avatar } from "cleanplate";
|
|
62
|
+
|
|
63
|
+
const MENU_ITEMS = [
|
|
64
|
+
{ label: "Dashboard", value: "/", icon: "speed" },
|
|
65
|
+
{ label: "Projects", value: "/projects", icon: "receipt_long" },
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
const AppHeader = () => {
|
|
69
|
+
const [activeMenuItem, setActiveMenuItem] = useState("/");
|
|
70
|
+
return (
|
|
71
|
+
<Header
|
|
72
|
+
logoUrl="/logo.svg"
|
|
73
|
+
menuItems={MENU_ITEMS}
|
|
74
|
+
activeMenuItem={activeMenuItem}
|
|
75
|
+
onMenuItemClick={(item) => setActiveMenuItem(item.value)}
|
|
76
|
+
headerRight={<Avatar name="John" />}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### With custom slots
|
|
83
|
+
|
|
84
|
+
```jsx
|
|
85
|
+
<Header
|
|
86
|
+
menuItems={menuItems}
|
|
87
|
+
activeMenuItem={activeItem}
|
|
88
|
+
onMenuItemClick={handleClick}
|
|
89
|
+
headerLeft={<img src="/logo.svg" alt="Logo" />}
|
|
90
|
+
headerRight={<Avatar name="User" />}
|
|
91
|
+
/>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Variants and sizes
|
|
95
|
+
|
|
96
|
+
```jsx
|
|
97
|
+
<Header menuItems={items} variant="light" activeMenuItem={active} onMenuItemClick={handle} />
|
|
98
|
+
<Header menuItems={items} variant="dark" activeMenuItem={active} onMenuItemClick={handle} />
|
|
99
|
+
<Header menuItems={items} size="small" activeMenuItem={active} onMenuItemClick={handle} />
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Behavior Notes
|
|
103
|
+
|
|
104
|
+
- **menuItems:** Required; each item has label, value, optional icon (Material icon name).
|
|
105
|
+
- **headerLeft / headerCenter / headerRight:** When provided, replace the default logo, MenuList, or right slot.
|
|
106
|
+
- **Mobile:** Below 1024px, center nav hides; hamburger shows. Click opens slide-in menu (Animated fade-in-left).
|
|
107
|
+
- **onMenuItemClick:** Called with the clicked item; mobile menu closes on click.
|
|
108
|
+
- **Margin:** Uses the suffix API (e.g. `"0"` → m-0).
|
|
109
|
+
|
|
110
|
+
## Related Components / Links
|
|
111
|
+
|
|
112
|
+
- MenuList (used in center and mobile menu)
|
|
113
|
+
- Avatar (commonly in headerRight)
|
|
114
|
+
- Button, Icon (mobile menu trigger and close)
|
|
115
|
+
- Animated (mobile menu slide-in)
|
package/docs/Icon.md
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
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)
|
|
@@ -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)
|