@oxy.so/bloom 2.1.0 → 2.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/README.md +3 -3
- package/docs/page-header.mdx +101 -0
- package/lib/commonjs/index.js +128 -116
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +128 -116
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/page-header/PageHeader.js +286 -0
- package/lib/commonjs/page-header/PageHeader.js.map +1 -0
- package/lib/commonjs/page-header/index.js +13 -0
- package/lib/commonjs/page-header/index.js.map +1 -0
- package/lib/commonjs/page-header/types.js +6 -0
- package/lib/commonjs/page-header/types.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +1 -0
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/page-header/PageHeader.js +281 -0
- package/lib/module/page-header/PageHeader.js.map +1 -0
- package/lib/module/page-header/index.js +4 -0
- package/lib/module/page-header/index.js.map +1 -0
- package/lib/module/page-header/types.js +4 -0
- package/lib/module/page-header/types.js.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +1 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.web.d.ts +1 -0
- package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/page-header/PageHeader.d.ts +6 -0
- package/lib/typescript/commonjs/page-header/PageHeader.d.ts.map +1 -0
- package/lib/typescript/commonjs/page-header/index.d.ts +3 -0
- package/lib/typescript/commonjs/page-header/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/page-header/types.d.ts +55 -0
- package/lib/typescript/commonjs/page-header/types.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +1 -0
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/index.web.d.ts +1 -0
- package/lib/typescript/module/index.web.d.ts.map +1 -1
- package/lib/typescript/module/page-header/PageHeader.d.ts +6 -0
- package/lib/typescript/module/page-header/PageHeader.d.ts.map +1 -0
- package/lib/typescript/module/page-header/index.d.ts +3 -0
- package/lib/typescript/module/page-header/index.d.ts.map +1 -0
- package/lib/typescript/module/page-header/types.d.ts +55 -0
- package/lib/typescript/module/page-header/types.d.ts.map +1 -0
- package/package.json +15 -1
- package/src/index.ts +1 -0
- package/src/index.web.ts +1 -0
- package/src/page-header/PageHeader.tsx +319 -0
- package/src/page-header/index.ts +3 -0
- package/src/page-header/types.ts +62 -0
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
### What it is
|
|
22
22
|
|
|
23
|
-
Components, hooks and design tokens published as `@oxy.so/bloom` across
|
|
23
|
+
Components, hooks and design tokens published as `@oxy.so/bloom` across 129 subpath exports, shipped as `src` for Metro and as compiled CommonJS and ESM for everyone else. Web builds resolve platform forks automatically through export conditions, so a `.web.tsx` fork never reaches a native bundle.
|
|
24
24
|
|
|
25
25
|
Styling is NativeWind classes throughout. There are no colour props and no wrapper components to theme a button, because a second way to set a colour is a second thing that can disagree.
|
|
26
26
|
|
|
@@ -151,12 +151,12 @@ Every palette is generated from a single seed colour by a dependency free colour
|
|
|
151
151
|
|
|
152
152
|
## Components
|
|
153
153
|
|
|
154
|
-
Bloom publishes
|
|
154
|
+
Bloom publishes 129 subpath exports. Importing from the subpath rather than the root keeps a bundle to what it actually renders.
|
|
155
155
|
|
|
156
156
|
| Group | Exports |
|
|
157
157
|
|---|---|
|
|
158
158
|
| Providers and theme | `provider`, `theme`, `theme-toggle`, `color-presets`, `preset-vars`, `design-tokens`, `tailwind-preset`, `styles`, `hooks` |
|
|
159
|
-
| App shell and navigation | `app-shell`, `sidebar`, `rail`, `breadcrumb`, `pagination`, `tabs`, `tab-bar`, `layout`, `content-panel` |
|
|
159
|
+
| App shell and navigation | `app-shell`, `page-header`, `sidebar`, `rail`, `breadcrumb`, `pagination`, `tabs`, `tab-bar`, `layout`, `content-panel` |
|
|
160
160
|
| Overlays | `dialog`, `alert-dialog`, `bottom-sheet`, `popover`, `context-menu`, `dropdown-menu`, `menubar`, `tooltip`, `overlay`, `portal`, `teleport`, `surfaces`, `settings-modal` |
|
|
161
161
|
| Actions | `button`, `button-group`, `social-button`, `fab`, `frosted-icon-button`, `pressable-scale`, `subtle-hover` |
|
|
162
162
|
| Forms | `text-field`, `textarea`, `phone-input`, `input-otp`, `field`, `input-group`, `label`, `select`, `command`, `checkbox`, `radio`, `switch`, `slider`, `segmented-control`, `search`, `date-picker`, `file-upload`, `auth-card` |
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: PageHeader
|
|
3
|
+
description: A screen's top bar — back button, title and subtitle, a leading node and actions — sticky on web, safe-area aware on native, with a scroll-linked border, shadow and transparent-over-media mode.
|
|
4
|
+
order: 105
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# PageHeader
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { PageHeader } from '@oxy.so/bloom/page-header';
|
|
11
|
+
|
|
12
|
+
<PageHeader
|
|
13
|
+
onBack={router.back}
|
|
14
|
+
title="Order #4821"
|
|
15
|
+
subtitle="Placed today"
|
|
16
|
+
actions={<>
|
|
17
|
+
<Button variant="secondary" iconOnly leadingIcon={RiShare2Line} accessibilityLabel="Share" />
|
|
18
|
+
<Button variant="primary" leadingIcon={RiAddFill}>New order</Button>
|
|
19
|
+
</>}
|
|
20
|
+
/>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Router-agnostic: the back button renders when `onBack` is set. Pass `router.back`, your app's safe-back helper, or omit it on a root screen (`router.canGoBack() ? router.back : undefined`).
|
|
24
|
+
|
|
25
|
+
## Props
|
|
26
|
+
|
|
27
|
+
| Prop | Default | |
|
|
28
|
+
| --- | --- | --- |
|
|
29
|
+
| `title` | — | A string is the heading (`role="heading"`, `aria-level={headingLevel}`); a node renders as-is and owns its semantics. |
|
|
30
|
+
| `subtitle` | — | A string is a secondary line; a node renders as-is. |
|
|
31
|
+
| `titleAlign` | `'start'` | `'center'` centres the title on the bar whatever the two sides hold. |
|
|
32
|
+
| `headingLevel` | `1` | |
|
|
33
|
+
| `onBack` / `backLabel` | — / `"Back"` | `backLabel` is the button's accessible name — localise it. |
|
|
34
|
+
| `leading` | — | After the back button, before the title (an avatar, a logo). |
|
|
35
|
+
| `actions` | — | End of the bar, 10 apart. Use Bloom `Button`s. |
|
|
36
|
+
| `border` | `'auto'` | `auto` fades the separator in with scroll; `always`; `none`. |
|
|
37
|
+
| `transparent` | `false` | Background, shadow and title fade in with scroll — for a header over media. The back button and actions stay (their own fill reads over any photo). |
|
|
38
|
+
| `scrollY` | — | A Reanimated `SharedValue<number>` driving the scroll-linked paint. |
|
|
39
|
+
| `scrollThreshold` | `20` | The offset over which border, shadow and background fade in. Over a hero, use the hero height minus the bar. |
|
|
40
|
+
| `sticky` | `true` | Web: `position: sticky; top: 0`. No effect on native. |
|
|
41
|
+
| `safeArea` | native `true`, web `false` | Pads the top by the safe-area inset (read from `SafeAreaInsetsContext`; no provider → 0). |
|
|
42
|
+
|
|
43
|
+
## Look
|
|
44
|
+
|
|
45
|
+
- Bar min-height 56; side inset 16 below `sm`, 24 from `sm`.
|
|
46
|
+
- Back: the secondary medium icon-only `Button` (36, pill, hairline, shadow-xs) with `RiArrowLeftLine`.
|
|
47
|
+
- Start group gap 6; title `headline-medium` text-primary, 4px side padding (`gap-1.5` + `px-1`, as in the template headers); subtitle `body-2-regular` text-secondary. Both truncate to one line.
|
|
48
|
+
- Background `background/full` (card; dark neutral-925). Separator 1px `separator-border` (neutral-200; dark neutral-800). Shadow `shadow-xs`, only once scrolled.
|
|
49
|
+
- No press scale. The fades are scroll-linked, not timed, so there is no motion to reduce.
|
|
50
|
+
|
|
51
|
+
## Scroll
|
|
52
|
+
|
|
53
|
+
Border (`auto`), shadow and — with `transparent` — background and title interpolate over `[0, scrollThreshold]` of the scroll offset:
|
|
54
|
+
|
|
55
|
+
- **Web, window scroll:** omit `scrollY`; the header follows `window.scrollY`.
|
|
56
|
+
- **A scroll container (any platform):** pass the offset.
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
const scrollY = useSharedValue(0);
|
|
60
|
+
const onScroll = useAnimatedScrollHandler({ onScroll: (e) => { scrollY.value = e.contentOffset.y; } }, [scrollY]);
|
|
61
|
+
|
|
62
|
+
<PageHeader title="Inbox" onBack={back} scrollY={scrollY} sticky={false} />
|
|
63
|
+
<Animated.ScrollView onScroll={onScroll} scrollEventThrottle={16}>…</Animated.ScrollView>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Without `scrollY` on native the header stays at rest (border `auto` hidden, `transparent` stays transparent). Name `scrollY` in the handler's dependency array — without the worklets Babel plugin (Storybook, some web builds) a shared value missing from it never updates.
|
|
67
|
+
|
|
68
|
+
**Over media** (`transparent`): let the photo start under the bar (`marginTop: -56` on the hero, or absolutely position the header), and set `scrollThreshold` to the hero height minus the bar so the bar arrives as the photo leaves.
|
|
69
|
+
|
|
70
|
+
## Accessibility
|
|
71
|
+
|
|
72
|
+
- The title is a `heading` (level 1 by default: the page header titles the page).
|
|
73
|
+
- The container carries no landmark role. `role="banner"` would be one banner per header, and an app shell already owns the page's banner; a page header inside `main` is not a landmark in HTML either.
|
|
74
|
+
- The back button is named by `backLabel`.
|
|
75
|
+
|
|
76
|
+
## Not included
|
|
77
|
+
|
|
78
|
+
- **iOS large title.** A large title that collapses into the bar needs to live inside the scroll content (so it scrolls under the bar) while the bar lives outside it; a standalone header cannot own both without making content move at twice the scroll speed on native. `Dialog`'s own header (`docs/dialog.mdx`) does it because the Dialog owns its scroller.
|
|
79
|
+
|
|
80
|
+
## Migrating from app headers
|
|
81
|
+
|
|
82
|
+
Mention, Allo and Homiio each hand-roll a `Header` with an `options` object. The mapping:
|
|
83
|
+
|
|
84
|
+
| App header | `PageHeader` |
|
|
85
|
+
| --- | --- |
|
|
86
|
+
| `options.title` | `title` |
|
|
87
|
+
| `options.titlePosition: 'left' \| 'center'` | `titleAlign: 'start' \| 'center'` |
|
|
88
|
+
| `options.subtitle` (string or node) | `subtitle` |
|
|
89
|
+
| `options.showBackButton` (+ `useSafeBack` / `router.back` inside) | `onBack={safeBack}` — omit to hide |
|
|
90
|
+
| Homiio `showBackButton && router.canGoBack()` | `onBack={router.canGoBack() ? router.back : undefined}` |
|
|
91
|
+
| `options.leftComponents: ReactNode[]` | `leading={<>…</>}` |
|
|
92
|
+
| `options.rightComponents: ReactNode[]` | `actions={<>…</>}` |
|
|
93
|
+
| `hideBottomBorder` | `border="none"` (the apps drew it at rest: `border="always"` for the old look) |
|
|
94
|
+
| `disableSticky` | `sticky={false}` |
|
|
95
|
+
| web `window.scrollY > 20` sticky state | built in (`scrollThreshold`, default 20) |
|
|
96
|
+
| Homiio `options.transparent` / `options.scrollThreshold` | `transparent` / `scrollThreshold` |
|
|
97
|
+
| Homiio `scrollY` | `scrollY` |
|
|
98
|
+
| Homiio `useSafeAreaInsets().top` | `safeArea` (default on native) |
|
|
99
|
+
| Mention `options.headerTitleStyle` | pass a node `title` |
|
|
100
|
+
|
|
101
|
+
Two visual changes: the title is `headline-medium` (16/22, 500) instead of 18/800, and the back button is a pill icon button instead of a bare arrow.
|