@ahrowe/ui 0.4.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/common/card/card.types.mjs.map +1 -1
- package/dist/esm/common/confirmModal/confirmModal.mjs +1 -1
- package/dist/esm/common/confirmModal/confirmModal.mjs.map +1 -1
- package/dist/esm/common/divider/divider.mjs +2 -0
- package/dist/esm/common/divider/divider.mjs.map +1 -0
- package/dist/esm/common/divider/divider.module.mjs +2 -0
- package/dist/esm/common/divider/divider.module.mjs.map +1 -0
- package/dist/esm/common/divider/divider.types.mjs +2 -0
- package/dist/esm/common/divider/divider.types.mjs.map +1 -0
- package/dist/esm/common/dropdown/dropdown.mjs +1 -1
- package/dist/esm/common/dropdown/dropdown.mjs.map +1 -1
- package/dist/esm/common/dropdown/dropdown.module.mjs.map +1 -1
- package/dist/esm/common/input/input.mjs +1 -1
- package/dist/esm/common/input/input.mjs.map +1 -1
- package/dist/esm/common/input/input.module.mjs +1 -1
- package/dist/esm/common/input/input.module.mjs.map +1 -1
- package/dist/esm/common/sectionHeader/sectionHeader.mjs +2 -0
- package/dist/esm/common/sectionHeader/sectionHeader.mjs.map +1 -0
- package/dist/esm/common/sectionHeader/sectionHeader.module.mjs +2 -0
- package/dist/esm/common/sectionHeader/sectionHeader.module.mjs.map +1 -0
- package/dist/esm/common/sectionHeader/sectionHeader.types.mjs +2 -0
- package/dist/esm/common/sectionHeader/sectionHeader.types.mjs.map +1 -0
- package/dist/esm/common/themeProvider/defaultTheme.mjs +1 -1
- package/dist/esm/common/themeProvider/defaultTheme.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/package/common/card/card.types.d.ts +2 -6
- package/dist/types/package/common/configProvider/configProvider.types.d.ts +6 -0
- package/dist/types/package/common/confirmModal/confirmModal.d.ts +1 -1
- package/dist/types/package/common/confirmModal/confirmModal.types.d.ts +3 -0
- package/dist/types/package/common/divider/divider.d.ts +4 -0
- package/dist/types/package/common/divider/divider.types.d.ts +16 -0
- package/dist/types/package/common/divider/index.d.ts +2 -0
- package/dist/types/package/common/sectionHeader/index.d.ts +2 -0
- package/dist/types/package/common/sectionHeader/sectionHeader.d.ts +4 -0
- package/dist/types/package/common/sectionHeader/sectionHeader.types.d.ts +27 -0
- package/dist/types/package/common/themeProvider/theme.types.d.ts +1 -0
- package/dist/types/package/common/types/actions.types.d.ts +7 -0
- package/dist/types/package/index.d.ts +4 -0
- package/docs/CLAUDE.md +2 -0
- package/docs/ConfigProvider.md +2 -1
- package/docs/ConfirmModal.md +25 -0
- package/docs/Divider.md +33 -0
- package/docs/SectionHeader.md +90 -0
- package/package.json +3 -1
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# SectionHeader
|
|
2
|
+
|
|
3
|
+
**When to use:** A reusable heading block for the top of a page, panel, card, or any section — a title with an optional subtitle, a leading icon or thumbnail, and a trailing actions area. Use it wherever you'd otherwise hand-roll a `<h2>` + subtitle + buttons row. Inside a `Card`, the card-scoped `CardHeader` remains available; `SectionHeader` is the standalone, fully slot-customisable version.
|
|
4
|
+
|
|
5
|
+
**Import:** `import { SectionHeader, SectionHeaderSize } from '@ahrowe/ui'`
|
|
6
|
+
**Types:** `import type { SectionHeaderProps, SectionHeaderAction } from '@ahrowe/ui'`
|
|
7
|
+
|
|
8
|
+
**Style variants:** `SectionHeaderSize.Small` | `SectionHeaderSize.Medium` (default) | `SectionHeaderSize.Large`
|
|
9
|
+
|
|
10
|
+
```tsx
|
|
11
|
+
import { SectionHeader, SectionHeaderSize } from '@ahrowe/ui';
|
|
12
|
+
import { faFolder, faPen, faTrash } from '@fortawesome/free-solid-svg-icons';
|
|
13
|
+
|
|
14
|
+
// Title + subtitle
|
|
15
|
+
<SectionHeader title="Account settings" subtitle="Manage your profile and preferences" />
|
|
16
|
+
|
|
17
|
+
// Leading icon
|
|
18
|
+
<SectionHeader icon={faFolder} title="Documents" subtitle="12 files" />
|
|
19
|
+
|
|
20
|
+
// Leading thumbnail (URL → background image; any other ReactNode → rendered inside)
|
|
21
|
+
<SectionHeader thumbnail="https://example.com/avatar.jpg" title="Jane Doe" subtitle="Designer" />
|
|
22
|
+
|
|
23
|
+
// Trailing actions — array renders ActionIcons, or pass any ReactNode
|
|
24
|
+
<SectionHeader
|
|
25
|
+
title="Integrations"
|
|
26
|
+
actions={[
|
|
27
|
+
{ title: 'Edit', icon: faPen, onClick: handleEdit },
|
|
28
|
+
{ title: 'Delete', icon: faTrash, onClick: handleDelete },
|
|
29
|
+
]}
|
|
30
|
+
/>
|
|
31
|
+
<SectionHeader title="Reports" actions={<Button>Export</Button>} />
|
|
32
|
+
|
|
33
|
+
// Larger scale, a bottom divider, and a semantic heading level for a11y
|
|
34
|
+
<SectionHeader
|
|
35
|
+
size={SectionHeaderSize.Large}
|
|
36
|
+
level={1}
|
|
37
|
+
divider
|
|
38
|
+
title="Dashboard"
|
|
39
|
+
subtitle="Your workspace at a glance"
|
|
40
|
+
/>
|
|
41
|
+
|
|
42
|
+
// left / center — the title stays fixed to the left; everything else (left,
|
|
43
|
+
// center, actions) lives in a separate trailing block laid out with
|
|
44
|
+
// space-between, so `center` is centered within that block, not the whole header
|
|
45
|
+
<SectionHeader
|
|
46
|
+
title="Team members"
|
|
47
|
+
left={<Chip text="12 active" />}
|
|
48
|
+
center={<SearchInput value={query} onChange={setQuery} />}
|
|
49
|
+
actions={[{ title: 'Invite', icon: faPlus, onClick: handleInvite }]}
|
|
50
|
+
/>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Enums:**
|
|
54
|
+
|
|
55
|
+
- `SectionHeaderSize`: `Small` | `Medium` (default) | `Large`
|
|
56
|
+
|
|
57
|
+
**Key props:**
|
|
58
|
+
|
|
59
|
+
| Prop | Type | Description |
|
|
60
|
+
|------|------|-------------|
|
|
61
|
+
| `title` | `ReactNode` | Main heading |
|
|
62
|
+
| `subtitle` | `ReactNode` | Secondary text below the title |
|
|
63
|
+
| `icon` | `IconDefinition` | FontAwesome icon shown on the left; ignored when `thumbnail` is set |
|
|
64
|
+
| `thumbnail` | `string \| ReactNode` | URL → background image; any other ReactNode → rendered inside the leading circle |
|
|
65
|
+
| `left` | `ReactNode` | Leftmost content of the trailing block (title stays fixed to the left of it) |
|
|
66
|
+
| `center` | `ReactNode` | Center content of the trailing block, e.g. a search box or tabs |
|
|
67
|
+
| `actions` | `SectionHeaderAction[] \| ReactNode` | Rightmost content of the trailing block: array → `ActionIcon`s; ReactNode → rendered as-is |
|
|
68
|
+
| `level` | `1 \| 2 \| 3 \| 4 \| 5 \| 6` | Semantic heading level for the title element (default `2`) |
|
|
69
|
+
| `size` | `SectionHeaderSize` | Visual scale (default `Medium`) |
|
|
70
|
+
| `divider` | `boolean` | Render a `Divider` below the header (default `false`) |
|
|
71
|
+
|
|
72
|
+
**SectionHeaderAction:**
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
interface SectionHeaderAction {
|
|
76
|
+
title?: string;
|
|
77
|
+
icon: IconDefinition;
|
|
78
|
+
onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**Global defaults:** adopts `ConfigProvider` — set defaults app-wide via `defaultProps={{ SectionHeader: { size: SectionHeaderSize.Large } }}`. See [ConfigProvider.md](ConfigProvider.md).
|
|
83
|
+
|
|
84
|
+
**Theming:** title size/weight per `size` variant come from the theme, with local fallbacks — `SectionHeaderSize.Large` uses `--header-font-size` (falls back `24px`), `Medium` uses `--header-medium-font-size` (falls back `18px`), `Small` uses `--header-small-font-size` (falls back `16px`); all three use `--header-font-weight` for the title's font weight (falls back `600`). The leading icon/thumbnail is sized at `2.2×` the title size, so it scales automatically with the theme; the subtitle size is fixed per `size` variant (not derived), since it doesn't track the title proportionally at the `Large` size. See [ThemeProvider.md](ThemeProvider.md).
|
|
85
|
+
|
|
86
|
+
**Layout:** the title (with its leading icon/thumbnail) is fixed to the left and only takes the width its content needs. Everything after it — `left`, `center`, `actions` — lives in a separate `trailing` flex block laid out with `space-between`, so `center` is centered within that block (not the whole header) regardless of how wide `left`/`actions` are.
|
|
87
|
+
|
|
88
|
+
**Responsive:** the header wraps — if `trailing` (`left`/`center`/`actions`) doesn't fit next to the title, it drops to its own row; if `trailing` itself doesn't fit as one row, its own children wrap too. Below `640px` viewport width, `center` additionally takes a full-width row of its own, so a wide `center` element (e.g. a `SearchInput`) isn't squeezed alongside `left`/`actions` on small screens.
|
|
89
|
+
|
|
90
|
+
**Slots:** `root` `leading` `titles` `title` `subtitle` `trailing` `left` `center` `actions`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ahrowe/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"preview": "vite preview",
|
|
56
56
|
"gen-barrel": "tsx scripts/gen-barrel.ts",
|
|
57
57
|
"gc": "bash src/scripts/generateComponent.sh $INIT_CWD process.argv",
|
|
58
|
+
"changeset": "changeset",
|
|
58
59
|
"lint": "eslint .",
|
|
59
60
|
"lint:fix": "eslint . --fix",
|
|
60
61
|
"format": "prettier --write .",
|
|
@@ -86,6 +87,7 @@
|
|
|
86
87
|
"zod": "^4.4.3"
|
|
87
88
|
},
|
|
88
89
|
"devDependencies": {
|
|
90
|
+
"@changesets/cli": "^2.31.0",
|
|
89
91
|
"@eslint/js": "^9.39.4",
|
|
90
92
|
"@fortawesome/fontawesome-svg-core": "^7.2.0",
|
|
91
93
|
"@fortawesome/free-solid-svg-icons": "^7.2.0",
|