@oxy.so/bloom 2.5.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 +55 -1
- package/docs/sidebar.mdx +17 -0
- package/lib/commonjs/app-shell/AppShell.js +294 -135
- 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/commonjs/styles/web-view-style.js +25 -1
- package/lib/commonjs/styles/web-view-style.js.map +1 -1
- package/lib/module/app-shell/AppShell.js +296 -137
- 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/module/styles/web-view-style.js +23 -0
- package/lib/module/styles/web-view-style.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 +47 -3
- 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/commonjs/styles/web-view-style.d.ts +19 -0
- package/lib/typescript/commonjs/styles/web-view-style.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 +47 -3
- 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/lib/typescript/module/styles/web-view-style.d.ts +19 -0
- package/lib/typescript/module/styles/web-view-style.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/app-shell/AppShell.tsx +231 -90
- 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 +48 -3
- 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/styles/web-view-style.ts +23 -0
package/src/app-shell/types.ts
CHANGED
|
@@ -21,14 +21,35 @@ export interface AppShellProps {
|
|
|
21
21
|
*/
|
|
22
22
|
sidebar?: Omit<SidebarProps, 'mobile' | 'onClose' | 'flat'>;
|
|
23
23
|
drawer?: AppShellDrawer;
|
|
24
|
-
/**
|
|
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
|
-
/**
|
|
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;
|
|
@@ -37,12 +58,36 @@ export interface AppShellProps {
|
|
|
37
58
|
/** Controlled drawer state (below `lg`). */
|
|
38
59
|
drawerOpen?: boolean;
|
|
39
60
|
onDrawerOpenChange?: (open: boolean) => void;
|
|
61
|
+
/**
|
|
62
|
+
* What scrolls the page.
|
|
63
|
+
*
|
|
64
|
+
* - `document` (default) — WEB: the page grows the document and the browser
|
|
65
|
+
* scrolls it, like a `ContentPanel` page: scroll restoration, the mobile
|
|
66
|
+
* address bar collapsing, anchor links and `window.scrollTo` all work, and
|
|
67
|
+
* the in-flow sidebar stays pinned (`position: sticky`). Native has no
|
|
68
|
+
* document and treats it as `container`.
|
|
69
|
+
* - `container` — the shell fills its parent and the page scrolls inside its
|
|
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.
|
|
75
|
+
*/
|
|
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;
|
|
40
84
|
style?: StyleProp<ViewStyle>;
|
|
41
85
|
testID?: string;
|
|
42
86
|
}
|
|
43
87
|
|
|
44
88
|
export interface AppShellHeaderProps {
|
|
45
|
-
|
|
89
|
+
/** Optional: a header can be just the menu button, breadcrumb or actions. */
|
|
90
|
+
title?: string;
|
|
46
91
|
breadcrumb?: ReactNode;
|
|
47
92
|
actions?: ReactNode;
|
|
48
93
|
/** Shows the hamburger (below `lg`); omit for no menu button. */
|
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
|
|
|
@@ -30,6 +30,29 @@ export const WEB_POSITION_FIXED = 'fixed' as ViewStyle['position'];
|
|
|
30
30
|
*/
|
|
31
31
|
export const WEB_POSITION_STICKY = 'sticky' as ViewStyle['position'];
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* One viewport of height (`100dvh`), and one viewport minus a vertical inset,
|
|
35
|
+
* typed for React Native's `ViewStyle`. Same kind of gap as
|
|
36
|
+
* {@link WEB_POSITION_FIXED}: RN types lengths as a number or a percentage,
|
|
37
|
+
* while react-native-web passes any CSS length through. A percentage cannot say
|
|
38
|
+
* this in a page that scrolls the DOCUMENT — a percentage height needs a
|
|
39
|
+
* definite ancestor height, and an auto-height document-flow ancestor never has
|
|
40
|
+
* one. `dvh` rather than `vh` so a mobile browser's collapsing toolbar is not
|
|
41
|
+
* counted as viewport.
|
|
42
|
+
*/
|
|
43
|
+
export const WEB_VIEWPORT_HEIGHT = '100dvh' as ViewStyle['height'];
|
|
44
|
+
export function webViewportHeightMinus(px: number): ViewStyle['height'] {
|
|
45
|
+
return `calc(100dvh - ${px}px)` as ViewStyle['height'];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* `overflow: clip`, typed for React Native's `ViewStyle`. Clips like `hidden`
|
|
50
|
+
* without making the element a SCROLL CONTAINER — so a `position: sticky`
|
|
51
|
+
* descendant still sticks to the document instead of to a box that never
|
|
52
|
+
* scrolls.
|
|
53
|
+
*/
|
|
54
|
+
export const WEB_OVERFLOW_CLIP = 'clip' as ViewStyle['overflow'];
|
|
55
|
+
|
|
33
56
|
/**
|
|
34
57
|
* A `ViewStyle` that may ALSO carry CSS react-native-web forwards straight to the
|
|
35
58
|
* DOM node but React Native does not model at all.
|