@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.
- package/docs/app-shell.mdx +47 -3
- package/docs/sidebar.mdx +17 -0
- package/lib/commonjs/app-shell/AppShell.js +248 -156
- package/lib/commonjs/app-shell/AppShell.js.map +1 -1
- package/lib/commonjs/app-shell/AppShellHeader.js +2 -2
- package/lib/commonjs/app-shell/AppShellHeader.js.map +1 -1
- package/lib/commonjs/app-shell/AppShellMenuButton.js +40 -0
- package/lib/commonjs/app-shell/AppShellMenuButton.js.map +1 -0
- package/lib/commonjs/app-shell/context.js +30 -0
- package/lib/commonjs/app-shell/context.js.map +1 -0
- package/lib/commonjs/app-shell/index.js +14 -0
- package/lib/commonjs/app-shell/index.js.map +1 -1
- package/lib/commonjs/sidebar/Sidebar.js +51 -17
- package/lib/commonjs/sidebar/Sidebar.js.map +1 -1
- package/lib/commonjs/sidebar/SidebarLogoView.js +124 -0
- package/lib/commonjs/sidebar/SidebarLogoView.js.map +1 -0
- package/lib/commonjs/sidebar/SidebarRail.js +16 -2
- package/lib/commonjs/sidebar/SidebarRail.js.map +1 -1
- package/lib/module/app-shell/AppShell.js +249 -157
- package/lib/module/app-shell/AppShell.js.map +1 -1
- package/lib/module/app-shell/AppShellHeader.js +2 -2
- package/lib/module/app-shell/AppShellHeader.js.map +1 -1
- package/lib/module/app-shell/AppShellMenuButton.js +35 -0
- package/lib/module/app-shell/AppShellMenuButton.js.map +1 -0
- package/lib/module/app-shell/context.js +23 -0
- package/lib/module/app-shell/context.js.map +1 -0
- package/lib/module/app-shell/index.js +2 -0
- package/lib/module/app-shell/index.js.map +1 -1
- package/lib/module/sidebar/Sidebar.js +51 -17
- package/lib/module/sidebar/Sidebar.js.map +1 -1
- package/lib/module/sidebar/SidebarLogoView.js +119 -0
- package/lib/module/sidebar/SidebarLogoView.js.map +1 -0
- package/lib/module/sidebar/SidebarRail.js +16 -2
- package/lib/module/sidebar/SidebarRail.js.map +1 -1
- package/lib/typescript/commonjs/app-shell/AppShell.d.ts.map +1 -1
- package/lib/typescript/commonjs/app-shell/AppShellHeader.d.ts.map +1 -1
- package/lib/typescript/commonjs/app-shell/AppShellMenuButton.d.ts +4 -0
- package/lib/typescript/commonjs/app-shell/AppShellMenuButton.d.ts.map +1 -0
- package/lib/typescript/commonjs/app-shell/context.d.ts +18 -0
- package/lib/typescript/commonjs/app-shell/context.d.ts.map +1 -0
- package/lib/typescript/commonjs/app-shell/index.d.ts +4 -1
- package/lib/typescript/commonjs/app-shell/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/app-shell/types.d.ts +41 -11
- package/lib/typescript/commonjs/app-shell/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/sidebar/Sidebar.d.ts.map +1 -1
- package/lib/typescript/commonjs/sidebar/SidebarLogoView.d.ts +6 -0
- package/lib/typescript/commonjs/sidebar/SidebarLogoView.d.ts.map +1 -0
- package/lib/typescript/commonjs/sidebar/SidebarRail.d.ts +3 -2
- package/lib/typescript/commonjs/sidebar/SidebarRail.d.ts.map +1 -1
- package/lib/typescript/commonjs/sidebar/index.d.ts +1 -1
- package/lib/typescript/commonjs/sidebar/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/sidebar/types.d.ts +36 -0
- package/lib/typescript/commonjs/sidebar/types.d.ts.map +1 -1
- package/lib/typescript/module/app-shell/AppShell.d.ts.map +1 -1
- package/lib/typescript/module/app-shell/AppShellHeader.d.ts.map +1 -1
- package/lib/typescript/module/app-shell/AppShellMenuButton.d.ts +4 -0
- package/lib/typescript/module/app-shell/AppShellMenuButton.d.ts.map +1 -0
- package/lib/typescript/module/app-shell/context.d.ts +18 -0
- package/lib/typescript/module/app-shell/context.d.ts.map +1 -0
- package/lib/typescript/module/app-shell/index.d.ts +4 -1
- package/lib/typescript/module/app-shell/index.d.ts.map +1 -1
- package/lib/typescript/module/app-shell/types.d.ts +41 -11
- package/lib/typescript/module/app-shell/types.d.ts.map +1 -1
- package/lib/typescript/module/sidebar/Sidebar.d.ts.map +1 -1
- package/lib/typescript/module/sidebar/SidebarLogoView.d.ts +6 -0
- package/lib/typescript/module/sidebar/SidebarLogoView.d.ts.map +1 -0
- package/lib/typescript/module/sidebar/SidebarRail.d.ts +3 -2
- package/lib/typescript/module/sidebar/SidebarRail.d.ts.map +1 -1
- package/lib/typescript/module/sidebar/index.d.ts +1 -1
- package/lib/typescript/module/sidebar/index.d.ts.map +1 -1
- package/lib/typescript/module/sidebar/types.d.ts +36 -0
- package/lib/typescript/module/sidebar/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/app-shell/AppShell.tsx +181 -107
- package/src/app-shell/AppShellHeader.tsx +11 -9
- package/src/app-shell/AppShellMenuButton.tsx +37 -0
- package/src/app-shell/context.ts +35 -0
- package/src/app-shell/index.ts +4 -0
- package/src/app-shell/types.ts +42 -11
- package/src/sidebar/Sidebar.tsx +42 -22
- package/src/sidebar/SidebarLogoView.tsx +92 -0
- package/src/sidebar/SidebarRail.tsx +9 -1
- package/src/sidebar/index.ts +1 -0
- package/src/sidebar/types.ts +38 -0
package/src/sidebar/Sidebar.tsx
CHANGED
|
@@ -33,6 +33,7 @@ import { SidebarModeSwitcher } from './SidebarModeSwitcher';
|
|
|
33
33
|
import { SidebarPlanCard } from './SidebarPlanCard';
|
|
34
34
|
import { SidebarRail } from './SidebarRail';
|
|
35
35
|
import { SidebarTeamMenu } from './SidebarTeamMenu';
|
|
36
|
+
import { SidebarLogoView } from './SidebarLogoView';
|
|
36
37
|
import { SidebarUserMenu } from './SidebarUserMenu';
|
|
37
38
|
import type { SidebarNavItem, SidebarProps } from './types';
|
|
38
39
|
|
|
@@ -153,6 +154,7 @@ const SidebarPanel: React.FC<SidebarProps> = ({
|
|
|
153
154
|
searchLabel = 'Quick Search',
|
|
154
155
|
searchPlaceholder,
|
|
155
156
|
noResultsLabel = 'No results',
|
|
157
|
+
logo,
|
|
156
158
|
account,
|
|
157
159
|
team,
|
|
158
160
|
tree,
|
|
@@ -476,7 +478,45 @@ const SidebarPanel: React.FC<SidebarProps> = ({
|
|
|
476
478
|
/>
|
|
477
479
|
) : null;
|
|
478
480
|
|
|
479
|
-
const
|
|
481
|
+
const accountMenu = account ? (
|
|
482
|
+
<View
|
|
483
|
+
style={{
|
|
484
|
+
minWidth: 0,
|
|
485
|
+
flexShrink: 1,
|
|
486
|
+
display: flatMobile && searchActive ? 'none' : 'flex',
|
|
487
|
+
maxWidth: 190,
|
|
488
|
+
}}
|
|
489
|
+
>
|
|
490
|
+
<SidebarUserMenu
|
|
491
|
+
account={account}
|
|
492
|
+
collapsed={collapsed}
|
|
493
|
+
suppressHover={suppressUserHover}
|
|
494
|
+
onHoverSuppressionEnd={() => setSuppressUserHover(false)}
|
|
495
|
+
avatarBackground={flat ? palette.avatarFlat : undefined}
|
|
496
|
+
testID="sidebar-account"
|
|
497
|
+
/>
|
|
498
|
+
</View>
|
|
499
|
+
) : null;
|
|
500
|
+
|
|
501
|
+
// With a logo the brand leads the header and the account switcher gets its
|
|
502
|
+
// own row under it; collapsed, the mark sits on top of the expand control.
|
|
503
|
+
const headerRow = logo ? (
|
|
504
|
+
<>
|
|
505
|
+
<View
|
|
506
|
+
style={
|
|
507
|
+
collapsed
|
|
508
|
+
? { width: '100%', flexDirection: 'column', alignItems: 'flex-start', justifyContent: 'center', gap: 10 }
|
|
509
|
+
: { width: '100%', flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 8 }
|
|
510
|
+
}
|
|
511
|
+
>
|
|
512
|
+
<View style={{ minWidth: 0, flexShrink: 1, display: flatMobile && searchActive ? 'none' : 'flex' }}>
|
|
513
|
+
<SidebarLogoView logo={logo} collapsed={collapsed} testID="sidebar-logo" />
|
|
514
|
+
</View>
|
|
515
|
+
{headerControl}
|
|
516
|
+
</View>
|
|
517
|
+
{accountMenu}
|
|
518
|
+
</>
|
|
519
|
+
) : (
|
|
480
520
|
<View
|
|
481
521
|
style={
|
|
482
522
|
collapsed
|
|
@@ -484,27 +524,7 @@ const SidebarPanel: React.FC<SidebarProps> = ({
|
|
|
484
524
|
: { width: '100%', flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }
|
|
485
525
|
}
|
|
486
526
|
>
|
|
487
|
-
{
|
|
488
|
-
<View
|
|
489
|
-
style={{
|
|
490
|
-
minWidth: 0,
|
|
491
|
-
flexShrink: 1,
|
|
492
|
-
display: flatMobile && searchActive ? 'none' : 'flex',
|
|
493
|
-
maxWidth: 190,
|
|
494
|
-
}}
|
|
495
|
-
>
|
|
496
|
-
<SidebarUserMenu
|
|
497
|
-
account={account}
|
|
498
|
-
collapsed={collapsed}
|
|
499
|
-
suppressHover={suppressUserHover}
|
|
500
|
-
onHoverSuppressionEnd={() => setSuppressUserHover(false)}
|
|
501
|
-
avatarBackground={flat ? palette.avatarFlat : undefined}
|
|
502
|
-
testID="sidebar-account"
|
|
503
|
-
/>
|
|
504
|
-
</View>
|
|
505
|
-
) : (
|
|
506
|
-
<View />
|
|
507
|
-
)}
|
|
527
|
+
{accountMenu ?? <View />}
|
|
508
528
|
{headerControl}
|
|
509
529
|
</View>
|
|
510
530
|
);
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
import { Pressable, View, type GestureResponderEvent } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import type { WebCssStyle } from '../styles/web-view-style';
|
|
5
|
+
import { Text } from '../typography';
|
|
6
|
+
import { useSidebarPalette } from './palette';
|
|
7
|
+
import { Collapsible, IS_WEB, useSidebarWebCss } from './parts';
|
|
8
|
+
import type { SidebarLogoViewProps } from './types';
|
|
9
|
+
|
|
10
|
+
/** The mark's box: the collapsed column's width, and the header row's height. */
|
|
11
|
+
export const SIDEBAR_LOGO_SIZE = 36;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The brand at the top of the sidebar: a mark and a wordmark.
|
|
15
|
+
*
|
|
16
|
+
* mark centred in a 36 × 36 box — the collapsed column — so it stays
|
|
17
|
+
* put while the rail morphs; sized by the caller (a 24–28px glyph
|
|
18
|
+
* reads right)
|
|
19
|
+
* wordmark 8 to the right, in a collapse slot; a string renders as
|
|
20
|
+
* headline-semibold text-primary, anything else as given (an SVG
|
|
21
|
+
* wordmark, an image)
|
|
22
|
+
* link with `href` a real anchor on web, with `onPress` a button; the
|
|
23
|
+
* focus ring is the sidebar's. Without either it is decoration
|
|
24
|
+
* and stays out of the tab order
|
|
25
|
+
*/
|
|
26
|
+
const SidebarLogoViewComponent: React.FC<SidebarLogoViewProps> = ({
|
|
27
|
+
logo,
|
|
28
|
+
collapsed = false,
|
|
29
|
+
showWordmark = true,
|
|
30
|
+
testID,
|
|
31
|
+
}) => {
|
|
32
|
+
const palette = useSidebarPalette();
|
|
33
|
+
useSidebarWebCss();
|
|
34
|
+
const { icon, wordmark, href, onPress, accessibilityLabel } = logo;
|
|
35
|
+
const label = accessibilityLabel ?? (typeof wordmark === 'string' ? wordmark : undefined);
|
|
36
|
+
|
|
37
|
+
const content = (
|
|
38
|
+
<View style={{ flexDirection: 'row', alignItems: 'center', gap: icon != null && wordmark != null ? 8 : 0, minWidth: 0 }}>
|
|
39
|
+
{icon != null ? (
|
|
40
|
+
<View
|
|
41
|
+
style={{ width: SIDEBAR_LOGO_SIZE, height: SIDEBAR_LOGO_SIZE, alignItems: 'center', justifyContent: 'center', flexShrink: 0 }}
|
|
42
|
+
testID={testID ? `${testID}-icon` : undefined}
|
|
43
|
+
>
|
|
44
|
+
{icon}
|
|
45
|
+
</View>
|
|
46
|
+
) : null}
|
|
47
|
+
{wordmark != null && showWordmark ? (
|
|
48
|
+
<Collapsible collapsed={collapsed}>
|
|
49
|
+
<View style={{ minHeight: SIDEBAR_LOGO_SIZE, justifyContent: 'center' }} testID={testID ? `${testID}-wordmark` : undefined}>
|
|
50
|
+
{typeof wordmark === 'string' ? (
|
|
51
|
+
<Text variant="headline-semibold" numberOfLines={1} style={{ color: palette.text }}>
|
|
52
|
+
{wordmark}
|
|
53
|
+
</Text>
|
|
54
|
+
) : (
|
|
55
|
+
wordmark
|
|
56
|
+
)}
|
|
57
|
+
</View>
|
|
58
|
+
</Collapsible>
|
|
59
|
+
) : null}
|
|
60
|
+
</View>
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
if (!href && !onPress) {
|
|
64
|
+
return (
|
|
65
|
+
<View accessibilityLabel={label} role={label ? 'img' : undefined} style={{ minWidth: 0, flexShrink: 1 }} testID={testID}>
|
|
66
|
+
{content}
|
|
67
|
+
</View>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const ringStyle: WebCssStyle = { minWidth: 0, flexShrink: 1, borderRadius: 10, '--bloom-sidebar-ring': palette.ring };
|
|
72
|
+
return (
|
|
73
|
+
<Pressable
|
|
74
|
+
{...(IS_WEB ? { dataSet: { bloomSidebar: 'ring' }, ...(href ? { href } : null) } : {})}
|
|
75
|
+
role={href ? 'link' : 'button'}
|
|
76
|
+
accessibilityLabel={label}
|
|
77
|
+
onPress={(event: GestureResponderEvent) => {
|
|
78
|
+
if (!onPress) return;
|
|
79
|
+
// A router takes over the anchor's navigation.
|
|
80
|
+
if (IS_WEB && href) event.preventDefault();
|
|
81
|
+
onPress();
|
|
82
|
+
}}
|
|
83
|
+
style={ringStyle}
|
|
84
|
+
testID={testID}
|
|
85
|
+
>
|
|
86
|
+
{content}
|
|
87
|
+
</Pressable>
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const SidebarLogoView = memo(SidebarLogoViewComponent);
|
|
92
|
+
SidebarLogoView.displayName = 'SidebarLogoView';
|
|
@@ -4,6 +4,7 @@ import { ScrollView, View } from 'react-native';
|
|
|
4
4
|
import { Badge } from '../badge';
|
|
5
5
|
import { useSidebarPalette } from './palette';
|
|
6
6
|
import { IS_WEB } from './parts';
|
|
7
|
+
import { SidebarLogoView } from './SidebarLogoView';
|
|
7
8
|
import { SidebarRailItem } from './SidebarRailItem';
|
|
8
9
|
import type { SidebarNavItem, SidebarProps } from './types';
|
|
9
10
|
|
|
@@ -16,12 +17,14 @@ export const SIDEBAR_RAIL_WIDTH = 80;
|
|
|
16
17
|
* panel 80 wide, full height, background-full, no chrome
|
|
17
18
|
* items centred vertically in a scroller (px 8, py 24, gap 8), one
|
|
18
19
|
* `SidebarRailItem` per row
|
|
20
|
+
* logo the mark only, centred at the top (pt 24), when `logo` is given
|
|
19
21
|
* secondary pinned to the foot (px 8, pb 24, gap 8)
|
|
20
22
|
*
|
|
21
|
-
* The rail carries navigation only: account, team, plan, tree, quick search and
|
|
23
|
+
* The rail carries navigation and the logo's mark only: account, team, plan, tree, quick search and
|
|
22
24
|
* the theme toggle belong to the panel variant and are not rendered here.
|
|
23
25
|
*/
|
|
24
26
|
export function SidebarRail({
|
|
27
|
+
logo,
|
|
25
28
|
items = [],
|
|
26
29
|
secondaryItems = [],
|
|
27
30
|
selected,
|
|
@@ -73,6 +76,11 @@ export function SidebarRail({
|
|
|
73
76
|
style,
|
|
74
77
|
]}
|
|
75
78
|
>
|
|
79
|
+
{logo ? (
|
|
80
|
+
<View style={{ flexShrink: 0, alignItems: 'center', paddingTop: 24 }}>
|
|
81
|
+
<SidebarLogoView logo={logo} showWordmark={false} testID="sidebar-logo" />
|
|
82
|
+
</View>
|
|
83
|
+
) : null}
|
|
76
84
|
<ScrollView
|
|
77
85
|
{...(IS_WEB ? { dataSet: { bloomSidebarScroll: 'none' } } : {})}
|
|
78
86
|
style={{ flex: 1 }}
|
package/src/sidebar/index.ts
CHANGED
package/src/sidebar/types.ts
CHANGED
|
@@ -128,6 +128,37 @@ export interface SidebarAccountUser {
|
|
|
128
128
|
onPress?: () => void;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
/**
|
|
132
|
+
* The brand at the top of the sidebar. Give a mark, a wordmark or both.
|
|
133
|
+
*/
|
|
134
|
+
export interface SidebarLogo {
|
|
135
|
+
/**
|
|
136
|
+
* The mark (a logo glyph, an SVG, an image). Centred in a 36 × 36 box and
|
|
137
|
+
* kept while the sidebar is collapsed; size it yourself — 24–28px reads right.
|
|
138
|
+
*/
|
|
139
|
+
icon?: ReactNode;
|
|
140
|
+
/**
|
|
141
|
+
* The wordmark beside the mark, hidden while collapsed. A string renders as
|
|
142
|
+
* the product name in `headline-semibold`; anything else renders as given.
|
|
143
|
+
*/
|
|
144
|
+
wordmark?: ReactNode;
|
|
145
|
+
/** Link target (a real anchor on web). On native, pass `onPress` too. */
|
|
146
|
+
href?: string;
|
|
147
|
+
/** Called on press — a router's navigation to home, say. */
|
|
148
|
+
onPress?: () => void;
|
|
149
|
+
/** The logo's accessible name. Defaults to a string `wordmark`. */
|
|
150
|
+
accessibilityLabel?: string;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface SidebarLogoViewProps {
|
|
154
|
+
logo: SidebarLogo;
|
|
155
|
+
/** Collapses the wordmark, keeping the mark. */
|
|
156
|
+
collapsed?: boolean;
|
|
157
|
+
/** Renders the mark only (the navigation rail). Defaults to true. */
|
|
158
|
+
showWordmark?: boolean;
|
|
159
|
+
testID?: string;
|
|
160
|
+
}
|
|
161
|
+
|
|
131
162
|
/** The account switcher at the top of the rail and the menu it opens. */
|
|
132
163
|
export interface SidebarAccount {
|
|
133
164
|
name: string;
|
|
@@ -210,6 +241,13 @@ export interface SidebarProps {
|
|
|
210
241
|
searchPlaceholder?: string;
|
|
211
242
|
noResultsLabel?: string;
|
|
212
243
|
|
|
244
|
+
/**
|
|
245
|
+
* The brand at the top: a mark and/or a wordmark. In the panel it takes the
|
|
246
|
+
* header row beside the collapse control — the account switcher, if given
|
|
247
|
+
* too, moves to its own row under it. The rail shows the mark above its
|
|
248
|
+
* items.
|
|
249
|
+
*/
|
|
250
|
+
logo?: SidebarLogo;
|
|
213
251
|
account?: SidebarAccount;
|
|
214
252
|
team?: SidebarTeam;
|
|
215
253
|
|