aidos-ui 4.0.0 → 4.0.1
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/.claude/settings.local.json +14 -1
- package/CLAUDE.md +72 -0
- package/dist/BaseButton.js.map +1 -1
- package/dist/BaseLink.js.map +1 -1
- package/dist/BaseListItem.d.ts +1 -1
- package/dist/Calendar.d.ts +2 -2
- package/dist/DarkMode.js.map +1 -1
- package/dist/DatePicker.js.map +1 -1
- package/dist/Dialog.d.ts +3 -3
- package/dist/Dialog.js.map +1 -1
- package/dist/Dropdown.js.map +1 -1
- package/dist/Icon.d.ts +3 -3
- package/dist/Icon.js +2 -21
- package/dist/Icon.js.map +1 -1
- package/dist/Interactable.js.map +1 -1
- package/dist/NextJSRouterState.js.map +1 -1
- package/dist/OnVisible.d.ts +1 -1
- package/dist/OnVisible.js.map +1 -1
- package/dist/Popover.d.ts +3 -3
- package/dist/Popover.js.map +1 -1
- package/dist/Providers.d.ts +2 -2
- package/dist/RangeInput.d.ts +1 -1
- package/dist/RootView.js.map +1 -1
- package/dist/Select.d.ts +0 -1
- package/dist/Storage.d.ts +2 -1
- package/dist/Storage.js.map +1 -1
- package/dist/Stream.js.map +1 -1
- package/dist/Text.js.map +1 -1
- package/dist/TextInput.d.ts +3 -2
- package/dist/TextInput.js +13 -4
- package/dist/TextInput.js.map +1 -1
- package/dist/TextPairing.js.map +1 -1
- package/dist/Tooltip.d.ts +2 -2
- package/dist/Tooltip.js.map +1 -1
- package/dist/aria.js.map +1 -1
- package/dist/hash.js.map +1 -1
- package/dist/jss.d.ts +6 -6
- package/dist/jss.js +2 -2
- package/dist/jss.js.map +1 -1
- package/dist/numberToBase.js.map +1 -1
- package/dist/stateMachineContextFactory.js.map +1 -1
- package/dist/useCookie.js.map +1 -1
- package/dist/useKeyboard.js.map +1 -1
- package/dist/useNavigation.js.map +1 -1
- package/dist/useRefEffect.js.map +1 -1
- package/next-env.d.ts +2 -1
- package/next.config.js +2 -1
- package/package.json +27 -20
- package/src/BaseListItem.tsx +1 -1
- package/src/Calendar.tsx +2 -2
- package/src/Dialog.tsx +3 -3
- package/src/Icon.tsx +4 -30
- package/src/Popover.tsx +3 -3
- package/src/Providers.tsx +1 -1
- package/src/RangeInput.tsx +1 -1
- package/src/Storage.tsx +1 -1
- package/src/TextInput.tsx +17 -5
- package/src/Tooltip.tsx +2 -2
- package/src/docs/mdx.tsx +40 -0
- package/src/docs/searchIndex.ts +1 -1
- package/src/jss.tsx +3 -3
- package/src/pages/Badge.mdx +136 -14
- package/src/pages/Button.mdx +121 -63
- package/src/pages/Calendar.mdx +196 -2
- package/src/pages/Card.mdx +123 -47
- package/src/pages/Checkbox.mdx +103 -28
- package/src/pages/Dialog.mdx +172 -7
- package/src/pages/FlexLayout.mdx +185 -51
- package/src/pages/Hashing.mdx +199 -8
- package/src/pages/Icon.mdx +150 -42
- package/src/pages/IconButton.mdx +127 -116
- package/src/pages/Link.mdx +118 -47
- package/src/pages/List.mdx +167 -283
- package/src/pages/ListHeader.mdx +157 -27
- package/src/pages/Popover.mdx +177 -55
- package/src/pages/ProgressBar.mdx +186 -6
- package/src/pages/ProgressCircle.mdx +196 -13
- package/src/pages/RangeInput.mdx +189 -61
- package/src/pages/Tabs.mdx +202 -346
- package/src/pages/Text.mdx +102 -81
- package/src/pages/TextInput.mdx +169 -44
- package/src/pages/TextPairing.mdx +164 -115
- package/src/pages/TimeInput.mdx +142 -37
- package/src/pages/Tooltip.mdx +99 -12
- package/src/pages/_app.tsx +13 -3
- package/src/pages/css-in-js.mdx +196 -83
- package/src/pages/navigation.mdx +122 -20
- package/src/pages/useCookie.mdx +168 -7
- package/src/pages/useKeyboard.mdx +242 -5
- package/src/pages/useNavigation.mdx +244 -16
- package/src/pages/usePromise.mdx +271 -6
- package/src/pages/useRefEffect.mdx +230 -28
- package/tsconfig.json +13 -4
package/src/jss.tsx
CHANGED
|
@@ -210,7 +210,7 @@ export function JSSProvider({
|
|
|
210
210
|
children,
|
|
211
211
|
}: {
|
|
212
212
|
themes: { dark: Theme; light: Theme };
|
|
213
|
-
children: JSX.Element;
|
|
213
|
+
children: React.JSX.Element;
|
|
214
214
|
}) {
|
|
215
215
|
const stylesRef = useRef<string[] | null>(null);
|
|
216
216
|
|
|
@@ -534,10 +534,10 @@ const backgroundStyles = {
|
|
|
534
534
|
backgroundColor: cssVar("--highlight"),
|
|
535
535
|
},
|
|
536
536
|
light: {
|
|
537
|
-
backgroundColor: "
|
|
537
|
+
backgroundColor: cssVar("--light-text"),
|
|
538
538
|
},
|
|
539
539
|
dark: {
|
|
540
|
-
backgroundColor: "
|
|
540
|
+
backgroundColor: cssVar("--primary-text"),
|
|
541
541
|
},
|
|
542
542
|
warning: {
|
|
543
543
|
backgroundColor: cssVar("--warning"),
|
package/src/pages/Badge.mdx
CHANGED
|
@@ -1,30 +1,152 @@
|
|
|
1
1
|
import { Badge } from "../Badge";
|
|
2
2
|
import { Row } from "../Row";
|
|
3
|
+
import { Column } from "../Column";
|
|
4
|
+
import { Span } from "../Text";
|
|
5
|
+
import { IconButton } from "../IconButton";
|
|
3
6
|
|
|
4
7
|
# Badge
|
|
5
8
|
|
|
6
|
-
|
|
9
|
+
A small circular indicator used to draw attention to specific UI elements. Common uses include notification counts, status indicators, and visual markers.
|
|
7
10
|
|
|
8
11
|
---
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
## Props
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
| Prop | Type | Default | Description |
|
|
16
|
+
|------|------|---------|-------------|
|
|
17
|
+
| `size` | `Size` | `"medium"` | Badge size: `"xsmall"` (4px), `"small"` (6px), `"medium"` (12px), `"large"` (18px), `"xlarge"` (24px) |
|
|
18
|
+
| `color` | `Color` | `"highlight"` | Background color from theme |
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Sizes
|
|
23
|
+
|
|
24
|
+
<Row gap="large" align="center" justify="center" padding="medium">
|
|
25
|
+
<Column align="center" gap="small">
|
|
26
|
+
<Badge size="xsmall" />
|
|
27
|
+
<Span size="small" color="secondary">xsmall</Span>
|
|
28
|
+
</Column>
|
|
29
|
+
<Column align="center" gap="small">
|
|
30
|
+
<Badge size="small" />
|
|
31
|
+
<Span size="small" color="secondary">small</Span>
|
|
32
|
+
</Column>
|
|
33
|
+
<Column align="center" gap="small">
|
|
34
|
+
<Badge size="medium" />
|
|
35
|
+
<Span size="small" color="secondary">medium</Span>
|
|
36
|
+
</Column>
|
|
37
|
+
<Column align="center" gap="small">
|
|
38
|
+
<Badge size="large" />
|
|
39
|
+
<Span size="small" color="secondary">large</Span>
|
|
40
|
+
</Column>
|
|
41
|
+
<Column align="center" gap="small">
|
|
42
|
+
<Badge size="xlarge" />
|
|
43
|
+
<Span size="small" color="secondary">xlarge</Span>
|
|
44
|
+
</Column>
|
|
18
45
|
</Row>
|
|
19
46
|
|
|
20
47
|
```js
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
48
|
+
<Badge size="xsmall" /> // 4px
|
|
49
|
+
<Badge size="small" /> // 6px
|
|
50
|
+
<Badge size="medium" /> // 12px (default)
|
|
51
|
+
<Badge size="large" /> // 18px
|
|
52
|
+
<Badge size="xlarge" /> // 24px
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Colors
|
|
58
|
+
|
|
59
|
+
<Row gap="large" align="center" justify="center" padding="medium">
|
|
60
|
+
<Column align="center" gap="small">
|
|
61
|
+
<Badge color="highlight" />
|
|
62
|
+
<Span size="small" color="secondary">highlight</Span>
|
|
63
|
+
</Column>
|
|
64
|
+
<Column align="center" gap="small">
|
|
65
|
+
<Badge color="negative" />
|
|
66
|
+
<Span size="small" color="secondary">negative</Span>
|
|
67
|
+
</Column>
|
|
68
|
+
<Column align="center" gap="small">
|
|
69
|
+
<Badge color="warning" />
|
|
70
|
+
<Span size="small" color="secondary">warning</Span>
|
|
71
|
+
</Column>
|
|
72
|
+
<Column align="center" gap="small">
|
|
73
|
+
<Badge color="divider" />
|
|
74
|
+
<Span size="small" color="secondary">divider</Span>
|
|
75
|
+
</Column>
|
|
27
76
|
</Row>
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
<Badge color="highlight" /> // Accent/brand color
|
|
80
|
+
<Badge color="negative" /> // Error/alert
|
|
81
|
+
<Badge color="warning" /> // Warning
|
|
82
|
+
<Badge color="divider" /> // Neutral/muted
|
|
28
83
|
```
|
|
29
84
|
|
|
30
85
|
---
|
|
86
|
+
|
|
87
|
+
## Common use cases
|
|
88
|
+
|
|
89
|
+
### Notification indicator
|
|
90
|
+
|
|
91
|
+
<Row gap="medium" align="center" padding="medium">
|
|
92
|
+
<Row jss={{ position: "relative" }}>
|
|
93
|
+
<IconButton bare icon="fa-bell" size="large" color="secondary" onClick={() => {}} />
|
|
94
|
+
<Badge size="small" color="negative" jss={{ position: "absolute", top: 0, right: 0 }} />
|
|
95
|
+
</Row>
|
|
96
|
+
<Span color="secondary">Unread notifications</Span>
|
|
97
|
+
</Row>
|
|
98
|
+
|
|
99
|
+
```js
|
|
100
|
+
<Row jss={{ position: "relative" }}>
|
|
101
|
+
<IconButton bare icon="fa-bell" size="large" color="secondary" onClick={() => {}} />
|
|
102
|
+
<Badge
|
|
103
|
+
size="small"
|
|
104
|
+
color="negative"
|
|
105
|
+
jss={{ position: "absolute", top: 0, right: 0 }}
|
|
106
|
+
/>
|
|
107
|
+
</Row>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Status indicator
|
|
111
|
+
|
|
112
|
+
<Column gap="small" padding="medium">
|
|
113
|
+
<Row gap="small" align="center">
|
|
114
|
+
<Badge size="small" color="highlight" />
|
|
115
|
+
<Span>Online</Span>
|
|
116
|
+
</Row>
|
|
117
|
+
<Row gap="small" align="center">
|
|
118
|
+
<Badge size="small" color="warning" />
|
|
119
|
+
<Span>Away</Span>
|
|
120
|
+
</Row>
|
|
121
|
+
<Row gap="small" align="center">
|
|
122
|
+
<Badge size="small" color="divider" />
|
|
123
|
+
<Span>Offline</Span>
|
|
124
|
+
</Row>
|
|
125
|
+
</Column>
|
|
126
|
+
|
|
127
|
+
```js
|
|
128
|
+
<Row gap="small" align="center">
|
|
129
|
+
<Badge size="small" color="highlight" />
|
|
130
|
+
<Span>Online</Span>
|
|
131
|
+
</Row>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Visual markers
|
|
137
|
+
|
|
138
|
+
Use badges to highlight new or important items:
|
|
139
|
+
|
|
140
|
+
<Row gap="medium" align="center" padding="medium">
|
|
141
|
+
<Row gap="small" align="center">
|
|
142
|
+
<Span>New feature</Span>
|
|
143
|
+
<Badge size="xsmall" color="highlight" />
|
|
144
|
+
</Row>
|
|
145
|
+
</Row>
|
|
146
|
+
|
|
147
|
+
```js
|
|
148
|
+
<Row gap="small" align="center">
|
|
149
|
+
<Span>New feature</Span>
|
|
150
|
+
<Badge size="xsmall" color="highlight" />
|
|
151
|
+
</Row>
|
|
152
|
+
```
|
package/src/pages/Button.mdx
CHANGED
|
@@ -1,105 +1,163 @@
|
|
|
1
1
|
import { Button } from "../Button";
|
|
2
2
|
import { Row } from "../Row";
|
|
3
|
+
import { Column } from "../Column";
|
|
4
|
+
import { Icon } from "../Icon";
|
|
3
5
|
|
|
4
6
|
# Button
|
|
5
7
|
|
|
6
|
-
The `Button` component
|
|
8
|
+
The `Button` component enables users to trigger actions with a single click. It supports multiple color variants for different semantic purposes and can include icons.
|
|
7
9
|
|
|
8
10
|
---
|
|
9
11
|
|
|
10
|
-
##
|
|
12
|
+
## Props
|
|
13
|
+
|
|
14
|
+
| Prop | Type | Required | Default | Description |
|
|
15
|
+
|------|------|----------|---------|-------------|
|
|
16
|
+
| `children` | `string` | Yes | - | Button text label |
|
|
17
|
+
| `color` | `InteractableColor` | Yes | - | `"positive"`, `"primary"`, `"negative"`, `"dark"`, `"light"` |
|
|
18
|
+
| `onClick` | `function` | Yes | - | Click handler |
|
|
19
|
+
| `bare` | `boolean` | No | `false` | Removes background for a lighter appearance |
|
|
20
|
+
| `border` | `boolean` | No | `false` | Adds a border matching the text color |
|
|
21
|
+
| `disabled` | `boolean` | No | `false` | Disables interaction |
|
|
22
|
+
| `icon` | `IconType` | No | - | Icon to display alongside text |
|
|
23
|
+
| `iconPosition` | `"left"` \| `"right"` | No | `"left"` | Icon placement relative to text |
|
|
24
|
+
| `iconSize` | `Size` | No | `"medium"` | Icon size |
|
|
25
|
+
| `size` | `Size` | No | `"medium"` | Text size |
|
|
26
|
+
| `padding` | `Padding` | No | `"medium"` | Internal padding |
|
|
27
|
+
| `bold` | `boolean` | No | `false` | Bold text |
|
|
11
28
|
|
|
12
|
-
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Color variants
|
|
32
|
+
|
|
33
|
+
Each color variant communicates a different intent to users:
|
|
13
34
|
|
|
14
|
-
- Positive
|
|
15
|
-
- Primary
|
|
16
|
-
- Negative
|
|
17
|
-
- Dark
|
|
18
|
-
- Light: primary actions in a light theme
|
|
19
|
-
- Disabled: actions that are not available
|
|
35
|
+
- **Positive**: Confirmations, submissions, primary actions
|
|
36
|
+
- **Primary**: Secondary or neutral actions
|
|
37
|
+
- **Negative**: Destructive actions like delete or remove
|
|
38
|
+
- **Dark/Light**: Theme-specific variants for special contexts
|
|
20
39
|
|
|
21
40
|
<Row gap="large" align="center" padding="large" justify="center">
|
|
22
|
-
<Button
|
|
23
|
-
<Button
|
|
24
|
-
<Button
|
|
25
|
-
<Button
|
|
26
|
-
<Button
|
|
27
|
-
<Button label="Light" color="light" onClick={() => {}} />
|
|
41
|
+
<Button color="positive" onClick={() => {}}>Positive</Button>
|
|
42
|
+
<Button color="primary" onClick={() => {}}>Primary</Button>
|
|
43
|
+
<Button color="negative" onClick={() => {}}>Negative</Button>
|
|
44
|
+
<Button color="dark" onClick={() => {}}>Dark</Button>
|
|
45
|
+
<Button color="light" onClick={() => {}}>Light</Button>
|
|
28
46
|
</Row>
|
|
29
47
|
|
|
30
48
|
```js
|
|
49
|
+
<Button color="positive" onClick={() => {}}>Positive</Button>
|
|
50
|
+
<Button color="primary" onClick={() => {}}>Primary</Button>
|
|
51
|
+
<Button color="negative" onClick={() => {}}>Negative</Button>
|
|
52
|
+
<Button color="dark" onClick={() => {}}>Dark</Button>
|
|
53
|
+
<Button color="light" onClick={() => {}}>Light</Button>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Bare variant
|
|
59
|
+
|
|
60
|
+
The `bare` prop removes the background color, creating a lighter appearance that integrates well within complex layouts or when you need a less prominent action.
|
|
61
|
+
|
|
31
62
|
<Row gap="large" align="center" padding="large" justify="center">
|
|
32
|
-
<Button
|
|
33
|
-
<Button
|
|
34
|
-
<Button
|
|
35
|
-
<Button
|
|
36
|
-
<Button
|
|
37
|
-
<Button label="Light" color="light" onClick={() => {}} />
|
|
63
|
+
<Button bare color="positive" onClick={() => {}}>Positive</Button>
|
|
64
|
+
<Button bare color="primary" onClick={() => {}}>Primary</Button>
|
|
65
|
+
<Button bare color="negative" onClick={() => {}}>Negative</Button>
|
|
66
|
+
<Button bare color="dark" onClick={() => {}}>Dark</Button>
|
|
67
|
+
<Button bare color="light" onClick={() => {}}>Light</Button>
|
|
38
68
|
</Row>
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
<Button bare color="positive" onClick={() => {}}>Positive</Button>
|
|
72
|
+
<Button bare color="primary" onClick={() => {}}>Primary</Button>
|
|
73
|
+
<Button bare color="negative" onClick={() => {}}>Negative</Button>
|
|
39
74
|
```
|
|
40
75
|
|
|
41
76
|
---
|
|
42
77
|
|
|
43
|
-
##
|
|
78
|
+
## With border
|
|
44
79
|
|
|
45
|
-
|
|
80
|
+
Add a `border` prop to give buttons a defined edge. Works well with `bare` for outlined button styles.
|
|
46
81
|
|
|
47
82
|
<Row gap="large" align="center" padding="large" justify="center">
|
|
48
|
-
<Button bare
|
|
49
|
-
<Button bare
|
|
50
|
-
<Button bare
|
|
51
|
-
<Button bare label="Disabled" color="positive" disabled onClick={() => {}} />
|
|
52
|
-
<Button bare label="Dark" color="dark" onClick={() => {}} />
|
|
53
|
-
<Button bare label="Light" color="light" onClick={() => {}} />
|
|
83
|
+
<Button border bare color="positive" onClick={() => {}}>Positive</Button>
|
|
84
|
+
<Button border bare color="primary" onClick={() => {}}>Primary</Button>
|
|
85
|
+
<Button border bare color="negative" onClick={() => {}}>Negative</Button>
|
|
54
86
|
</Row>
|
|
55
87
|
|
|
56
88
|
```js
|
|
89
|
+
<Button border bare color="positive" onClick={() => {}}>Outlined</Button>
|
|
90
|
+
<Button border bare color="primary" onClick={() => {}}>Outlined</Button>
|
|
91
|
+
<Button border bare color="negative" onClick={() => {}}>Outlined</Button>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## With icon
|
|
97
|
+
|
|
98
|
+
Buttons can include icons to reinforce their purpose. Use `icon` to specify the icon and `iconPosition` to place it on the left or right.
|
|
99
|
+
|
|
57
100
|
<Row gap="large" align="center" padding="large" justify="center">
|
|
58
|
-
<Button
|
|
59
|
-
<Button
|
|
60
|
-
<Button
|
|
61
|
-
<Button bare label="Disabled" color="positive" disabled onClick={() => {}} />
|
|
62
|
-
<Button bare label="Dark" color="dark" onClick={() => {}} />
|
|
63
|
-
<Button bare label="Light" color="light" onClick={() => {}} />
|
|
101
|
+
<Button color="positive" icon="fa-check" onClick={() => {}}>Confirm</Button>
|
|
102
|
+
<Button color="negative" icon="fa-trash" onClick={() => {}}>Delete</Button>
|
|
103
|
+
<Button color="primary" icon="fa-arrow-right" iconPosition="right" onClick={() => {}}>Next</Button>
|
|
64
104
|
</Row>
|
|
105
|
+
|
|
106
|
+
```js
|
|
107
|
+
<Button color="positive" icon="fa-check" onClick={() => {}}>
|
|
108
|
+
Confirm
|
|
109
|
+
</Button>
|
|
110
|
+
|
|
111
|
+
<Button color="negative" icon="fa-trash" onClick={() => {}}>
|
|
112
|
+
Delete
|
|
113
|
+
</Button>
|
|
114
|
+
|
|
115
|
+
<Button color="primary" icon="fa-arrow-right" iconPosition="right" onClick={() => {}}>
|
|
116
|
+
Next
|
|
117
|
+
</Button>
|
|
65
118
|
```
|
|
66
119
|
|
|
67
|
-
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Disabled state
|
|
68
123
|
|
|
69
|
-
|
|
124
|
+
Disabled buttons prevent interaction and display a muted appearance. The component uses `aria-disabled` for accessibility.
|
|
70
125
|
|
|
71
126
|
<Row gap="large" align="center" padding="large" justify="center">
|
|
72
|
-
<Button
|
|
73
|
-
<Button
|
|
74
|
-
<Button border bare
|
|
75
|
-
<Button
|
|
76
|
-
border
|
|
77
|
-
bare
|
|
78
|
-
label="Disabled"
|
|
79
|
-
color="positive"
|
|
80
|
-
disabled
|
|
81
|
-
onClick={() => {}}
|
|
82
|
-
/>
|
|
83
|
-
<Button border bare label="Dark" color="dark" onClick={() => {}} />
|
|
84
|
-
<Button border bare label="Light" color="light" onClick={() => {}} />
|
|
127
|
+
<Button color="positive" disabled onClick={() => {}}>Disabled</Button>
|
|
128
|
+
<Button bare color="positive" disabled onClick={() => {}}>Disabled bare</Button>
|
|
129
|
+
<Button border bare color="positive" disabled onClick={() => {}}>Disabled outlined</Button>
|
|
85
130
|
</Row>
|
|
86
131
|
|
|
87
132
|
```js
|
|
133
|
+
<Button color="positive" disabled onClick={() => {}}>
|
|
134
|
+
Disabled
|
|
135
|
+
</Button>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Sizes
|
|
141
|
+
|
|
142
|
+
Control text size with the `size` prop. Available sizes: `"xsmall"`, `"small"`, `"medium"`, `"large"`, `"xlarge"`.
|
|
143
|
+
|
|
88
144
|
<Row gap="large" align="center" padding="large" justify="center">
|
|
89
|
-
<Button
|
|
90
|
-
<Button
|
|
91
|
-
<Button
|
|
92
|
-
<Button
|
|
93
|
-
border
|
|
94
|
-
bare
|
|
95
|
-
label="Disabled"
|
|
96
|
-
color="positive"
|
|
97
|
-
disabled
|
|
98
|
-
onClick={() => {}}
|
|
99
|
-
/>
|
|
100
|
-
<Button border bare label="Dark" color="dark" onClick={() => {}} />
|
|
101
|
-
<Button border bare label="Light" color="light" onClick={() => {}} />
|
|
145
|
+
<Button color="positive" size="small" onClick={() => {}}>Small</Button>
|
|
146
|
+
<Button color="positive" size="medium" onClick={() => {}}>Medium</Button>
|
|
147
|
+
<Button color="positive" size="large" onClick={() => {}}>Large</Button>
|
|
102
148
|
</Row>
|
|
149
|
+
|
|
150
|
+
```js
|
|
151
|
+
<Button color="positive" size="small" onClick={() => {}}>Small</Button>
|
|
152
|
+
<Button color="positive" size="medium" onClick={() => {}}>Medium</Button>
|
|
153
|
+
<Button color="positive" size="large" onClick={() => {}}>Large</Button>
|
|
103
154
|
```
|
|
104
155
|
|
|
105
156
|
---
|
|
157
|
+
|
|
158
|
+
## Accessibility
|
|
159
|
+
|
|
160
|
+
- Buttons use semantic `<button>` elements
|
|
161
|
+
- Disabled state is communicated via `aria-disabled` attribute
|
|
162
|
+
- Focus states are clearly visible with outline styling
|
|
163
|
+
- Click handlers are ignored when disabled, preventing accidental actions
|
package/src/pages/Calendar.mdx
CHANGED
|
@@ -1,11 +1,97 @@
|
|
|
1
1
|
import { Calendar } from "../Calendar";
|
|
2
2
|
import { Box } from "../Box";
|
|
3
|
+
import { Row } from "../Row";
|
|
4
|
+
import { Column } from "../Column";
|
|
3
5
|
import { Badge } from "../Badge";
|
|
4
6
|
import { Span, H3 } from "../Text";
|
|
7
|
+
import { cssVar } from "../jss";
|
|
5
8
|
|
|
6
9
|
# Calendar
|
|
7
10
|
|
|
8
|
-
|
|
11
|
+
A flexible calendar grid component for displaying months. Fully customizable through render callbacks for both header cells (weekday names) and day cells.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Props
|
|
16
|
+
|
|
17
|
+
| Prop | Type | Default | Description |
|
|
18
|
+
|------|------|---------|-------------|
|
|
19
|
+
| `date` | `Date` | Required | The month to display (uses year and month from this date) |
|
|
20
|
+
| `header` | `(props) => JSX.Element` | Required | Render function for weekday header cells |
|
|
21
|
+
| `cell` | `(props) => JSX.Element` | Required | Render function for day cells |
|
|
22
|
+
| `jss` | `JSS` | - | Custom styles for the calendar grid |
|
|
23
|
+
|
|
24
|
+
### Header render props
|
|
25
|
+
|
|
26
|
+
| Property | Type | Description |
|
|
27
|
+
|----------|------|-------------|
|
|
28
|
+
| `weekday` | `string` | Localized weekday abbreviation (Mon, Tue, etc.) |
|
|
29
|
+
|
|
30
|
+
### Cell render props
|
|
31
|
+
|
|
32
|
+
| Property | Type | Description |
|
|
33
|
+
|----------|------|-------------|
|
|
34
|
+
| `date` | `Date` | The date for this cell |
|
|
35
|
+
| `today` | `boolean` | Whether this date is today |
|
|
36
|
+
| `outOfMonth` | `boolean` | Whether this date is outside the current month |
|
|
37
|
+
| `top` | `boolean` | Whether this cell is in the top row |
|
|
38
|
+
| `bottom` | `boolean` | Whether this cell is in the bottom row |
|
|
39
|
+
| `left` | `boolean` | Whether this cell is in the leftmost column |
|
|
40
|
+
| `right` | `boolean` | Whether this cell is in the rightmost column |
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Basic usage
|
|
45
|
+
|
|
46
|
+
<Calendar
|
|
47
|
+
date={new Date()}
|
|
48
|
+
header={({ weekday }) => (
|
|
49
|
+
<Box padding="small" jss={{ textAlign: "center" }}>
|
|
50
|
+
<Span bold color="secondary" size="small">{weekday}</Span>
|
|
51
|
+
</Box>
|
|
52
|
+
)}
|
|
53
|
+
cell={({ today, date, outOfMonth }) => (
|
|
54
|
+
<Box padding="small" relative={true} jss={{ opacity: outOfMonth ? 0.3 : 1, textAlign: "center" }}>
|
|
55
|
+
{today && (
|
|
56
|
+
<Badge
|
|
57
|
+
size="xlarge"
|
|
58
|
+
color="highlight"
|
|
59
|
+
jss={{
|
|
60
|
+
position: "absolute",
|
|
61
|
+
top: "50%",
|
|
62
|
+
left: "50%",
|
|
63
|
+
transform: "translate(-50%, -50%)",
|
|
64
|
+
zIndex: 0,
|
|
65
|
+
}}
|
|
66
|
+
/>
|
|
67
|
+
)}
|
|
68
|
+
<Span jss={{ position: "relative", zIndex: 1 }} color={today ? "light" : "primary"}>
|
|
69
|
+
{date.getDate()}
|
|
70
|
+
</Span>
|
|
71
|
+
</Box>
|
|
72
|
+
)}
|
|
73
|
+
/>
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
<Calendar
|
|
77
|
+
date={new Date()}
|
|
78
|
+
header={({ weekday }) => (
|
|
79
|
+
<Box padding="small" jss={{ textAlign: "center" }}>
|
|
80
|
+
<Span bold color="secondary" size="small">{weekday}</Span>
|
|
81
|
+
</Box>
|
|
82
|
+
)}
|
|
83
|
+
cell={({ today, date, outOfMonth }) => (
|
|
84
|
+
<Box padding="small" jss={{ opacity: outOfMonth ? 0.3 : 1 }}>
|
|
85
|
+
{today && <Badge color="highlight" />}
|
|
86
|
+
<Span>{date.getDate()}</Span>
|
|
87
|
+
</Box>
|
|
88
|
+
)}
|
|
89
|
+
/>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## With today indicator
|
|
9
95
|
|
|
10
96
|
<Calendar
|
|
11
97
|
date={new Date()}
|
|
@@ -36,7 +122,7 @@ The calendar component is can be used to represent months, and is customisable t
|
|
|
36
122
|
date={new Date()}
|
|
37
123
|
header={({ weekday }) => (
|
|
38
124
|
<Box>
|
|
39
|
-
<
|
|
125
|
+
<H3>{weekday}</H3>
|
|
40
126
|
</Box>
|
|
41
127
|
)}
|
|
42
128
|
cell={({ today, date, outOfMonth }) => (
|
|
@@ -58,3 +144,111 @@ The calendar component is can be used to represent months, and is customisable t
|
|
|
58
144
|
```
|
|
59
145
|
|
|
60
146
|
---
|
|
147
|
+
|
|
148
|
+
## Using position props
|
|
149
|
+
|
|
150
|
+
The cell render props include position information for styling borders and corners:
|
|
151
|
+
|
|
152
|
+
```js
|
|
153
|
+
<Calendar
|
|
154
|
+
date={new Date()}
|
|
155
|
+
header={({ weekday }) => <Span>{weekday}</Span>}
|
|
156
|
+
cell={({ date, outOfMonth, top, bottom, left, right }) => (
|
|
157
|
+
<Box
|
|
158
|
+
jss={{
|
|
159
|
+
opacity: outOfMonth ? 0.3 : 1,
|
|
160
|
+
borderTop: top ? "1px solid var(--divider)" : "none",
|
|
161
|
+
borderBottom: bottom ? "1px solid var(--divider)" : "none",
|
|
162
|
+
borderLeft: left ? "1px solid var(--divider)" : "none",
|
|
163
|
+
borderRight: right ? "1px solid var(--divider)" : "none",
|
|
164
|
+
borderTopLeftRadius: top && left ? 8 : 0,
|
|
165
|
+
borderTopRightRadius: top && right ? 8 : 0,
|
|
166
|
+
borderBottomLeftRadius: bottom && left ? 8 : 0,
|
|
167
|
+
borderBottomRightRadius: bottom && right ? 8 : 0,
|
|
168
|
+
}}
|
|
169
|
+
>
|
|
170
|
+
<Span>{date.getDate()}</Span>
|
|
171
|
+
</Box>
|
|
172
|
+
)}
|
|
173
|
+
/>
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Interactive calendar
|
|
179
|
+
|
|
180
|
+
Create a date picker by adding click handlers:
|
|
181
|
+
|
|
182
|
+
```js
|
|
183
|
+
function DatePicker() {
|
|
184
|
+
const [selected, setSelected] = useState(null);
|
|
185
|
+
const [month, setMonth] = useState(new Date());
|
|
186
|
+
|
|
187
|
+
return (
|
|
188
|
+
<Column gap="medium">
|
|
189
|
+
<Row justify="space-between" align="center">
|
|
190
|
+
<IconButton
|
|
191
|
+
icon="fa-chevron-left"
|
|
192
|
+
onClick={() => setMonth(new Date(month.getFullYear(), month.getMonth() - 1))}
|
|
193
|
+
/>
|
|
194
|
+
<Span bold>
|
|
195
|
+
{month.toLocaleDateString("en-US", { month: "long", year: "numeric" })}
|
|
196
|
+
</Span>
|
|
197
|
+
<IconButton
|
|
198
|
+
icon="fa-chevron-right"
|
|
199
|
+
onClick={() => setMonth(new Date(month.getFullYear(), month.getMonth() + 1))}
|
|
200
|
+
/>
|
|
201
|
+
</Row>
|
|
202
|
+
<Calendar
|
|
203
|
+
date={month}
|
|
204
|
+
header={({ weekday }) => <Span size="small">{weekday}</Span>}
|
|
205
|
+
cell={({ date, outOfMonth, today }) => {
|
|
206
|
+
const isSelected = selected?.toDateString() === date.toDateString();
|
|
207
|
+
return (
|
|
208
|
+
<BaseButton
|
|
209
|
+
bare
|
|
210
|
+
onClick={() => !outOfMonth && setSelected(date)}
|
|
211
|
+
jss={{
|
|
212
|
+
opacity: outOfMonth ? 0.3 : 1,
|
|
213
|
+
backgroundColor: isSelected ? "var(--highlight)" : "transparent",
|
|
214
|
+
borderRadius: "50%",
|
|
215
|
+
}}
|
|
216
|
+
>
|
|
217
|
+
<Span color={isSelected ? "light" : "primary"}>
|
|
218
|
+
{date.getDate()}
|
|
219
|
+
</Span>
|
|
220
|
+
</BaseButton>
|
|
221
|
+
);
|
|
222
|
+
}}
|
|
223
|
+
/>
|
|
224
|
+
</Column>
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Grid layout
|
|
232
|
+
|
|
233
|
+
The Calendar uses CSS Grid with 7 columns (Mon-Sun). The header row and day cells flow naturally into the grid:
|
|
234
|
+
|
|
235
|
+
```js
|
|
236
|
+
// Custom grid styling
|
|
237
|
+
<Calendar
|
|
238
|
+
date={new Date()}
|
|
239
|
+
jss={{
|
|
240
|
+
gap: 4,
|
|
241
|
+
padding: 16,
|
|
242
|
+
backgroundColor: "var(--secondary-background)",
|
|
243
|
+
borderRadius: 12,
|
|
244
|
+
}}
|
|
245
|
+
header={...}
|
|
246
|
+
cell={...}
|
|
247
|
+
/>
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## Localization
|
|
253
|
+
|
|
254
|
+
Weekday names are automatically localized using `Intl.DateTimeFormat` with UK English locale (week starts Monday). The calendar always displays Monday through Sunday.
|