@w5-ui/react 0.2.1 → 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.
Files changed (40) hide show
  1. package/README.md +118 -4
  2. package/package.json +2 -2
  3. package/src/components/AppLayout.tsx +38 -0
  4. package/src/components/AppShell.tsx +41 -49
  5. package/src/components/Body.tsx +32 -0
  6. package/src/components/BodyLg.tsx +29 -0
  7. package/src/components/Caption.tsx +29 -0
  8. package/src/components/Card.tsx +13 -0
  9. package/src/components/CardMore.tsx +22 -0
  10. package/src/components/Code.tsx +27 -0
  11. package/src/components/ContextMenu.tsx +4 -0
  12. package/src/components/Delta.tsx +29 -0
  13. package/src/components/Display1.tsx +33 -0
  14. package/src/components/Display2.tsx +32 -0
  15. package/src/components/Eyebrow.tsx +28 -0
  16. package/src/components/FieldStack.tsx +19 -0
  17. package/src/components/FormActions.tsx +20 -0
  18. package/src/components/FormRow.tsx +19 -0
  19. package/src/components/Grid.tsx +21 -0
  20. package/src/components/H1.tsx +32 -0
  21. package/src/components/H2.tsx +32 -0
  22. package/src/components/H3.tsx +32 -0
  23. package/src/components/H4.tsx +31 -0
  24. package/src/components/Label.tsx +30 -0
  25. package/src/components/Mac.tsx +25 -0
  26. package/src/components/Modal.tsx +16 -2
  27. package/src/components/Mono.tsx +31 -0
  28. package/src/components/Muted.tsx +27 -0
  29. package/src/components/NameCell.tsx +45 -0
  30. package/src/components/NotifDot.tsx +24 -0
  31. package/src/components/PageHeader.tsx +20 -0
  32. package/src/components/SrOnly.tsx +25 -0
  33. package/src/components/StatNumber.tsx +25 -0
  34. package/src/components/StatusRing.tsx +38 -0
  35. package/src/components/Submeta.tsx +23 -0
  36. package/src/components/TablePager.tsx +27 -0
  37. package/src/components/TableShell.tsx +23 -0
  38. package/src/components/TopbarActions.tsx +70 -0
  39. package/src/components/Unit.tsx +25 -0
  40. package/src/index.ts +33 -0
@@ -0,0 +1,70 @@
1
+ import { SearchIcon, UpdatesIcon, BellIcon, HelpIcon } from '../icons.js'
2
+ import { Avatar } from './Avatar.js'
3
+ import { IconButton } from './Button.js'
4
+ import { NotifDot } from './NotifDot.js'
5
+
6
+ export interface TopbarActionsProps {
7
+ /** Avatar initials shown in the trailing account chip. */
8
+ initials?: string
9
+ /** Unread count surfaced via the bell `aria-label` and the red `NotifDot`
10
+ * overlay. `0` hides the dot. */
11
+ notificationCount?: number
12
+ }
13
+
14
+ /**
15
+ * The canonical right-side action group inside `<Topbar>`: Search, Updates,
16
+ * Notifications (with `<NotifDot>` overlay when unread), Help, and the account
17
+ * `<Avatar>`. Renders the same five controls in the same order as the default
18
+ * block inside `<Topbar>` itself.
19
+ *
20
+ * Pass `<Topbar actions={...}>` replaces the default block in full — userland
21
+ * that wants to inject a theme toggle, status pill, or environment switch
22
+ * usually wants those _alongside_ the canonical controls, not instead of them.
23
+ * `<TopbarActions>` is that re-entry point: compose your custom controls plus
24
+ * `<TopbarActions />` and userland keeps the search / bell / avatar rhythm the
25
+ * reference dashboards ship without copying classes or icons.
26
+ *
27
+ * ```tsx
28
+ * <Topbar
29
+ * siteName="HQ"
30
+ * activeApp="system"
31
+ * onAppChange={setApp}
32
+ * actions={
33
+ * <>
34
+ * <ThemeToggle />
35
+ * <TopbarActions notificationCount={3} initials="WS" />
36
+ * </>
37
+ * }
38
+ * />
39
+ * ```
40
+ *
41
+ * The `<NotifDot>` ring colour, the `IconButton` 28 px square, and the
42
+ * `Avatar` `size="sm"` chip all come from `@w5-ui/tokens/dashboard.css` — drop
43
+ * the primitive in and the topbar reads identically to the Dashboard story.
44
+ */
45
+ export function TopbarActions({ initials = 'MS', notificationCount = 1 }: TopbarActionsProps) {
46
+ return (
47
+ <>
48
+ <IconButton aria-label="Search" title="Search">
49
+ <SearchIcon />
50
+ </IconButton>
51
+ <IconButton aria-label="Updates" title="Updates">
52
+ <UpdatesIcon />
53
+ </IconButton>
54
+ <IconButton
55
+ aria-label={
56
+ notificationCount > 0 ? `Notifications, ${notificationCount} new` : 'Notifications'
57
+ }
58
+ title="Notifications"
59
+ style={{ position: 'relative' }}
60
+ >
61
+ <BellIcon />
62
+ {notificationCount > 0 && <NotifDot />}
63
+ </IconButton>
64
+ <IconButton aria-label="Help" title="Help">
65
+ <HelpIcon />
66
+ </IconButton>
67
+ <Avatar initials={initials} size="sm" alt={`Account, ${initials}`} />
68
+ </>
69
+ )
70
+ }
@@ -0,0 +1,25 @@
1
+ import type { HTMLAttributes, ReactNode } from 'react'
2
+
3
+ export interface UnitProps extends HTMLAttributes<HTMLSpanElement> {
4
+ children?: ReactNode
5
+ }
6
+
7
+ /**
8
+ * Small inline label that trails a hero number inside a `.stat` row or a
9
+ * `<Card>` title row (e.g. "Mbps · down", "Last 24 h", "ms · jitter band").
10
+ * Renders a `<span class="unit">` so the `.unit` rule in
11
+ * `@w5-ui/tokens/dashboard.css` sets the canonical muted colour, 12 px size,
12
+ * and inline-block rhythm. Stops userland reaching for inline `font-size` /
13
+ * `color` overrides next to bare numbers.
14
+ *
15
+ * Typed equivalent of `<span className="unit">`; pair with `<Stat>` (which
16
+ * already wires this internally) for hero tiles, or compose by hand inside a
17
+ * `<Card>` when the headline number sits above a chart.
18
+ */
19
+ export function Unit({ className = '', children, ...rest }: UnitProps) {
20
+ return (
21
+ <span className={`unit ${className}`.trim()} {...rest}>
22
+ {children}
23
+ </span>
24
+ )
25
+ }
package/src/index.ts CHANGED
@@ -18,6 +18,38 @@ export * from './components/Signal.js'
18
18
  export * from './components/Donut.js'
19
19
  export * from './components/StatusIndicator.js'
20
20
  export * from './components/AppShell.js'
21
+ export * from './components/AppLayout.js'
22
+ export * from './components/Grid.js'
23
+ export * from './components/FieldStack.js'
24
+ export * from './components/FormRow.js'
25
+ export * from './components/FormActions.js'
26
+ export * from './components/TableShell.js'
27
+ export * from './components/TablePager.js'
28
+ export * from './components/Submeta.js'
29
+ export * from './components/Delta.js'
30
+ export * from './components/CardMore.js'
31
+ export * from './components/Unit.js'
32
+ export * from './components/StatNumber.js'
33
+ export * from './components/Mac.js'
34
+ export * from './components/NameCell.js'
35
+ export * from './components/SrOnly.js'
36
+ export * from './components/NotifDot.js'
37
+ export * from './components/StatusRing.js'
38
+ export * from './components/TopbarActions.js'
39
+ export * from './components/Muted.js'
40
+ export * from './components/Code.js'
41
+ export * from './components/Eyebrow.js'
42
+ export * from './components/Mono.js'
43
+ export * from './components/Caption.js'
44
+ export * from './components/BodyLg.js'
45
+ export * from './components/Body.js'
46
+ export * from './components/Label.js'
47
+ export * from './components/Display1.js'
48
+ export * from './components/Display2.js'
49
+ export * from './components/H1.js'
50
+ export * from './components/H2.js'
51
+ export * from './components/H3.js'
52
+ export * from './components/H4.js'
21
53
  export * from './components/Skeleton.js'
22
54
  export * from './components/Spinner.js'
23
55
  export * from './components/SkipLink.js'
@@ -157,4 +189,5 @@ export * from './components/SelectionToolbar.js'
157
189
  export * from './components/FilterBuilder.js'
158
190
  export * from './components/RankedList.js'
159
191
  export * from './components/GroupedList.js'
192
+ export * from './components/PageHeader.js'
160
193
  export * from './icons.js'