anvilui 0.1.0 → 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/AGENTS.md +483 -0
- package/README.md +70 -3
- package/bin/anvilui.mjs +83 -0
- package/dist/colors/colors.d.ts +10 -2
- package/dist/components/Accordion/Accordion.d.ts +36 -0
- package/dist/components/AnimatedNumber/AnimatedNumber.d.ts +17 -0
- package/dist/components/AnvilRoot/AnvilContext.d.ts +22 -2
- package/dist/components/AnvilRoot/AnvilRoot.d.ts +44 -6
- package/dist/components/AppBar/AppBar.d.ts +13 -2
- package/dist/components/Avatar/Avatar.d.ts +6 -2
- package/dist/components/Avatar/AvatarGroupContext.d.ts +1 -0
- package/dist/components/AvatarGroup/AvatarGroup.d.ts +25 -0
- package/dist/components/Badge/Badge.d.ts +4 -0
- package/dist/components/BottomSheet/BottomSheet.d.ts +22 -0
- package/dist/components/Button/Button.d.ts +17 -0
- package/dist/components/Calendar/Calendar.d.ts +19 -0
- package/dist/components/Card/Card.d.ts +36 -0
- package/dist/components/Carousel/Carousel.d.ts +21 -0
- package/dist/components/Checkbox/Checkbox.d.ts +10 -0
- package/dist/components/Chip/Chip.d.ts +25 -2
- package/dist/components/Combobox/Combobox.d.ts +42 -0
- package/dist/components/Confetti/Confetti.d.ts +31 -0
- package/dist/components/ContextMenu/ContextMenu.d.ts +24 -0
- package/dist/components/DateInput/DateInput.d.ts +37 -0
- package/dist/components/Dialog/Dialog.d.ts +32 -0
- package/dist/components/Divider/Divider.d.ts +8 -0
- package/dist/components/FAB/FAB.d.ts +4 -0
- package/dist/components/FAB/magnet.d.ts +2 -0
- package/dist/components/FABMenu/FABMenu.d.ts +55 -0
- package/dist/components/Field/Field.d.ts +20 -0
- package/dist/components/FloatingToolbar/FloatingToolbar.d.ts +15 -0
- package/dist/components/HoldButton/HoldButton.d.ts +4 -1
- package/dist/components/Icon/Icon.d.ts +14 -0
- package/dist/components/IconButton/IconButton.d.ts +11 -0
- package/dist/components/Input/Input.d.ts +9 -0
- package/dist/components/Kbd/Kbd.d.ts +21 -0
- package/dist/components/List/List.d.ts +10 -1
- package/dist/components/Menu/Menu.d.ts +32 -0
- package/dist/components/Menubar/Menubar.d.ts +17 -0
- package/dist/components/NavigationBar/NavigationBar.d.ts +10 -0
- package/dist/components/NavigationDrawer/NavigationDrawer.d.ts +22 -0
- package/dist/components/NavigationList/NavigationList.d.ts +27 -0
- package/dist/components/NavigationRail/NavigationRail.d.ts +25 -9
- package/dist/components/PinInput/PinInput.d.ts +31 -0
- package/dist/components/Popover/Popover.d.ts +30 -2
- package/dist/components/PreviewCard/PreviewCard.d.ts +31 -0
- package/dist/components/Progress/Progress.d.ts +8 -1
- package/dist/components/RadioGroup/RadioGroup.d.ts +12 -0
- package/dist/components/Search/Search.d.ts +39 -0
- package/dist/components/Select/Select.d.ts +15 -2
- package/dist/components/Skeleton/Skeleton.d.ts +20 -0
- package/dist/components/Slider/Slider.d.ts +5 -0
- package/dist/components/Snackbar/Snackbar.d.ts +7 -2
- package/dist/components/SplitButton/SplitButton.d.ts +13 -0
- package/dist/components/Sticker/Sticker.d.ts +21 -0
- package/dist/components/Switch/Switch.d.ts +11 -0
- package/dist/components/Table/Table.d.ts +36 -0
- package/dist/components/Tabs/Tabs.d.ts +17 -0
- package/dist/components/Textarea/Textarea.d.ts +8 -0
- package/dist/components/TimePicker/TimePicker.d.ts +45 -0
- package/dist/components/Toggle/Toggle.d.ts +41 -0
- package/dist/components/ToggleGroup/ToggleGroup.d.ts +14 -2
- package/dist/components/Tooltip/Tooltip.d.ts +10 -1
- package/dist/components/Typography/Typography.d.ts +13 -1
- package/dist/datetime.d.ts +12 -0
- package/dist/dev.d.ts +15 -0
- package/dist/index.cjs +3105 -634
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1417 -364
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +50 -4
- package/dist/index.js +3038 -591
- package/dist/index.js.map +1 -1
- package/dist/themes/baseTheme.d.ts +2 -0
- package/dist/themes/createTheme.d.ts +22 -0
- package/dist/themes/monochromeTheme.d.ts +2 -0
- package/dist/themes/types.d.ts +15 -6
- package/dist/tokens/baseTokens.d.ts +4 -0
- package/dist/tokens/types.d.ts +34 -0
- package/docs/accordion.md +47 -0
- package/docs/animated-number.md +31 -0
- package/docs/app-bar.md +53 -0
- package/docs/avatar-group.md +35 -0
- package/docs/avatar.md +34 -0
- package/docs/badge.md +41 -0
- package/docs/bottom-sheet.md +65 -0
- package/docs/button.md +63 -0
- package/docs/calendar.md +26 -0
- package/docs/card.md +71 -0
- package/docs/carousel.md +43 -0
- package/docs/checkbox.md +37 -0
- package/docs/chip.md +48 -0
- package/docs/combobox.md +72 -0
- package/docs/composition.md +80 -0
- package/docs/confetti.md +30 -0
- package/docs/context-menu.md +42 -0
- package/docs/date-input.md +41 -0
- package/docs/dialog.md +106 -0
- package/docs/divider.md +31 -0
- package/docs/fab-menu.md +55 -0
- package/docs/fab.md +43 -0
- package/docs/field.md +59 -0
- package/docs/floating-toolbar.md +48 -0
- package/docs/forms.md +81 -0
- package/docs/hold-button.md +32 -0
- package/docs/icon-button.md +54 -0
- package/docs/icons.md +38 -0
- package/docs/input.md +50 -0
- package/docs/kbd.md +25 -0
- package/docs/list.md +65 -0
- package/docs/llms-index.md +82 -0
- package/docs/menu.md +88 -0
- package/docs/menubar.md +34 -0
- package/docs/morph.md +51 -0
- package/docs/navigation-bar.md +48 -0
- package/docs/navigation-drawer.md +72 -0
- package/docs/navigation-list.md +40 -0
- package/docs/navigation-rail.md +53 -0
- package/docs/pin-input.md +38 -0
- package/docs/popover.md +78 -0
- package/docs/preview-card.md +40 -0
- package/docs/progress.md +37 -0
- package/docs/radio-group.md +47 -0
- package/docs/search.md +77 -0
- package/docs/select.md +64 -0
- package/docs/setup.md +106 -0
- package/docs/skeleton.md +33 -0
- package/docs/slider.md +49 -0
- package/docs/snackbar.md +50 -0
- package/docs/split-button.md +44 -0
- package/docs/sticker.md +27 -0
- package/docs/switch.md +44 -0
- package/docs/table.md +66 -0
- package/docs/tabs.md +51 -0
- package/docs/textarea.md +23 -0
- package/docs/theming.md +182 -0
- package/docs/time-picker.md +38 -0
- package/docs/toggle-group.md +70 -0
- package/docs/toggle.md +49 -0
- package/docs/tooltip.md +42 -0
- package/docs/typography.md +41 -0
- package/package.json +25 -5
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { Theme } from './types';
|
|
2
|
+
/** The default light theme (purple). AnvilRoot uses it unless you pass `lightTheme`. */
|
|
2
3
|
export declare const baseLightTheme: Theme;
|
|
4
|
+
/** The default dark theme (purple). AnvilRoot uses it unless you pass `darkTheme`. */
|
|
3
5
|
export declare const baseDarkTheme: Theme;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Theme } from './types';
|
|
2
|
+
export type ThemePair = {
|
|
3
|
+
light: Theme;
|
|
4
|
+
dark: Theme;
|
|
5
|
+
};
|
|
6
|
+
export type CreateThemeOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* Seed for the tonal roles (selected states, tonal buttons), as
|
|
9
|
+
* hex. @default the primary color
|
|
10
|
+
*/
|
|
11
|
+
tonal?: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Builds a light and a dark theme from one hex color, e.g. `'#0B6E4F'`.
|
|
15
|
+
* Pass the result to `AnvilRoot` as `lightTheme={t.light} darkTheme={t.dark}`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createTheme(primary: string, options?: CreateThemeOptions): ThemePair;
|
|
18
|
+
/**
|
|
19
|
+
* Builds a light and a dark theme from the main colors of an image: an
|
|
20
|
+
* `<img>`, a `File`/`Blob`, or a URL (which must allow CORS). Browser only.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createThemeFromImage(image: ImageBitmapSource | string): Promise<ThemePair>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { Theme } from './types';
|
|
2
|
+
/** A black-and-white light theme. Pass as `<AnvilRoot lightTheme={monochromeLightTheme}>`. */
|
|
2
3
|
export declare const monochromeLightTheme: Theme;
|
|
4
|
+
/** A black-and-white dark theme. Pass as `<AnvilRoot darkTheme={monochromeDarkTheme}>`. */
|
|
3
5
|
export declare const monochromeDarkTheme: Theme;
|
package/dist/themes/types.d.ts
CHANGED
|
@@ -2,20 +2,25 @@ export type ThemeMode = 'light' | 'dark';
|
|
|
2
2
|
export type Theme = {
|
|
3
3
|
background: string;
|
|
4
4
|
onBackground: string;
|
|
5
|
+
/** Secondary text on `background`: descriptions, placeholders, hints. */
|
|
6
|
+
onBackgroundMuted: string;
|
|
5
7
|
container: string;
|
|
6
8
|
onContainer: string;
|
|
7
9
|
/**
|
|
8
10
|
* One step from the background toward `container`: navigation, menus,
|
|
9
|
-
* dialogs and sheets.
|
|
11
|
+
* dialogs and sheets.
|
|
10
12
|
*/
|
|
11
|
-
|
|
12
|
-
/** Text and icons on `
|
|
13
|
-
|
|
14
|
-
/** @deprecated Renamed to `
|
|
13
|
+
surface: string;
|
|
14
|
+
/** Text and icons on `surface`. */
|
|
15
|
+
onSurface: string;
|
|
16
|
+
/** @deprecated Renamed to `surface`. Still read if that's missing. */
|
|
15
17
|
surfaceVariant?: string;
|
|
16
|
-
/** @deprecated Renamed to `
|
|
18
|
+
/** @deprecated Renamed to `onSurface`. Still read if that's missing. */
|
|
17
19
|
onSurfaceVariant?: string;
|
|
20
|
+
/** Borders of inputs and outlined controls. */
|
|
18
21
|
outline: string;
|
|
22
|
+
/** Thin lines between content: dividers, table lines, tab underlines. */
|
|
23
|
+
divider: string;
|
|
19
24
|
primary: string;
|
|
20
25
|
onPrimary: string;
|
|
21
26
|
primaryContainer: string;
|
|
@@ -48,4 +53,8 @@ export type Theme = {
|
|
|
48
53
|
* `primary` mixed toward `background`, which is readable but approximate.
|
|
49
54
|
*/
|
|
50
55
|
inversePrimary?: string;
|
|
56
|
+
/** Color of elevation shadows, alpha included. Defaults to black at 30%. */
|
|
57
|
+
shadow?: string;
|
|
58
|
+
/** The dimmed backdrop behind dialogs and sheets. Defaults to black at 40%. */
|
|
59
|
+
scrim?: string;
|
|
51
60
|
};
|
package/dist/tokens/types.d.ts
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Everything about the look except colors. Each key becomes CSS variables
|
|
3
|
+
* on AnvilRoot, e.g. `radius.medium` is `--avl-radius-medium`.
|
|
4
|
+
*/
|
|
1
5
|
export type DesignTokens = {
|
|
6
|
+
/** The spacing unit in px. `--avl-spacing-x1` … `x20` are multiples of it. @default 4 */
|
|
2
7
|
spacing: number;
|
|
8
|
+
/** Font stacks for body text, titles and code. */
|
|
3
9
|
font: Font;
|
|
10
|
+
/** Font sizes for each text style. */
|
|
4
11
|
fontSize: FontSize;
|
|
12
|
+
/** Corner radii. */
|
|
5
13
|
radius: BorderRadius;
|
|
14
|
+
/** Width of borders on inputs and outlined controls. @default '1.5px' */
|
|
6
15
|
outlineSize: string;
|
|
16
|
+
/** Opacity of disabled controls. @default '0.5' */
|
|
17
|
+
disabledOpacity: string;
|
|
18
|
+
/** Font weights. */
|
|
19
|
+
fontWeight: FontWeight;
|
|
20
|
+
/** Elevation shadows. */
|
|
21
|
+
shadow: Shadow;
|
|
22
|
+
/** Easing curves. */
|
|
7
23
|
ease: Ease;
|
|
24
|
+
/** Animation durations. */
|
|
8
25
|
easeLength: EaseLength;
|
|
9
26
|
};
|
|
10
27
|
export type Ease = {
|
|
@@ -13,12 +30,29 @@ export type Ease = {
|
|
|
13
30
|
in: string;
|
|
14
31
|
/** No overshoot: things that slide across or in from the screen edge. */
|
|
15
32
|
smooth: string;
|
|
33
|
+
/**
|
|
34
|
+
* A spring that overshoots and wobbles before settling: playful moments
|
|
35
|
+
* like the slider's squish. Pair with a longer duration.
|
|
36
|
+
*/
|
|
37
|
+
bounce: string;
|
|
16
38
|
};
|
|
17
39
|
export type EaseLength = {
|
|
18
40
|
short: string;
|
|
19
41
|
normal: string;
|
|
20
42
|
slow: string;
|
|
21
43
|
};
|
|
44
|
+
export type FontWeight = {
|
|
45
|
+
regular: string;
|
|
46
|
+
medium: string;
|
|
47
|
+
semibold: string;
|
|
48
|
+
bold: string;
|
|
49
|
+
};
|
|
50
|
+
/** Elevation. Use `var(--avl-color-shadow)` so the color follows the theme. */
|
|
51
|
+
export type Shadow = {
|
|
52
|
+
small: string;
|
|
53
|
+
medium: string;
|
|
54
|
+
large: string;
|
|
55
|
+
};
|
|
22
56
|
export type Font = {
|
|
23
57
|
main: string;
|
|
24
58
|
title: string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Accordion
|
|
2
|
+
|
|
3
|
+
Expandable sections.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import {
|
|
7
|
+
Accordion,
|
|
8
|
+
AccordionItem,
|
|
9
|
+
AccordionTrigger,
|
|
10
|
+
AccordionPanel,
|
|
11
|
+
} from 'anvilui'
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
| Part | Renders | Props |
|
|
15
|
+
| --- | --- | --- |
|
|
16
|
+
| `Accordion` | `<div>` | `value` / `defaultValue` (**always an array** of open item values), `onValueChange(value[], details)`, `multiple` (default `false`) |
|
|
17
|
+
| `AccordionItem` | `<div>` | `value` (any; auto-generated if omitted), `disabled` |
|
|
18
|
+
| `AccordionTrigger` | `<button>` inside a heading | `as`: `'h2' … 'h6'`, default `'h3'` |
|
|
19
|
+
| `AccordionPanel` | `<div>` | `keepMounted` |
|
|
20
|
+
|
|
21
|
+
Without `defaultValue`, every item starts closed. There is no `type="single" \| "multiple"` or `collapsible`: use `multiple`. Items can always be closed.
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import {
|
|
25
|
+
Accordion,
|
|
26
|
+
AccordionItem,
|
|
27
|
+
AccordionPanel,
|
|
28
|
+
AccordionTrigger,
|
|
29
|
+
} from 'anvilui'
|
|
30
|
+
|
|
31
|
+
export function Faq() {
|
|
32
|
+
return (
|
|
33
|
+
<Accordion defaultValue={['shipping']}>
|
|
34
|
+
<AccordionItem value="shipping">
|
|
35
|
+
<AccordionTrigger>
|
|
36
|
+
How long does shipping take?
|
|
37
|
+
</AccordionTrigger>
|
|
38
|
+
<AccordionPanel>2–4 business days.</AccordionPanel>
|
|
39
|
+
</AccordionItem>
|
|
40
|
+
<AccordionItem value="returns">
|
|
41
|
+
<AccordionTrigger>Can I return an item?</AccordionTrigger>
|
|
42
|
+
<AccordionPanel>Yes, within 30 days.</AccordionPanel>
|
|
43
|
+
</AccordionItem>
|
|
44
|
+
</Accordion>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
```
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# AnimatedNumber
|
|
2
|
+
|
|
3
|
+
A number whose digits roll like an odometer when `value` changes. Renders a `<span>`.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { AnimatedNumber } from 'anvilui'
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Description |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| `value` | `number` | Required. |
|
|
12
|
+
| `format` | `Intl.NumberFormatOptions` | Currency, percent, compact, decimals. |
|
|
13
|
+
| `locales` | `Intl.LocalesArgument` | Default: the browser's. |
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { useState } from 'react'
|
|
17
|
+
import { AnimatedNumber, Button } from 'anvilui'
|
|
18
|
+
|
|
19
|
+
export function Example() {
|
|
20
|
+
const [count, setCount] = useState(1200)
|
|
21
|
+
return (
|
|
22
|
+
<>
|
|
23
|
+
<AnimatedNumber
|
|
24
|
+
value={count}
|
|
25
|
+
format={{ style: 'currency', currency: 'USD' }}
|
|
26
|
+
/>
|
|
27
|
+
<Button onClick={() => setCount(count + 99)}>Add</Button>
|
|
28
|
+
</>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
```
|
package/docs/app-bar.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# AppBar
|
|
2
|
+
|
|
3
|
+
The bar across the top of a screen: title, navigation button, actions. Renders a `<header>`. The title is the **`label` prop**, not children.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { AppBar } from 'anvilui'
|
|
7
|
+
import type { AppBarProps } from 'anvilui'
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
| Prop | Type | Default | Description |
|
|
11
|
+
| --- | --- | --- | --- |
|
|
12
|
+
| `label` | `ReactNode` | required | The title. |
|
|
13
|
+
| `labelAs` | `'p' \| 'span' \| 'div' \| 'h1' … 'h6'` | `'div'` | Tag for the title; `'h1'` when it's the page heading. |
|
|
14
|
+
| `start` | `ReactNode` | | Before the title (menu or back `IconButton`). |
|
|
15
|
+
| `end` | `ReactNode` | | After the title (action `IconButton`s, `Avatar`). |
|
|
16
|
+
| `size` | `'normal' \| 'big'` | `'normal'` | `big` puts a larger title on its own row. |
|
|
17
|
+
| `centered` | `boolean` | `false` | Center the title (normal size only). |
|
|
18
|
+
| `color` | `ComponentColor` | `'container'` | Matches navigation surfaces. |
|
|
19
|
+
| `fillType` | `'filled' \| 'outlined' \| 'text'` | `'filled'` | `text` makes it the page color. |
|
|
20
|
+
|
|
21
|
+
Minimum height: 64px (`size="normal"`), 152px (`size="big"`). Not sticky by default: add `style={{ position: 'sticky', top: 0, zIndex: 1 }}`.
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { AppBar, Avatar, IconButton } from 'anvilui'
|
|
25
|
+
|
|
26
|
+
export function Example() {
|
|
27
|
+
return (
|
|
28
|
+
<AppBar
|
|
29
|
+
label="Inbox"
|
|
30
|
+
labelAs="h1"
|
|
31
|
+
start={
|
|
32
|
+
<IconButton
|
|
33
|
+
icon="menu"
|
|
34
|
+
aria-label="Open navigation"
|
|
35
|
+
fillType="text"
|
|
36
|
+
color="container"
|
|
37
|
+
/>
|
|
38
|
+
}
|
|
39
|
+
end={
|
|
40
|
+
<>
|
|
41
|
+
<IconButton
|
|
42
|
+
icon="search"
|
|
43
|
+
aria-label="Search"
|
|
44
|
+
fillType="text"
|
|
45
|
+
color="container"
|
|
46
|
+
/>
|
|
47
|
+
<Avatar name="Ada Lovelace" size="small" />
|
|
48
|
+
</>
|
|
49
|
+
}
|
|
50
|
+
/>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# AvatarGroup
|
|
2
|
+
|
|
3
|
+
A row of overlapping `Avatar`s that fans out on hover. Renders a `<div role="group">` and takes `<div>` props; give it an `aria-label`. Set `size` on the group, not on each Avatar.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { AvatarGroup, Avatar } from 'anvilui'
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Default | Description |
|
|
10
|
+
| --- | --- | --- | --- |
|
|
11
|
+
| `max` | `number` | no limit | Past it, the last spot becomes "+N". |
|
|
12
|
+
| `size` | `'small' \| 'normal' \| 'big'` | `'normal'` | Applies to every avatar inside. |
|
|
13
|
+
| `fan` | `boolean` | `true` | Spread on hover/focus. |
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Avatar, AvatarGroup } from 'anvilui'
|
|
17
|
+
|
|
18
|
+
const people = [
|
|
19
|
+
'Ada Lovelace',
|
|
20
|
+
'Alan Turing',
|
|
21
|
+
'Grace Hopper',
|
|
22
|
+
'Linus Torvalds',
|
|
23
|
+
'Margaret Hamilton',
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
export function Example() {
|
|
27
|
+
return (
|
|
28
|
+
<AvatarGroup max={4} aria-label="Project members">
|
|
29
|
+
{people.map((name) => (
|
|
30
|
+
<Avatar key={name} name={name} />
|
|
31
|
+
))}
|
|
32
|
+
</AvatarGroup>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
```
|
package/docs/avatar.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Avatar
|
|
2
|
+
|
|
3
|
+
A picture, initials or icon for a person or thing.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Avatar } from 'anvilui'
|
|
7
|
+
import type { AvatarProps } from 'anvilui'
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
| Prop | Type | Default | Description |
|
|
11
|
+
| --- | --- | --- | --- |
|
|
12
|
+
| `src` | `string` | | Image URL; the fallback shows while it loads or if it fails. |
|
|
13
|
+
| `name` | `string` | | Read by screen readers; its initials are the fallback ("Ada Lovelace" → "AL"). |
|
|
14
|
+
| `icon` | `MaterialSymbol` | `'person'` | Fallback without a `name`. |
|
|
15
|
+
| `size` | `'small' \| 'normal' \| 'big'` | `'normal'` | 32, 40 or 56px. |
|
|
16
|
+
| `color` | `ComponentColor` | `'primary'` | Fallback background. |
|
|
17
|
+
| `fillType` | `'filled' \| 'outlined' \| 'text'` | `'filled'` | |
|
|
18
|
+
| `children` | `ReactNode` | | Replaces the fallback. |
|
|
19
|
+
|
|
20
|
+
No `alt` prop: use `name`. Leave `name` out when the name is shown next to it.
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import { Avatar } from 'anvilui'
|
|
24
|
+
|
|
25
|
+
export function Example() {
|
|
26
|
+
return (
|
|
27
|
+
<div style={{ display: 'flex', gap: 8 }}>
|
|
28
|
+
<Avatar name="Ada Lovelace" src="https://example.com/ada.jpg" />
|
|
29
|
+
<Avatar name="Alan Turing" color="tonal" />
|
|
30
|
+
<Avatar icon="group" size="big" color="container" />
|
|
31
|
+
</div>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
```
|
package/docs/badge.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Badge
|
|
2
|
+
|
|
3
|
+
A dot or count on the corner of what it wraps, or inline on its own. Error-colored by default. Hidden from screen readers.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Badge } from 'anvilui'
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Default | Description |
|
|
10
|
+
| --- | --- | --- | --- |
|
|
11
|
+
| `count` | `number` | | Omit for a dot; `0` hides it. |
|
|
12
|
+
| `max` | `number` | `999` | Above shows "999+". |
|
|
13
|
+
| `color` | `ComponentColor` | `'error'` | |
|
|
14
|
+
| `children` | `ReactNode` | | What it sits on. |
|
|
15
|
+
|
|
16
|
+
No `content` / `badgeContent` / `variant`.
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
import { Badge, Icon, IconButton } from 'anvilui'
|
|
20
|
+
|
|
21
|
+
export function Example() {
|
|
22
|
+
return (
|
|
23
|
+
<>
|
|
24
|
+
<Badge count={3}>
|
|
25
|
+
<IconButton
|
|
26
|
+
icon="mail"
|
|
27
|
+
aria-label="Inbox, 3 unread"
|
|
28
|
+
fillType="text"
|
|
29
|
+
color="container"
|
|
30
|
+
/>
|
|
31
|
+
</Badge>
|
|
32
|
+
<Badge>
|
|
33
|
+
<Icon name="notifications" />
|
|
34
|
+
</Badge>
|
|
35
|
+
<Badge count={12} color="primary" />
|
|
36
|
+
</>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Put the count in the wrapped element's `aria-label` too. On a non-interactive icon, label the icon: `<Badge count={4}><Icon name="chat_bubble" aria-label="4 comments" /></Badge>`.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# BottomSheet
|
|
2
|
+
|
|
3
|
+
A panel that slides up from the bottom; swipe down or tap outside to close.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import {
|
|
7
|
+
BottomSheet,
|
|
8
|
+
BottomSheetTrigger,
|
|
9
|
+
BottomSheetPopup,
|
|
10
|
+
BottomSheetTitle,
|
|
11
|
+
BottomSheetDescription,
|
|
12
|
+
BottomSheetClose,
|
|
13
|
+
} from 'anvilui'
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
| Part | Renders | Notes |
|
|
17
|
+
| --- | --- | --- |
|
|
18
|
+
| `BottomSheet` | nothing (state) | `open` / `defaultOpen` / `onOpenChange`, `snapPoints` (e.g. `[0.5, 1]`), plus Base UI Drawer.Root props |
|
|
19
|
+
| `BottomSheetTrigger` | bare `<button>` | `render={<Button />}` |
|
|
20
|
+
| `BottomSheetPopup` | portal + backdrop + sheet + drag handle | Already padded; children scroll. |
|
|
21
|
+
| `BottomSheetTitle` | `<h2>` | Names the sheet. |
|
|
22
|
+
| `BottomSheetDescription` | `<p>` | |
|
|
23
|
+
| `BottomSheetClose` | bare `<button>` | |
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import {
|
|
27
|
+
BottomSheet,
|
|
28
|
+
BottomSheetPopup,
|
|
29
|
+
BottomSheetTitle,
|
|
30
|
+
BottomSheetTrigger,
|
|
31
|
+
Button,
|
|
32
|
+
List,
|
|
33
|
+
ListItem,
|
|
34
|
+
Icon,
|
|
35
|
+
} from 'anvilui'
|
|
36
|
+
|
|
37
|
+
export function ShareSheet() {
|
|
38
|
+
return (
|
|
39
|
+
<BottomSheet>
|
|
40
|
+
<BottomSheetTrigger render={<Button startIcon="share" />}>
|
|
41
|
+
Share
|
|
42
|
+
</BottomSheetTrigger>
|
|
43
|
+
<BottomSheetPopup>
|
|
44
|
+
<BottomSheetTitle>Share</BottomSheetTitle>
|
|
45
|
+
<List>
|
|
46
|
+
<ListItem
|
|
47
|
+
label="Copy link"
|
|
48
|
+
start={<Icon name="link" />}
|
|
49
|
+
render={<button type="button" />}
|
|
50
|
+
/>
|
|
51
|
+
<ListItem
|
|
52
|
+
label="Email"
|
|
53
|
+
start={<Icon name="mail" />}
|
|
54
|
+
render={<button type="button" />}
|
|
55
|
+
/>
|
|
56
|
+
</List>
|
|
57
|
+
</BottomSheetPopup>
|
|
58
|
+
</BottomSheet>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
There is no actions part: for buttons at the bottom use your own row, e.g. `<div style={{ display: 'flex', justifyContent: 'flex-end', gap: 8 }}><BottomSheetClose render={<Button fillType="text" />}>Cancel</BottomSheetClose><Button type="submit">Add</Button></div>`. To close it after a form submit, control it with `open` / `onOpenChange`.
|
|
64
|
+
|
|
65
|
+
Base UI docs: `node_modules/@base-ui/react/docs/react/components/drawer.md`.
|
package/docs/button.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Button
|
|
2
|
+
|
|
3
|
+
A button with a text label and optional icons. Renders a `<button type="button">`.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Button } from 'anvilui'
|
|
7
|
+
import type { ButtonProps } from 'anvilui'
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Props
|
|
11
|
+
|
|
12
|
+
| Prop | Type | Default | Description |
|
|
13
|
+
| --- | --- | --- | --- |
|
|
14
|
+
| `fillType` | `'filled' \| 'outlined' \| 'text'` | `'filled'` | The style (other libraries call this `variant`). |
|
|
15
|
+
| `color` | `ComponentColor` | `'primary'` | `primary`, `tonal`, `success`, `warning`, `error`, `container`, `surface`. |
|
|
16
|
+
| `size` | `'small' \| 'normal' \| 'big'` | `'normal'` | 32, 40 or 48px tall. |
|
|
17
|
+
| `startIcon` | `MaterialSymbol` | | Icon name before the label, e.g. `'add'`. |
|
|
18
|
+
| `endIcon` | `MaterialSymbol` | | Icon name after the label. |
|
|
19
|
+
| `loading` | `boolean` | `false` | Spinner in place of `startIcon`; ignores clicks; keeps focus. |
|
|
20
|
+
| `disabled` | `boolean` | `false` | |
|
|
21
|
+
| `type` | `'button' \| 'submit' \| 'reset'` | `'button'` | Pass `'submit'` in forms. |
|
|
22
|
+
| `render` | `ReactElement` | | Render as another element, e.g. `<a href>` (+ `nativeButton={false}`). |
|
|
23
|
+
|
|
24
|
+
Also takes Base UI Button props (`focusableWhenDisabled`, `nativeButton`) and all `<button>` attributes. Base UI docs: `node_modules/@base-ui/react/docs/react/components/button.md`.
|
|
25
|
+
|
|
26
|
+
## Example
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import { useState } from 'react'
|
|
30
|
+
import { Button } from 'anvilui'
|
|
31
|
+
|
|
32
|
+
export function Example() {
|
|
33
|
+
const [saving, setSaving] = useState(false)
|
|
34
|
+
return (
|
|
35
|
+
<div style={{ display: 'flex', gap: 8 }}>
|
|
36
|
+
<Button startIcon="add">New</Button>
|
|
37
|
+
<Button fillType="outlined" color="container">
|
|
38
|
+
Cancel
|
|
39
|
+
</Button>
|
|
40
|
+
<Button fillType="text">Learn more</Button>
|
|
41
|
+
<Button color="error" startIcon="delete">
|
|
42
|
+
Delete
|
|
43
|
+
</Button>
|
|
44
|
+
<Button loading={saving} onClick={() => setSaving(true)}>
|
|
45
|
+
{saving ? 'Saving' : 'Save'}
|
|
46
|
+
</Button>
|
|
47
|
+
<Button
|
|
48
|
+
render={<a href="/docs" />}
|
|
49
|
+
nativeButton={false}
|
|
50
|
+
endIcon="arrow_forward"
|
|
51
|
+
>
|
|
52
|
+
Docs
|
|
53
|
+
</Button>
|
|
54
|
+
</div>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Notes
|
|
60
|
+
|
|
61
|
+
- Mapping from other libraries: `variant="outline"` → `fillType="outlined"`, `variant="ghost" | "link"` → `fillType="text"`, `variant="secondary"` → `color="container"` or `color="tonal"`, `variant="destructive"` → `color="error"`.
|
|
62
|
+
- Icon-only? Use [IconButton](icon-button.md). Grouped buttons: [SplitButton](split-button.md). Hold-to-confirm: [HoldButton](hold-button.md). On/off: [Toggle](toggle.md).
|
|
63
|
+
- No `fullWidth` prop: use `style={{ width: '100%' }}`.
|
package/docs/calendar.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Calendar
|
|
2
|
+
|
|
3
|
+
A month grid to pick a date. **Values are `"YYYY-MM-DD"` strings.** Locale-aware (first weekday, names).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Calendar } from 'anvilui'
|
|
7
|
+
import type { CalendarProps } from 'anvilui'
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
| Prop | Type | Default | Description |
|
|
11
|
+
| --- | --- | --- | --- |
|
|
12
|
+
| `value` / `defaultValue` | `string \| null` | `null` | |
|
|
13
|
+
| `onValueChange` | `(value: string) => void` | | |
|
|
14
|
+
| other | `<div>` props | | |
|
|
15
|
+
|
|
16
|
+
No range selection, `min` / `max` or disabled dates. For a field with a popup calendar, use [DateInput](date-input.md).
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
import { useState } from 'react'
|
|
20
|
+
import { Calendar } from 'anvilui'
|
|
21
|
+
|
|
22
|
+
export function Example() {
|
|
23
|
+
const [date, setDate] = useState<string | null>(null)
|
|
24
|
+
return <Calendar value={date} onValueChange={setDate} />
|
|
25
|
+
}
|
|
26
|
+
```
|
package/docs/card.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Card
|
|
2
|
+
|
|
3
|
+
A rounded surface that groups content. Neutral `container` color by default.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Card, CardTitle, CardContent, CardActions } from 'anvilui'
|
|
7
|
+
import type {
|
|
8
|
+
CardProps,
|
|
9
|
+
CardTitleProps,
|
|
10
|
+
CardContentProps,
|
|
11
|
+
CardActionsProps,
|
|
12
|
+
} from 'anvilui'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Card props
|
|
16
|
+
|
|
17
|
+
| Prop | Type | Default | Description |
|
|
18
|
+
| --- | --- | --- | --- |
|
|
19
|
+
| `color` | `ComponentColor` | `'container'` | |
|
|
20
|
+
| `fillType` | `'filled' \| 'outlined' \| 'text'` | `'filled'` | |
|
|
21
|
+
| `clickable` | `boolean` | `false` | The whole card becomes one button (Base UI Button props: `onClick`, `disabled`, `render`). Buttons and links inside still work on their own. |
|
|
22
|
+
|
|
23
|
+
A plain card takes `<div>` props.
|
|
24
|
+
|
|
25
|
+
## Parts
|
|
26
|
+
|
|
27
|
+
| Part | Renders | Notes |
|
|
28
|
+
| --- | --- | --- |
|
|
29
|
+
| `CardTitle` | `<div>` styled as h6 | Pass `as="h2"` (etc.) for a real heading; `type` changes the look. [Typography](typography.md) props. |
|
|
30
|
+
| `CardContent` | `<div>` | Padded body. |
|
|
31
|
+
| `CardActions` | `<div>` | Button row aligned to the end. |
|
|
32
|
+
|
|
33
|
+
There is **no** `CardHeader`, `CardFooter`, `CardDescription` or `CardMedia`. Put an `<img>` directly inside the card.
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import { Button, Card, CardActions, CardContent, CardTitle } from 'anvilui'
|
|
37
|
+
|
|
38
|
+
export function Example() {
|
|
39
|
+
return (
|
|
40
|
+
<div
|
|
41
|
+
style={{
|
|
42
|
+
display: 'grid',
|
|
43
|
+
gap: 16,
|
|
44
|
+
gridTemplateColumns: 'repeat(auto-fill, minmax(260px, 1fr))',
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
<Card>
|
|
48
|
+
<CardTitle as="h2">Storage</CardTitle>
|
|
49
|
+
<CardContent>You've used 80% of your space.</CardContent>
|
|
50
|
+
<CardActions>
|
|
51
|
+
<Button fillType="text">Dismiss</Button>
|
|
52
|
+
<Button>Upgrade</Button>
|
|
53
|
+
</CardActions>
|
|
54
|
+
</Card>
|
|
55
|
+
|
|
56
|
+
<Card
|
|
57
|
+
clickable
|
|
58
|
+
onClick={() => console.log('open')}
|
|
59
|
+
fillType="outlined"
|
|
60
|
+
>
|
|
61
|
+
<CardTitle>Open project</CardTitle>
|
|
62
|
+
<CardContent>Last edited today</CardContent>
|
|
63
|
+
</Card>
|
|
64
|
+
|
|
65
|
+
<Card clickable render={<a href="/billing" />}>
|
|
66
|
+
<CardTitle>Billing</CardTitle>
|
|
67
|
+
</Card>
|
|
68
|
+
</div>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
```
|
package/docs/carousel.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Carousel
|
|
2
|
+
|
|
3
|
+
A horizontally scrolling row of items, draggable with a mouse. `aria-label` required.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Carousel, CarouselItem } from 'anvilui'
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
| Part | Renders | Props |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| `Carousel` | `<div role="region">` | `aria-label` (required), `<div>` props |
|
|
12
|
+
| `CarouselItem` | `<div>` | `<div>` props. 240px wide by default; set `style={{ width }}`. |
|
|
13
|
+
|
|
14
|
+
No arrows, dots, autoplay or `index` state.
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { Carousel, CarouselItem } from 'anvilui'
|
|
18
|
+
|
|
19
|
+
const albums = [
|
|
20
|
+
{ id: 1, title: 'Blue', cover: '/blue.jpg' },
|
|
21
|
+
{ id: 2, title: 'Red', cover: '/red.jpg' },
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
export function Example() {
|
|
25
|
+
return (
|
|
26
|
+
<Carousel aria-label="Featured albums">
|
|
27
|
+
{albums.map((a) => (
|
|
28
|
+
<CarouselItem key={a.id}>
|
|
29
|
+
<img
|
|
30
|
+
src={a.cover}
|
|
31
|
+
alt={a.title}
|
|
32
|
+
style={{
|
|
33
|
+
width: '100%',
|
|
34
|
+
height: 180,
|
|
35
|
+
objectFit: 'cover',
|
|
36
|
+
}}
|
|
37
|
+
/>
|
|
38
|
+
</CarouselItem>
|
|
39
|
+
))}
|
|
40
|
+
</Carousel>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
```
|