@oxy.so/bloom 2.6.0 → 2.7.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 (84) hide show
  1. package/docs/app-shell.mdx +47 -3
  2. package/docs/sidebar.mdx +17 -0
  3. package/lib/commonjs/app-shell/AppShell.js +248 -156
  4. package/lib/commonjs/app-shell/AppShell.js.map +1 -1
  5. package/lib/commonjs/app-shell/AppShellHeader.js +2 -2
  6. package/lib/commonjs/app-shell/AppShellHeader.js.map +1 -1
  7. package/lib/commonjs/app-shell/AppShellMenuButton.js +40 -0
  8. package/lib/commonjs/app-shell/AppShellMenuButton.js.map +1 -0
  9. package/lib/commonjs/app-shell/context.js +30 -0
  10. package/lib/commonjs/app-shell/context.js.map +1 -0
  11. package/lib/commonjs/app-shell/index.js +14 -0
  12. package/lib/commonjs/app-shell/index.js.map +1 -1
  13. package/lib/commonjs/sidebar/Sidebar.js +51 -17
  14. package/lib/commonjs/sidebar/Sidebar.js.map +1 -1
  15. package/lib/commonjs/sidebar/SidebarLogoView.js +124 -0
  16. package/lib/commonjs/sidebar/SidebarLogoView.js.map +1 -0
  17. package/lib/commonjs/sidebar/SidebarRail.js +16 -2
  18. package/lib/commonjs/sidebar/SidebarRail.js.map +1 -1
  19. package/lib/module/app-shell/AppShell.js +249 -157
  20. package/lib/module/app-shell/AppShell.js.map +1 -1
  21. package/lib/module/app-shell/AppShellHeader.js +2 -2
  22. package/lib/module/app-shell/AppShellHeader.js.map +1 -1
  23. package/lib/module/app-shell/AppShellMenuButton.js +35 -0
  24. package/lib/module/app-shell/AppShellMenuButton.js.map +1 -0
  25. package/lib/module/app-shell/context.js +23 -0
  26. package/lib/module/app-shell/context.js.map +1 -0
  27. package/lib/module/app-shell/index.js +2 -0
  28. package/lib/module/app-shell/index.js.map +1 -1
  29. package/lib/module/sidebar/Sidebar.js +51 -17
  30. package/lib/module/sidebar/Sidebar.js.map +1 -1
  31. package/lib/module/sidebar/SidebarLogoView.js +119 -0
  32. package/lib/module/sidebar/SidebarLogoView.js.map +1 -0
  33. package/lib/module/sidebar/SidebarRail.js +16 -2
  34. package/lib/module/sidebar/SidebarRail.js.map +1 -1
  35. package/lib/typescript/commonjs/app-shell/AppShell.d.ts.map +1 -1
  36. package/lib/typescript/commonjs/app-shell/AppShellHeader.d.ts.map +1 -1
  37. package/lib/typescript/commonjs/app-shell/AppShellMenuButton.d.ts +4 -0
  38. package/lib/typescript/commonjs/app-shell/AppShellMenuButton.d.ts.map +1 -0
  39. package/lib/typescript/commonjs/app-shell/context.d.ts +18 -0
  40. package/lib/typescript/commonjs/app-shell/context.d.ts.map +1 -0
  41. package/lib/typescript/commonjs/app-shell/index.d.ts +4 -1
  42. package/lib/typescript/commonjs/app-shell/index.d.ts.map +1 -1
  43. package/lib/typescript/commonjs/app-shell/types.d.ts +41 -11
  44. package/lib/typescript/commonjs/app-shell/types.d.ts.map +1 -1
  45. package/lib/typescript/commonjs/sidebar/Sidebar.d.ts.map +1 -1
  46. package/lib/typescript/commonjs/sidebar/SidebarLogoView.d.ts +6 -0
  47. package/lib/typescript/commonjs/sidebar/SidebarLogoView.d.ts.map +1 -0
  48. package/lib/typescript/commonjs/sidebar/SidebarRail.d.ts +3 -2
  49. package/lib/typescript/commonjs/sidebar/SidebarRail.d.ts.map +1 -1
  50. package/lib/typescript/commonjs/sidebar/index.d.ts +1 -1
  51. package/lib/typescript/commonjs/sidebar/index.d.ts.map +1 -1
  52. package/lib/typescript/commonjs/sidebar/types.d.ts +36 -0
  53. package/lib/typescript/commonjs/sidebar/types.d.ts.map +1 -1
  54. package/lib/typescript/module/app-shell/AppShell.d.ts.map +1 -1
  55. package/lib/typescript/module/app-shell/AppShellHeader.d.ts.map +1 -1
  56. package/lib/typescript/module/app-shell/AppShellMenuButton.d.ts +4 -0
  57. package/lib/typescript/module/app-shell/AppShellMenuButton.d.ts.map +1 -0
  58. package/lib/typescript/module/app-shell/context.d.ts +18 -0
  59. package/lib/typescript/module/app-shell/context.d.ts.map +1 -0
  60. package/lib/typescript/module/app-shell/index.d.ts +4 -1
  61. package/lib/typescript/module/app-shell/index.d.ts.map +1 -1
  62. package/lib/typescript/module/app-shell/types.d.ts +41 -11
  63. package/lib/typescript/module/app-shell/types.d.ts.map +1 -1
  64. package/lib/typescript/module/sidebar/Sidebar.d.ts.map +1 -1
  65. package/lib/typescript/module/sidebar/SidebarLogoView.d.ts +6 -0
  66. package/lib/typescript/module/sidebar/SidebarLogoView.d.ts.map +1 -0
  67. package/lib/typescript/module/sidebar/SidebarRail.d.ts +3 -2
  68. package/lib/typescript/module/sidebar/SidebarRail.d.ts.map +1 -1
  69. package/lib/typescript/module/sidebar/index.d.ts +1 -1
  70. package/lib/typescript/module/sidebar/index.d.ts.map +1 -1
  71. package/lib/typescript/module/sidebar/types.d.ts +36 -0
  72. package/lib/typescript/module/sidebar/types.d.ts.map +1 -1
  73. package/package.json +1 -1
  74. package/src/app-shell/AppShell.tsx +181 -107
  75. package/src/app-shell/AppShellHeader.tsx +11 -9
  76. package/src/app-shell/AppShellMenuButton.tsx +37 -0
  77. package/src/app-shell/context.ts +35 -0
  78. package/src/app-shell/index.ts +4 -0
  79. package/src/app-shell/types.ts +42 -11
  80. package/src/sidebar/Sidebar.tsx +42 -22
  81. package/src/sidebar/SidebarLogoView.tsx +92 -0
  82. package/src/sidebar/SidebarRail.tsx +9 -1
  83. package/src/sidebar/index.ts +1 -0
  84. package/src/sidebar/types.ts +38 -0
@@ -1,4 +1,4 @@
1
- import React, { memo, useEffect } from 'react';
1
+ import React, { memo, useEffect, useMemo } from 'react';
2
2
  import { Platform, Pressable, ScrollView, View, useWindowDimensions } from 'react-native';
3
3
  import Animated, {
4
4
  Easing,
@@ -24,13 +24,15 @@ import {
24
24
  } from '../styles/web-view-style';
25
25
  import { useTheme } from '../theme/use-theme';
26
26
  import { AppShellHeader } from './AppShellHeader';
27
+ import { AppShellProvider } from './context';
27
28
  import type { AppShellProps } from './types';
28
29
 
29
30
  /**
30
31
  * The page frame: a starter shell and a dashboard shell, combined into one
31
32
  * component.
32
33
  *
33
- * root row, full height, background-full, overflow hidden
34
+ * root row, background-full; one screen tall at least (document
35
+ * scroll), exactly (`fixed`), or its parent's height (`container`)
34
36
  * lg and up the sidebar in flow (from `sm` for `variant: 'rail'`, whose
35
37
  * drawer below `sm` opens the panel); `overlay` pads the whole frame 12 with a
36
38
  * 16 gap, `reveal` sits the rail 12 from the top-left
@@ -39,7 +41,10 @@ import type { AppShellProps } from './types';
39
41
  * header (breadcrumb + title row), then the content (gap 16,
40
42
  * 16 below). `overlay` insets the column 12 from the top at `sm`,
41
43
  * `reveal` pads the page 12 (24 on top at `sm`)
42
- * below lg the header grows a hamburger. `overlay` opens the rail as a
44
+ * aside optional right column, `asideWidth` (320) wide from `asideFrom`
45
+ * (xl), pinned like the rail; below it stacked after the content
46
+ * below lg the header grows a hamburger (also with no title — see
47
+ * `useAppShell` / `AppShellMenuButton`). `overlay` opens the rail as a
43
48
  * drawer (12 inset) over a 40% black backdrop; `reveal` slides
44
49
  * the page 272 right and rounds it to 32 while the rail, flat
45
50
  * beneath it, scales up from 0.94 and fades in (325ms,
@@ -51,22 +56,28 @@ const REVEAL_EASE = Easing.bezier(0.42, 0, 0.58, 1);
51
56
  const REVEAL_MS = 325;
52
57
  const REVEAL_OFFSET = 272;
53
58
 
59
+ type ScrollMode = 'document' | 'container' | 'fixed';
60
+
54
61
  /**
55
- * The page's scroller. In `document` mode it is a plain box and the page grows
56
- * the document; otherwise a `ScrollView` filling the frame.
62
+ * The page's scroller. `document`: a plain box, the page grows the document.
63
+ * `fixed`: a plain box that fills the frame's height and never scrolls — the
64
+ * page owns its scrolling. `container`: a `ScrollView` filling the frame.
57
65
  */
58
66
  function Scroller({
59
- document: inDocument,
67
+ mode,
60
68
  style,
61
69
  contentStyle,
62
70
  children,
63
71
  }: {
64
- document: boolean;
72
+ mode: ScrollMode;
65
73
  style: WebCssStyle;
66
74
  contentStyle: WebCssStyle;
67
75
  children: React.ReactNode;
68
76
  }) {
69
- if (inDocument) return <View style={[style, contentStyle]}>{children}</View>;
77
+ if (mode === 'document') return <View style={[style, contentStyle]}>{children}</View>;
78
+ if (mode === 'fixed') {
79
+ return <View style={[{ flex: 1, minHeight: 0 }, style, contentStyle]}>{children}</View>;
80
+ }
70
81
  return (
71
82
  <ScrollView style={[{ flex: 1 }, style]} contentContainerStyle={contentStyle}>
72
83
  {children}
@@ -81,6 +92,10 @@ const AppShellComponent: React.FC<AppShellProps> = ({
81
92
  breadcrumb,
82
93
  actions,
83
94
  header,
95
+ aside,
96
+ asideWidth = 320,
97
+ asideFrom = 'xl',
98
+ asideCollapse = 'stack',
84
99
  children,
85
100
  contentMaxWidth = 1300,
86
101
  overlay,
@@ -92,12 +107,16 @@ const AppShellComponent: React.FC<AppShellProps> = ({
92
107
  }) => {
93
108
  const theme = useTheme();
94
109
  const { width } = useWindowDimensions();
95
- // Native has no document; `scroll` only chooses on web.
96
- const doc = Platform.OS === 'web' && scroll === 'document';
110
+ // Native has no document: `document` falls back to `container` there.
111
+ const mode: ScrollMode = scroll === 'document' && Platform.OS !== 'web' ? 'container' : scroll;
112
+ const doc = mode === 'document';
113
+ const fixed = mode === 'fixed';
97
114
  const small = width >= BREAKPOINTS.sm;
98
115
  // The rail is narrow enough to stay in flow from `sm`; the panel needs `lg`.
99
116
  const rail = sidebar?.variant === 'rail';
100
117
  const wide = rail ? small : width >= BREAKPOINTS.lg;
118
+ const asideBeside = aside != null && width >= BREAKPOINTS[asideFrom];
119
+ const asideStacked = aside != null && !asideBeside && asideCollapse === 'stack';
101
120
  // The drawer always opens the full panel, whatever the in-flow variant.
102
121
  const drawerSidebar = sidebar ? { ...sidebar, variant: 'panel' as const } : undefined;
103
122
  const reducedMotion = useReducedMotion();
@@ -106,7 +125,19 @@ const AppShellComponent: React.FC<AppShellProps> = ({
106
125
  defaultValue: false,
107
126
  onChange: onDrawerOpenChange,
108
127
  });
109
- const isOpen = open && !wide;
128
+ const drawerAvailable = !!sidebar && !wide;
129
+ const isOpen = open && drawerAvailable;
130
+
131
+ const shell = useMemo(
132
+ () => ({
133
+ drawerAvailable,
134
+ drawerOpen: isOpen,
135
+ openDrawer: () => setOpen(true),
136
+ closeDrawer: () => setOpen(false),
137
+ toggleDrawer: () => setOpen(!isOpen),
138
+ }),
139
+ [drawerAvailable, isOpen, setOpen],
140
+ );
110
141
 
111
142
  const { neutral: n } = resolveButtonRamps(theme);
112
143
  const background = theme.isDark ? mixColor(n[900], n[950], 0.4) : theme.colors.card;
@@ -126,127 +157,158 @@ const AppShellComponent: React.FC<AppShellProps> = ({
126
157
  );
127
158
  const veilStyle = useAnimatedStyle(() => ({ opacity: reveal.value }), [reveal]);
128
159
 
160
+ // The default header renders whenever it has something to show — a menu
161
+ // button alone counts, so a page without a title can still open the drawer.
129
162
  const headerNode =
130
163
  header ??
131
- (title != null ? (
164
+ (title != null || breadcrumb != null || actions != null || drawerAvailable ? (
132
165
  <AppShellHeader
133
166
  title={title}
134
167
  breadcrumb={breadcrumb}
135
168
  actions={actions}
136
169
  menuOpen={isOpen}
137
- onMenuPress={sidebar && !wide ? () => setOpen(!open) : undefined}
170
+ onMenuPress={drawerAvailable ? shell.toggleDrawer : undefined}
138
171
  testID={testID ? `${testID}-header` : undefined}
139
172
  />
140
173
  ) : null);
141
174
 
175
+ const fill = fixed ? { flex: 1, minHeight: 0 } : null;
142
176
  const column = (
143
- <View style={{ width: '100%', maxWidth: contentMaxWidth, alignSelf: 'center', gap: 10 }}>
177
+ <View style={[{ width: '100%', maxWidth: contentMaxWidth, alignSelf: 'center', gap: 10 }, fill]}>
144
178
  {headerNode}
145
- <View style={{ width: '100%', gap: 16, paddingBottom: drawer === 'overlay' ? 16 : 0 }}>{children}</View>
179
+ <View style={[{ width: '100%', gap: 16, paddingBottom: drawer === 'overlay' ? 16 : 0 }, fill]}>
180
+ {children}
181
+ {asideStacked ? <View testID={testID ? `${testID}-aside` : undefined}>{aside}</View> : null}
182
+ </View>
146
183
  </View>
147
184
  );
148
185
 
149
- if (drawer === 'reveal') {
150
- return (
186
+ // Beside the content: sticky and self-scrolling with document scroll, a
187
+ // full-height scroller otherwise.
188
+ const asideColumn = (inset: WebCssStyle) =>
189
+ asideBeside ? (
151
190
  <View
152
- testID={testID}
153
- style={[doc ? revealDocumentRoot : { flex: 1, height: '100%', overflow: 'hidden' }, { flexDirection: 'row', backgroundColor: background }, style]}
191
+ testID={testID ? `${testID}-aside` : undefined}
192
+ style={[
193
+ { width: asideWidth, flexShrink: 0 },
194
+ doc ? { ...stickyRail(12), width: asideWidth } : { alignSelf: 'stretch' },
195
+ inset,
196
+ ]}
154
197
  >
155
- {sidebar && wide ? (
156
- <View style={[{ paddingTop: 12, paddingBottom: 12, paddingLeft: 12, flexShrink: 0 }, doc ? stickyRail(0) : null]}>
157
- <Sidebar {...sidebar} />
158
- </View>
159
- ) : null}
160
- {sidebar && !wide ? (
161
- <View
162
- aria-hidden={!isOpen}
163
- pointerEvents={isOpen ? 'auto' : 'none'}
164
- // Fixed on web in document mode: the rail waits beneath the VIEWPORT,
165
- // wherever the page is scrolled to.
166
- style={{ position: doc ? WEB_POSITION_FIXED : 'absolute', top: 0, bottom: 0, left: 0, width: 272, paddingTop: 12, paddingBottom: 12, paddingLeft: 6 }}
167
- >
168
- <Animated.View style={[{ height: '100%', width: 260, transformOrigin: 'left center' }, railStyle]}>
169
- <Sidebar {...drawerSidebar} mobile flat onClose={() => setOpen(false)} />
170
- </Animated.View>
171
- </View>
172
- ) : null}
173
- <Animated.View
174
- style={[{ flex: 1, minWidth: 0, overflow: doc ? WEB_OVERFLOW_CLIP : 'hidden', backgroundColor: background }, wide ? null : pageStyle]}
198
+ <ScrollView style={{ flex: 1 }} contentContainerStyle={{ flexGrow: 1 }} showsVerticalScrollIndicator={false}>
199
+ {aside}
200
+ </ScrollView>
201
+ </View>
202
+ ) : null;
203
+
204
+ const frame = doc ? documentRoot : fixed ? fixedRoot : containerRoot;
205
+
206
+ if (drawer === 'reveal') {
207
+ return (
208
+ <AppShellProvider value={shell}>
209
+ <View
210
+ testID={testID}
211
+ style={[frame, doc ? { overflow: WEB_OVERFLOW_CLIP } : null, { flexDirection: 'row', backgroundColor: background }, style]}
175
212
  >
176
- <Scroller document={doc} style={{}} contentStyle={{ padding: 12, paddingTop: small ? 24 : 12 }}>
177
- {column}
178
- </Scroller>
179
- {!wide ? (
180
- <Animated.View
213
+ {sidebar && wide ? (
214
+ <View style={[{ paddingTop: 12, paddingBottom: 12, paddingLeft: 12, flexShrink: 0 }, doc ? stickyRail(0) : null]}>
215
+ <Sidebar {...sidebar} />
216
+ </View>
217
+ ) : null}
218
+ {sidebar && !wide ? (
219
+ <View
220
+ aria-hidden={!isOpen}
181
221
  pointerEvents={isOpen ? 'auto' : 'none'}
182
- style={[{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0 }, veilStyle]}
222
+ // Fixed on web in document mode: the rail waits beneath the VIEWPORT,
223
+ // wherever the page is scrolled to.
224
+ style={{ position: doc ? WEB_POSITION_FIXED : 'absolute', top: 0, bottom: 0, left: 0, width: 272, paddingTop: 12, paddingBottom: 12, paddingLeft: 6 }}
183
225
  >
184
- <Pressable
185
- role="button"
186
- accessibilityLabel="Close navigation"
187
- focusable={isOpen}
188
- onPress={() => setOpen(false)}
189
- style={{
190
- flex: 1,
191
- backgroundColor: theme.isDark ? 'rgba(255, 255, 255, 0.05)' : 'rgba(0, 0, 0, 0.1)',
192
- }}
193
- testID={testID ? `${testID}-veil` : undefined}
194
- />
195
- </Animated.View>
226
+ <Animated.View style={[{ height: '100%', width: 260, transformOrigin: 'left center' }, railStyle]}>
227
+ <Sidebar {...drawerSidebar} mobile flat onClose={() => setOpen(false)} />
228
+ </Animated.View>
229
+ </View>
196
230
  ) : null}
197
- </Animated.View>
198
- {overlay}
199
- </View>
231
+ <Animated.View
232
+ style={[
233
+ { flex: 1, minWidth: 0, flexDirection: 'row', overflow: doc ? WEB_OVERFLOW_CLIP : 'hidden', backgroundColor: background },
234
+ wide ? null : pageStyle,
235
+ ]}
236
+ >
237
+ <Scroller mode={mode} style={{ flex: doc ? undefined : 1, flexGrow: 1, minWidth: 0 }} contentStyle={{ padding: 12, paddingTop: small ? 24 : 12 }}>
238
+ {column}
239
+ </Scroller>
240
+ {asideColumn({ paddingTop: small ? 24 : 12, paddingBottom: 12, paddingRight: 12 })}
241
+ {!wide ? (
242
+ <Animated.View
243
+ pointerEvents={isOpen ? 'auto' : 'none'}
244
+ style={[{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0 }, veilStyle]}
245
+ >
246
+ <Pressable
247
+ role="button"
248
+ accessibilityLabel="Close navigation"
249
+ focusable={isOpen}
250
+ onPress={() => setOpen(false)}
251
+ style={{
252
+ flex: 1,
253
+ backgroundColor: theme.isDark ? 'rgba(255, 255, 255, 0.05)' : 'rgba(0, 0, 0, 0.1)',
254
+ }}
255
+ testID={testID ? `${testID}-veil` : undefined}
256
+ />
257
+ </Animated.View>
258
+ ) : null}
259
+ </Animated.View>
260
+ {overlay}
261
+ </View>
262
+ </AppShellProvider>
200
263
  );
201
264
  }
202
265
 
203
266
  return (
204
- <View
205
- testID={testID}
206
- style={[
207
- doc ? documentRoot : { flex: 1, height: '100%', overflow: 'hidden' },
208
- { flexDirection: 'row', gap: 16, padding: 12, backgroundColor: background },
209
- style,
210
- ]}
211
- >
212
- {sidebar && wide ? (
213
- doc ? (
214
- <View style={stickyRail(12)}>
267
+ <AppShellProvider value={shell}>
268
+ <View
269
+ testID={testID}
270
+ style={[frame, { flexDirection: 'row', gap: 16, padding: 12, backgroundColor: background }, style]}
271
+ >
272
+ {sidebar && wide ? (
273
+ doc ? (
274
+ <View style={stickyRail(12)}>
275
+ <Sidebar {...sidebar} />
276
+ </View>
277
+ ) : (
215
278
  <Sidebar {...sidebar} />
216
- </View>
217
- ) : (
218
- <Sidebar {...sidebar} />
219
- )
220
- ) : null}
221
- {sidebar && isOpen ? (
222
- <Portal>
223
- <OverlayRoot>
224
- <Backdrop
225
- onPress={() => setOpen(false)}
226
- blurIntensity={0}
227
- dimOpacity={0.4}
228
- accessibilityLabel="Close navigation"
229
- />
230
- <View
231
- pointerEvents="box-none"
232
- style={{ position: 'absolute', top: 0, bottom: 0, left: 0, flexDirection: 'row', padding: 12 }}
233
- >
234
- <View pointerEvents="auto" style={{ height: '100%' }}>
235
- <Sidebar {...drawerSidebar} mobile onClose={() => setOpen(false)} />
279
+ )
280
+ ) : null}
281
+ {sidebar && isOpen ? (
282
+ <Portal>
283
+ <OverlayRoot>
284
+ <Backdrop
285
+ onPress={() => setOpen(false)}
286
+ blurIntensity={0}
287
+ dimOpacity={0.4}
288
+ accessibilityLabel="Close navigation"
289
+ />
290
+ <View
291
+ pointerEvents="box-none"
292
+ style={{ position: 'absolute', top: 0, bottom: 0, left: 0, flexDirection: 'row', padding: 12 }}
293
+ >
294
+ <View pointerEvents="auto" style={{ height: '100%' }}>
295
+ <Sidebar {...drawerSidebar} mobile onClose={() => setOpen(false)} />
296
+ </View>
236
297
  </View>
237
- </View>
238
- </OverlayRoot>
239
- </Portal>
240
- ) : null}
241
- <Scroller
242
- document={doc}
243
- style={{ flex: 1, minWidth: 0, backgroundColor: background }}
244
- contentStyle={{ paddingTop: small ? 12 : 0 }}
245
- >
246
- {column}
247
- </Scroller>
248
- {overlay}
249
- </View>
298
+ </OverlayRoot>
299
+ </Portal>
300
+ ) : null}
301
+ <Scroller
302
+ mode={mode}
303
+ style={{ flex: 1, minWidth: 0, backgroundColor: background }}
304
+ contentStyle={{ paddingTop: small ? 12 : 0 }}
305
+ >
306
+ {column}
307
+ </Scroller>
308
+ {asideColumn({})}
309
+ {overlay}
310
+ </View>
311
+ </AppShellProvider>
250
312
  );
251
313
  };
252
314
 
@@ -258,9 +320,21 @@ const AppShellComponent: React.FC<AppShellProps> = ({
258
320
  * overflow — or the sticky rail would stick to a box that never scrolls.
259
321
  */
260
322
  const documentRoot: WebCssStyle = { flexGrow: 1, minHeight: WEB_VIEWPORT_HEIGHT };
261
- // The page slides 272 right under `reveal`; `clip` keeps that from widening the
262
- // document with a horizontal scrollbar, without becoming a scroll container.
263
- const revealDocumentRoot: WebCssStyle = { ...documentRoot, overflow: WEB_OVERFLOW_CLIP };
323
+ // (Under `reveal` the document root also takes `overflow: clip`: the page slides
324
+ // 272 right, and `clip` keeps that from widening the document with a horizontal
325
+ // scrollbar without becoming a scroll container.)
326
+
327
+ /** Container mode: fill the parent, scroll inside. */
328
+ const containerRoot: WebCssStyle = { flex: 1, height: '100%', overflow: 'hidden' };
329
+
330
+ /**
331
+ * Fixed mode: exactly one screen — `100dvh` on web, the parent on native — and
332
+ * nothing scrolls; the content fills the height left under the header.
333
+ */
334
+ const fixedRoot: WebCssStyle =
335
+ Platform.OS === 'web'
336
+ ? { height: WEB_VIEWPORT_HEIGHT, overflow: 'hidden' }
337
+ : { flex: 1, height: '100%', overflow: 'hidden' };
264
338
 
265
339
  /** The in-flow rail, pinned to the viewport while the document scrolls under it. */
266
340
  function stickyRail(inset: number): WebCssStyle {
@@ -57,15 +57,17 @@ const AppShellHeaderComponent: React.FC<AppShellHeaderProps> = ({
57
57
  testID={testID ? `${testID}-menu` : undefined}
58
58
  />
59
59
  ) : null}
60
- <Text
61
- role="heading"
62
- aria-level={1}
63
- variant="title-2-medium"
64
- numberOfLines={1}
65
- style={{ paddingLeft: 4, paddingRight: 4, color: theme.colors.text }}
66
- >
67
- {title}
68
- </Text>
60
+ {title != null ? (
61
+ <Text
62
+ role="heading"
63
+ aria-level={1}
64
+ variant="title-2-medium"
65
+ numberOfLines={1}
66
+ style={{ paddingLeft: 4, paddingRight: 4, color: theme.colors.text }}
67
+ >
68
+ {title}
69
+ </Text>
70
+ ) : null}
69
71
  </View>
70
72
  {actions ? (
71
73
  <View
@@ -0,0 +1,37 @@
1
+ import React, { memo } from 'react';
2
+
3
+ import { Button } from '../button';
4
+ import { RiCloseLine, RiMenuLine } from '../icons/remix';
5
+ import { useAppShell } from './context';
6
+ import type { AppShellMenuButtonProps } from './types';
7
+
8
+ /**
9
+ * The hamburger that opens `AppShell`'s drawer, for a page that draws its own
10
+ * header. Renders nothing while the sidebar sits in flow, so it can stay in the
11
+ * markup at every width. A medium secondary icon button — the same one
12
+ * `AppShellHeader` shows — swapping to a close glyph while the drawer is open.
13
+ */
14
+ const AppShellMenuButtonComponent: React.FC<AppShellMenuButtonProps> = ({
15
+ accessibilityLabel = 'Open navigation',
16
+ style,
17
+ testID,
18
+ }) => {
19
+ const shell = useAppShell();
20
+ if (!shell.drawerAvailable) return null;
21
+ return (
22
+ <Button
23
+ variant="secondary"
24
+ size="medium"
25
+ iconOnly
26
+ leadingIcon={shell.drawerOpen ? RiCloseLine : RiMenuLine}
27
+ accessibilityLabel={accessibilityLabel}
28
+ aria-expanded={shell.drawerOpen}
29
+ onPress={shell.toggleDrawer}
30
+ style={style}
31
+ testID={testID}
32
+ />
33
+ );
34
+ };
35
+
36
+ export const AppShellMenuButton = memo(AppShellMenuButtonComponent);
37
+ AppShellMenuButton.displayName = 'AppShellMenuButton';
@@ -0,0 +1,35 @@
1
+ /**
2
+ * What `AppShell` tells the page inside it about its navigation drawer, so a
3
+ * page without a `title` — or with its own `header` — can still open it.
4
+ */
5
+ import { createContext, useContext } from 'react';
6
+
7
+ export interface AppShellContextValue {
8
+ /**
9
+ * Whether the sidebar is a drawer right now (below `lg`, or below `sm` for
10
+ * `variant: 'rail'`). `false` when it sits in flow or there is no sidebar —
11
+ * a menu button has nothing to open then.
12
+ */
13
+ drawerAvailable: boolean;
14
+ drawerOpen: boolean;
15
+ openDrawer: () => void;
16
+ closeDrawer: () => void;
17
+ toggleDrawer: () => void;
18
+ }
19
+
20
+ const AppShellContext = createContext<AppShellContextValue | null>(null);
21
+ AppShellContext.displayName = 'BloomAppShellContext';
22
+
23
+ export const AppShellProvider = AppShellContext.Provider;
24
+
25
+ /** The enclosing `AppShell`'s drawer. Throws outside one. */
26
+ export function useAppShell(): AppShellContextValue {
27
+ const value = useContext(AppShellContext);
28
+ if (!value) throw new Error('useAppShell must be used inside an <AppShell>.');
29
+ return value;
30
+ }
31
+
32
+ /** The enclosing `AppShell`'s drawer, or `null` outside one. */
33
+ export function useOptionalAppShell(): AppShellContextValue | null {
34
+ return useContext(AppShellContext);
35
+ }
@@ -1,11 +1,15 @@
1
1
  export { AppShell } from './AppShell';
2
2
  export { AppShellHeader } from './AppShellHeader';
3
+ export { AppShellMenuButton } from './AppShellMenuButton';
4
+ export { useAppShell } from './context';
5
+ export type { AppShellContextValue } from './context';
3
6
  export { NotificationBell } from './NotificationBell';
4
7
  export { ProOfferCard } from './ProOfferCard';
5
8
 
6
9
  export type {
7
10
  AppShellDrawer,
8
11
  AppShellHeaderProps,
12
+ AppShellMenuButtonProps,
9
13
  AppShellProps,
10
14
  NotificationBellProps,
11
15
  ProOfferCardProps,
@@ -21,14 +21,35 @@ export interface AppShellProps {
21
21
  */
22
22
  sidebar?: Omit<SidebarProps, 'mobile' | 'onClose' | 'flat'>;
23
23
  drawer?: AppShellDrawer;
24
- /** Heading over the content. */
24
+ /**
25
+ * Heading over the content. Optional: without it (and without `breadcrumb` /
26
+ * `actions`) the header still renders the menu button while the sidebar is a
27
+ * drawer, and nothing otherwise. A page with its own `header` opens the
28
+ * drawer with `AppShellMenuButton` or `useAppShell()`.
29
+ */
25
30
  title?: string;
26
31
  /** Breadcrumb trail above the heading (a `Breadcrumb`). */
27
32
  breadcrumb?: ReactNode;
28
33
  /** Header actions on the right (`NotificationBell`, buttons). */
29
34
  actions?: ReactNode;
30
- /** Replaces the whole header. */
35
+ /**
36
+ * Replaces the whole header. Put an `AppShellMenuButton` in it to keep the
37
+ * drawer reachable on narrow screens.
38
+ */
31
39
  header?: ReactNode;
40
+ /**
41
+ * A second column on the right of the page (a detail panel, activity, a
42
+ * chat). In flow from `asideFrom`; below it, stacked under the content or
43
+ * hidden (`asideCollapse`). Pinned like the sidebar — with document scroll
44
+ * it is sticky and scrolls its own overflow.
45
+ */
46
+ aside?: ReactNode;
47
+ /** The aside column's width. Defaults to 320. */
48
+ asideWidth?: number;
49
+ /** The breakpoint the aside sits beside the content from. Defaults to `xl` (1280). */
50
+ asideFrom?: 'md' | 'lg' | 'xl';
51
+ /** Below `asideFrom`: `stack` (default) renders it after the content, `hidden` drops it. */
52
+ asideCollapse?: 'stack' | 'hidden';
32
53
  children?: ReactNode;
33
54
  /** The content column's max width. Defaults to 1300. */
34
55
  contentMaxWidth?: number;
@@ -38,25 +59,35 @@ export interface AppShellProps {
38
59
  drawerOpen?: boolean;
39
60
  onDrawerOpenChange?: (open: boolean) => void;
40
61
  /**
41
- * What scrolls the page on WEB.
62
+ * What scrolls the page.
42
63
  *
43
- * - `document` (default) — the page grows the document and the browser
64
+ * - `document` (default) — WEB: the page grows the document and the browser
44
65
  * scrolls it, like a `ContentPanel` page: scroll restoration, the mobile
45
66
  * address bar collapsing, anchor links and `window.scrollTo` all work, and
46
- * the in-flow sidebar stays pinned (`position: sticky`).
67
+ * the in-flow sidebar stays pinned (`position: sticky`). Native has no
68
+ * document and treats it as `container`.
47
69
  * - `container` — the shell fills its parent and the page scrolls inside its
48
- * own `ScrollView`. For a shell embedded in a bounded box rather than
49
- * owning the page.
50
- *
51
- * Native has no document and always scrolls its own `ScrollView`.
70
+ * own `ScrollView`. For a shell embedded in a bounded box.
71
+ * - `fixed` — the shell is exactly one screen tall and NOTHING scrolls: the
72
+ * header stays, and the content fills the rest of the height (`flex: 1`),
73
+ * so the page owns its own scrolling — a chat, a map, a board. On web the
74
+ * frame is `100dvh`; on native it fills its parent.
52
75
  */
53
- scroll?: 'document' | 'container';
76
+ scroll?: 'document' | 'container' | 'fixed';
77
+ style?: StyleProp<ViewStyle>;
78
+ testID?: string;
79
+ }
80
+
81
+ export interface AppShellMenuButtonProps {
82
+ /** Defaults to `"Open navigation"`. */
83
+ accessibilityLabel?: string;
54
84
  style?: StyleProp<ViewStyle>;
55
85
  testID?: string;
56
86
  }
57
87
 
58
88
  export interface AppShellHeaderProps {
59
- title: string;
89
+ /** Optional: a header can be just the menu button, breadcrumb or actions. */
90
+ title?: string;
60
91
  breadcrumb?: ReactNode;
61
92
  actions?: ReactNode;
62
93
  /** Shows the hamburger (below `lg`); omit for no menu button. */