@12-apps/ui 6.72.0 → 6.73.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/components-catalog.md +1 -1
- package/dist/_internal/components/index.js +7 -7
- package/dist/_internal/components/navigation/SectionNav/SectionNav.bar.js +5 -4
- package/dist/_internal/components/navigation/SectionNav/SectionNav.js +8 -7
- package/dist/_internal/components/navigation/SectionNav/SectionNav.parts.js +8 -3
- package/dist/_internal/components/navigation/SectionNav/SectionNav.primary.js +3 -2
- package/dist/_internal/components/navigation/SectionNav/SectionNav.rail.js +4 -3
- package/dist/_internal/components/navigation/SectionNav/SectionNav.railCreate.js +3 -2
- package/dist/_internal/components/navigation/SectionNav/SectionNav.sheet.js +3 -2
- package/dist/_internal/components/navigation/index.js +8 -7
- package/dist/{chunk-XS4NQ6LD.js → chunk-23LPXHR2.js} +61 -35
- package/dist/chunk-23LPXHR2.js.map +1 -0
- package/dist/{chunk-WP7KPWCP.js → chunk-24HHUCWB.js} +14 -2
- package/dist/chunk-24HHUCWB.js.map +1 -0
- package/dist/{chunk-WY7FR7I4.js → chunk-ILJ3FXIC.js} +17 -8
- package/dist/chunk-ILJ3FXIC.js.map +1 -0
- package/dist/{chunk-VI2IXBOO.js → chunk-KPEKD5SG.js} +24 -13
- package/dist/chunk-KPEKD5SG.js.map +1 -0
- package/dist/{chunk-2STYL5PF.js → chunk-NM46HQSW.js} +2 -2
- package/dist/{chunk-LWQGIN2M.js → chunk-NQP72RTD.js} +9 -6
- package/dist/chunk-NQP72RTD.js.map +1 -0
- package/dist/{chunk-OBGUD2PG.js → chunk-SNWCT6JN.js} +91 -42
- package/dist/chunk-SNWCT6JN.js.map +1 -0
- package/dist/navigation/SectionNav.js +8 -7
- package/dist/types/components/navigation/SectionNav/SectionNav.bar.d.ts +6 -2
- package/dist/types/components/navigation/SectionNav/SectionNav.bar.d.ts.map +1 -1
- package/dist/types/components/navigation/SectionNav/SectionNav.d.ts +4 -1
- package/dist/types/components/navigation/SectionNav/SectionNav.d.ts.map +1 -1
- package/dist/types/components/navigation/SectionNav/SectionNav.parts.d.ts +12 -1
- package/dist/types/components/navigation/SectionNav/SectionNav.parts.d.ts.map +1 -1
- package/dist/types/components/navigation/SectionNav/SectionNav.primary.d.ts +7 -1
- package/dist/types/components/navigation/SectionNav/SectionNav.primary.d.ts.map +1 -1
- package/dist/types/components/navigation/SectionNav/SectionNav.rail.d.ts +3 -2
- package/dist/types/components/navigation/SectionNav/SectionNav.rail.d.ts.map +1 -1
- package/dist/types/components/navigation/SectionNav/SectionNav.railCreate.d.ts +3 -1
- package/dist/types/components/navigation/SectionNav/SectionNav.railCreate.d.ts.map +1 -1
- package/dist/types/components/navigation/SectionNav/SectionNav.types.d.ts +12 -0
- package/dist/types/components/navigation/SectionNav/SectionNav.types.d.ts.map +1 -1
- package/dist/types/components/navigation/SectionNav/index.d.ts +1 -0
- package/dist/types/components/navigation/SectionNav/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/navigation/SectionNav/SectionNav.bar.tsx +77 -29
- package/src/components/navigation/SectionNav/SectionNav.md +24 -3
- package/src/components/navigation/SectionNav/SectionNav.parts.tsx +19 -1
- package/src/components/navigation/SectionNav/SectionNav.primary.tsx +39 -11
- package/src/components/navigation/SectionNav/SectionNav.rail.tsx +90 -35
- package/src/components/navigation/SectionNav/SectionNav.railCreate.tsx +23 -5
- package/src/components/navigation/SectionNav/SectionNav.tsx +6 -0
- package/src/components/navigation/SectionNav/SectionNav.types.ts +12 -0
- package/src/components/navigation/SectionNav/index.ts +1 -0
- package/dist/chunk-LWQGIN2M.js.map +0 -1
- package/dist/chunk-OBGUD2PG.js.map +0 -1
- package/dist/chunk-VI2IXBOO.js.map +0 -1
- package/dist/chunk-WP7KPWCP.js.map +0 -1
- package/dist/chunk-WY7FR7I4.js.map +0 -1
- package/dist/chunk-XS4NQ6LD.js.map +0 -1
- /package/dist/{chunk-2STYL5PF.js.map → chunk-NM46HQSW.js.map} +0 -0
|
@@ -6,9 +6,10 @@ import type { SectionNavProps } from './SectionNav.types';
|
|
|
6
6
|
* `primary` action as a row, then `more` listed in full.
|
|
7
7
|
*
|
|
8
8
|
* It fills the column the host gives it and scrolls on its own, like the
|
|
9
|
-
* sidebar it stands in for.
|
|
9
|
+
* sidebar it stands in for. `compact` draws every row as its icon for a
|
|
10
|
+
* column 64px wide; the words stay the rows' names.
|
|
10
11
|
*/
|
|
11
|
-
export declare function SectionNavRail({ label, destinations, primary, more, back, heading, linkComponent, copy, dataTestId, }: Required<Pick<SectionNavProps, 'label' | 'destinations' | 'copy' | 'dataTestId'>> & Pick<SectionNavProps, 'primary' | 'more' | 'back' | 'heading'> & {
|
|
12
|
+
export declare function SectionNavRail({ label, destinations, primary, more, back, heading, linkComponent, copy, dataTestId, compact, }: Required<Pick<SectionNavProps, 'label' | 'destinations' | 'copy' | 'dataTestId'>> & Pick<SectionNavProps, 'primary' | 'more' | 'back' | 'heading' | 'compact'> & {
|
|
12
13
|
linkComponent: ElementType | undefined;
|
|
13
14
|
}): React.JSX.Element;
|
|
14
15
|
//# sourceMappingURL=SectionNav.rail.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SectionNav.rail.d.ts","sourceRoot":"","sources":["../../../../../src/components/navigation/SectionNav/SectionNav.rail.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SectionNav.rail.d.ts","sourceRoot":"","sources":["../../../../../src/components/navigation/SectionNav/SectionNav.rail.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAa,MAAM,OAAO,CAAC;AAkBpD,OAAO,KAAK,EAKV,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAoR5B;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,YAAY,EACZ,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,aAAa,EACb,IAAI,EACJ,UAAU,EACV,OAAe,GAChB,EAAE,QAAQ,CAAC,IAAI,CAAC,eAAe,EAAE,OAAO,GAAG,cAAc,GAAG,MAAM,GAAG,YAAY,CAAC,CAAC,GAClF,IAAI,CAAC,eAAe,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC,GAAG;IAC3E,aAAa,EAAE,WAAW,GAAG,SAAS,CAAC;CACxC,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAsDtB"}
|
|
@@ -15,10 +15,12 @@ import type { SectionNavMenu } from './SectionNav.types';
|
|
|
15
15
|
* outside click. Choosing an entry closes it too, and the entry's link or act
|
|
16
16
|
* takes over.
|
|
17
17
|
*/
|
|
18
|
-
export declare function RailCreateMenu({ menu, linkComponent, copy, testId, }: {
|
|
18
|
+
export declare function RailCreateMenu({ menu, linkComponent, copy, testId, compact, }: {
|
|
19
19
|
menu: SectionNavMenu;
|
|
20
20
|
linkComponent: ElementType | undefined;
|
|
21
21
|
copy: SectionNavCopy;
|
|
22
22
|
testId: string;
|
|
23
|
+
/** The button as its icon only — the label stays its name and its tooltip. */
|
|
24
|
+
compact?: boolean;
|
|
23
25
|
}): React.JSX.Element;
|
|
24
26
|
//# sourceMappingURL=SectionNav.railCreate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SectionNav.railCreate.d.ts","sourceRoot":"","sources":["../../../../../src/components/navigation/SectionNav/SectionNav.railCreate.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAmB,KAAK,WAAW,EAAkB,MAAM,OAAO,CAAC;AAE1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAIpD,OAAO,KAAK,EAAmB,cAAc,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"SectionNav.railCreate.d.ts","sourceRoot":"","sources":["../../../../../src/components/navigation/SectionNav/SectionNav.railCreate.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAmB,KAAK,WAAW,EAAkB,MAAM,OAAO,CAAC;AAE1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAIpD,OAAO,KAAK,EAAmB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAkE1E;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,EAC7B,IAAI,EACJ,aAAa,EACb,IAAI,EACJ,MAAM,EACN,OAAe,GAChB,EAAE;IACD,IAAI,EAAE,cAAc,CAAC;IACrB,aAAa,EAAE,WAAW,GAAG,SAAS,CAAC;IACvC,IAAI,EAAE,cAAc,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,8EAA8E;IAC9E,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA4DpB"}
|
|
@@ -178,5 +178,17 @@ export interface SectionNavProps {
|
|
|
178
178
|
copy: SectionNavCopy;
|
|
179
179
|
/** Prefix for every `data-testid`. Defaults to `"section-nav"`. */
|
|
180
180
|
dataTestId?: string;
|
|
181
|
+
/**
|
|
182
|
+
* Icons only, a size down — for a host that folds its chrome so the content
|
|
183
|
+
* gets the screen (a "focus mode"). Every label stays its control's
|
|
184
|
+
* accessible name and `title`; nothing is removed, only drawn smaller.
|
|
185
|
+
*
|
|
186
|
+
* `bar` — 48px instead of 60, the raised button 40px instead of 52, no
|
|
187
|
+
* captions; `sectionNavBarInset(theme, { compact: true })` is its inset.
|
|
188
|
+
* `rail` — every row, the way back and the create button as their icon only,
|
|
189
|
+
* headings out of sight, for a column 64px wide (the host sets the width).
|
|
190
|
+
* Defaults to `false`.
|
|
191
|
+
*/
|
|
192
|
+
compact?: boolean;
|
|
181
193
|
}
|
|
182
194
|
//# sourceMappingURL=SectionNav.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SectionNav.types.d.ts","sourceRoot":"","sources":["../../../../../src/components/navigation/SectionNav/SectionNav.types.ts"],"names":[],"mappings":"AAAA,O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c,CAAC;IACtB,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,aAAa,CAAC,EAAE,WAAW,CAAC;IAC5B,kEAAkE;IAClE,IAAI,EAAE,cAAc,CAAC;IACrB,mEAAmE;IACnE,UAAU,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"SectionNav.types.d.ts","sourceRoot":"","sources":["../../../../../src/components/navigation/SectionNav/SectionNav.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,iFAAiF;AACjF,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,GAAG,CAAC;AAE3C;;;;;;;;GAQG;AACH,MAAM,WAAW,qBAAqB;IACpC,+DAA+D;IAC/D,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,SAAS,C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AAM,WAAW,eAAe;IAC9B;;;;;;;OAOG;IACH,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC;IACvB,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,qBAAqB,EAAE,CAAC;IACtC;;;OAGG;IACH,OAAO,CAAC,EAAE,cAAc,GAAG,gBAAgB,CAAC;IAC5C,6EAA6E;IAC7E,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,kDAAkD;IAClD,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,aAAa,CAAC,EAAE,WAAW,CAAC;IAC5B,kEAAkE;IAClE,IAAI,EAAE,cAAc,CAAC;IACrB,mEAAmE;IACnE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { SectionNav } from './SectionNav';
|
|
2
2
|
export { sectionNavBarInset } from './SectionNav.bar';
|
|
3
|
+
export type { SectionNavBarOptions } from './SectionNav.bar';
|
|
3
4
|
export { RaisedActionButton } from './SectionNav.primary';
|
|
4
5
|
export type { RaisedActionButtonProps } from './SectionNav.primary';
|
|
5
6
|
export type { SectionNavAction, SectionNavBack, SectionNavBadge, SectionNavDestination, SectionNavEntry, SectionNavGroup, SectionNavMenu, SectionNavProps, } from './SectionNav.types';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/navigation/SectionNav/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACpE,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,eAAe,EACf,cAAc,EACd,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/navigation/SectionNav/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,YAAY,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACpE,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,eAAe,EACf,cAAc,EACd,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
package/package.json
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
NOT_LIVE,
|
|
15
15
|
SlotIcon,
|
|
16
16
|
controlProps,
|
|
17
|
+
useMounted,
|
|
17
18
|
destinationControl,
|
|
18
19
|
focusRing,
|
|
19
20
|
} from './SectionNav.parts';
|
|
@@ -24,16 +25,24 @@ import type { SectionNavAction, SectionNavBadge, SectionNavDestination, SectionN
|
|
|
24
25
|
/** Which of the bar's two menus is open, if any. */
|
|
25
26
|
type OpenMenu = 'primary' | 'more' | null;
|
|
26
27
|
|
|
27
|
-
/**
|
|
28
|
-
|
|
28
|
+
/**
|
|
29
|
+
* The bar's height above the safe area — tall enough for an icon over a label;
|
|
30
|
+
* a compact bar holds the icon alone.
|
|
31
|
+
*/
|
|
32
|
+
const barHeight = (theme: Parameters<typeof rem>[0], compact = false): string => rem(theme, compact ? 48 : 60);
|
|
33
|
+
|
|
34
|
+
/** How the bar is drawn — `compact` is `SectionNavProps.compact`. */
|
|
35
|
+
export interface SectionNavBarOptions {
|
|
36
|
+
compact?: boolean;
|
|
37
|
+
}
|
|
29
38
|
|
|
30
39
|
/**
|
|
31
40
|
* The bar's full height on screen, the safe area included — where its sheets
|
|
32
41
|
* stop, and what a host reserves at the foot of its content so nothing it
|
|
33
42
|
* floats (a toast, a receipt) lands under the bar.
|
|
34
43
|
*/
|
|
35
|
-
export function sectionNavBarInset(theme: Parameters<typeof rem>[0]): string {
|
|
36
|
-
return `calc(${barHeight(theme)} + env(safe-area-inset-bottom))`;
|
|
44
|
+
export function sectionNavBarInset(theme: Parameters<typeof rem>[0], options: SectionNavBarOptions = {}): string {
|
|
45
|
+
return `calc(${barHeight(theme, options.compact === true)} + env(safe-area-inset-bottom))`;
|
|
37
46
|
}
|
|
38
47
|
|
|
39
48
|
/**
|
|
@@ -62,6 +71,7 @@ function Slot({
|
|
|
62
71
|
control,
|
|
63
72
|
expanded,
|
|
64
73
|
loading = false,
|
|
74
|
+
compact = false,
|
|
65
75
|
}: {
|
|
66
76
|
label: string;
|
|
67
77
|
icon: ReactNode;
|
|
@@ -73,17 +83,21 @@ function Slot({
|
|
|
73
83
|
control: Record<string, unknown>;
|
|
74
84
|
expanded?: boolean;
|
|
75
85
|
loading?: boolean;
|
|
86
|
+
/** Icon only: the label stays the slot's name, out of sight, and its tooltip. */
|
|
87
|
+
compact?: boolean;
|
|
76
88
|
}): React.JSX.Element {
|
|
77
89
|
const theme = useTheme();
|
|
90
|
+
const animate = useMounted();
|
|
78
91
|
return (
|
|
79
92
|
<Box
|
|
80
93
|
{...control}
|
|
94
|
+
title={compact ? label : undefined}
|
|
81
95
|
aria-current={current ? 'page' : undefined}
|
|
82
96
|
aria-expanded={expanded}
|
|
83
97
|
aria-busy={loading || undefined}
|
|
84
98
|
data-lit={lit ? 'true' : undefined}
|
|
85
99
|
data-testid={testId}
|
|
86
|
-
sx={slotSx(theme, lit)}
|
|
100
|
+
sx={slotSx(theme, lit, compact)}
|
|
87
101
|
>
|
|
88
102
|
<CountedIcon
|
|
89
103
|
icon={
|
|
@@ -107,6 +121,7 @@ function Slot({
|
|
|
107
121
|
lineHeight: 1.3,
|
|
108
122
|
fontWeight: lit ? 700 : 600,
|
|
109
123
|
color: lit ? 'text.primary' : 'inherit',
|
|
124
|
+
...labelFoldSx(theme, compact, animate),
|
|
110
125
|
}}
|
|
111
126
|
>
|
|
112
127
|
{label}
|
|
@@ -115,6 +130,23 @@ function Slot({
|
|
|
115
130
|
);
|
|
116
131
|
}
|
|
117
132
|
|
|
133
|
+
/**
|
|
134
|
+
* The label folding away in a compact bar: it shrinks to no height and fades
|
|
135
|
+
* while the bar shrinks, rather than leaving in one frame. Never `display:
|
|
136
|
+
* none` — it is still the slot's accessible name. With reduced motion it
|
|
137
|
+
* simply goes.
|
|
138
|
+
*/
|
|
139
|
+
function labelFoldSx(theme: Theme, compact: boolean, animate: boolean): Record<string, unknown> {
|
|
140
|
+
return {
|
|
141
|
+
maxHeight: compact ? 0 : rem(theme, 24),
|
|
142
|
+
opacity: compact ? 0 : 1,
|
|
143
|
+
transition: animate
|
|
144
|
+
? theme.transitions.create(['max-height', 'opacity'], { duration: theme.transitions.duration.shorter })
|
|
145
|
+
: 'none',
|
|
146
|
+
'@media (prefers-reduced-motion: reduce)': { transition: 'none' },
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
118
150
|
/** The pill behind a slot's icon — tinted while the slot is lit. */
|
|
119
151
|
function pillSx(theme: Theme): SxProps<Theme> {
|
|
120
152
|
return {
|
|
@@ -129,7 +161,7 @@ function pillSx(theme: Theme): SxProps<Theme> {
|
|
|
129
161
|
}
|
|
130
162
|
|
|
131
163
|
/** A slot's look: icon over label, a pill behind the lit icon, dimmed when disabled. */
|
|
132
|
-
function slotSx(theme: Theme, lit: boolean): SxProps<Theme> {
|
|
164
|
+
function slotSx(theme: Theme, lit: boolean, compact: boolean): SxProps<Theme> {
|
|
133
165
|
return {
|
|
134
166
|
...CONTROL_RESET,
|
|
135
167
|
...focusRing(theme),
|
|
@@ -139,7 +171,7 @@ function slotSx(theme: Theme, lit: boolean): SxProps<Theme> {
|
|
|
139
171
|
flexDirection: 'column',
|
|
140
172
|
alignItems: 'center',
|
|
141
173
|
justifyContent: 'center',
|
|
142
|
-
gap: 0.25,
|
|
174
|
+
gap: compact ? 0 : 0.25,
|
|
143
175
|
position: 'relative',
|
|
144
176
|
color: lit ? 'primary.main' : 'text.secondary',
|
|
145
177
|
// The current slot is marked by more than its colour: a tinted pill behind
|
|
@@ -158,6 +190,7 @@ interface SlotContext {
|
|
|
158
190
|
linkComponent: ElementType | undefined;
|
|
159
191
|
copy: SectionNavCopy;
|
|
160
192
|
dataTestId: string;
|
|
193
|
+
compact: boolean;
|
|
161
194
|
}
|
|
162
195
|
|
|
163
196
|
/** The raised button: an action runs on tap; a menu opens its sheet. */
|
|
@@ -175,6 +208,7 @@ function PrimarySlot({
|
|
|
175
208
|
label={primary.label}
|
|
176
209
|
icon={primary.icon}
|
|
177
210
|
captioned
|
|
211
|
+
compact={context.compact}
|
|
178
212
|
disabled={primary.disabled}
|
|
179
213
|
loading={primary.loading}
|
|
180
214
|
dataTestId={testId}
|
|
@@ -191,6 +225,7 @@ function PrimarySlot({
|
|
|
191
225
|
icon={primary.icon}
|
|
192
226
|
open={context.open === 'primary'}
|
|
193
227
|
closeLabel={context.copy.close}
|
|
228
|
+
compact={context.compact}
|
|
194
229
|
disabled={primary.disabled}
|
|
195
230
|
dataTestId={testId}
|
|
196
231
|
onClick={() => context.toggle('primary')}
|
|
@@ -211,6 +246,7 @@ function MoreSlot({ more, context }: { more: SectionNavMenu; context: SlotContex
|
|
|
211
246
|
expanded={open === 'more'}
|
|
212
247
|
copy={context.copy}
|
|
213
248
|
testId={more.dataTestId ?? `${context.dataTestId}-more`}
|
|
249
|
+
compact={context.compact}
|
|
214
250
|
control={controlProps({
|
|
215
251
|
href: undefined,
|
|
216
252
|
linkComponent: context.linkComponent,
|
|
@@ -240,6 +276,7 @@ function DestinationSlot({
|
|
|
240
276
|
copy={context.copy}
|
|
241
277
|
testId={destination.dataTestId ?? `${context.dataTestId}-dest-${destination.id}`}
|
|
242
278
|
loading={destination.loading === true}
|
|
279
|
+
compact={context.compact}
|
|
243
280
|
control={destinationControl(destination, context.linkComponent, () => {
|
|
244
281
|
context.close();
|
|
245
282
|
destination.onSelect?.();
|
|
@@ -265,6 +302,32 @@ function BarSlotView({
|
|
|
265
302
|
return <DestinationSlot destination={slot.destination} context={context} />;
|
|
266
303
|
}
|
|
267
304
|
|
|
305
|
+
/** The bar's own box: docked, a hairline on top, raised over the backdrop only while its sheet is open. */
|
|
306
|
+
function barSx(theme: Theme, sheetOpen: boolean, compact: boolean, animate: boolean): SxProps<Theme> {
|
|
307
|
+
return {
|
|
308
|
+
flex: 'none',
|
|
309
|
+
display: 'flex',
|
|
310
|
+
alignItems: 'stretch',
|
|
311
|
+
boxSizing: 'border-box',
|
|
312
|
+
height: sectionNavBarInset(theme, { compact }),
|
|
313
|
+
// Folding to icons and back is a change of height the eye follows;
|
|
314
|
+
// with reduced motion it simply happens.
|
|
315
|
+
transition: animate ? theme.transitions.create('height', { duration: theme.transitions.duration.shorter }) : 'none',
|
|
316
|
+
'@media (prefers-reduced-motion: reduce)': { transition: 'none' },
|
|
317
|
+
paddingBottom: 'env(safe-area-inset-bottom)',
|
|
318
|
+
borderTop: `1px solid ${theme.palette.divider}`,
|
|
319
|
+
bgcolor: 'background.paper',
|
|
320
|
+
// Above the backdrop ONLY while one of its own sheets is open, so the
|
|
321
|
+
// primary button can close what it opened. Raised all the time it
|
|
322
|
+
// would sit over every dialog the page opens, and on a small phone a
|
|
323
|
+
// dialog's own footer is exactly where the bar is. `stackedOverlayZIndex`,
|
|
324
|
+
// not `zIndex.modal + 1`: a host lifting a bottom Drawer clear of a
|
|
325
|
+
// stacked sheet catches this bar's OWN sheets too.
|
|
326
|
+
position: 'relative',
|
|
327
|
+
zIndex: sheetOpen ? stackedOverlayZIndex(theme) + 1 : 'auto',
|
|
328
|
+
} as SxProps<Theme>;
|
|
329
|
+
}
|
|
330
|
+
|
|
268
331
|
/** The phone layout: a bottom bar, with its menus as bottom sheets. */
|
|
269
332
|
export function SectionNavBar({
|
|
270
333
|
label,
|
|
@@ -274,10 +337,12 @@ export function SectionNavBar({
|
|
|
274
337
|
linkComponent,
|
|
275
338
|
copy,
|
|
276
339
|
dataTestId,
|
|
340
|
+
compact = false,
|
|
277
341
|
}: Required<Pick<SectionNavProps, 'label' | 'destinations' | 'copy' | 'dataTestId'>> &
|
|
278
|
-
Pick<SectionNavProps, 'primary' | 'more'> & { linkComponent: ElementType | undefined }): React.JSX.Element {
|
|
342
|
+
Pick<SectionNavProps, 'primary' | 'more' | 'compact'> & { linkComponent: ElementType | undefined }): React.JSX.Element {
|
|
279
343
|
const sheetMenu = isMenu(primary) ? primary : undefined;
|
|
280
344
|
const theme = useTheme();
|
|
345
|
+
const animate = useMounted();
|
|
281
346
|
const [open, setOpen] = useState<OpenMenu>(null);
|
|
282
347
|
const toggle = (menu: Exclude<OpenMenu, null>): void => setOpen((current) => (current === menu ? null : menu));
|
|
283
348
|
const close = (): void => setOpen(null);
|
|
@@ -288,24 +353,7 @@ export function SectionNavBar({
|
|
|
288
353
|
component="nav"
|
|
289
354
|
aria-label={label}
|
|
290
355
|
data-testid={dataTestId}
|
|
291
|
-
sx={
|
|
292
|
-
flex: 'none',
|
|
293
|
-
display: 'flex',
|
|
294
|
-
alignItems: 'stretch',
|
|
295
|
-
boxSizing: 'border-box',
|
|
296
|
-
height: sectionNavBarInset(theme),
|
|
297
|
-
paddingBottom: 'env(safe-area-inset-bottom)',
|
|
298
|
-
borderTop: `1px solid ${theme.palette.divider}`,
|
|
299
|
-
bgcolor: 'background.paper',
|
|
300
|
-
// Above the backdrop ONLY while one of its own sheets is open, so the
|
|
301
|
-
// primary button can close what it opened. Raised all the time it
|
|
302
|
-
// would sit over every dialog the page opens, and on a small phone a
|
|
303
|
-
// dialog's own footer is exactly where the bar is. `stackedOverlayZIndex`,
|
|
304
|
-
// not `zIndex.modal + 1`: a host lifting a bottom Drawer clear of a
|
|
305
|
-
// stacked sheet catches this bar's OWN sheets too.
|
|
306
|
-
position: 'relative',
|
|
307
|
-
zIndex: open === null ? 'auto' : stackedOverlayZIndex(theme) + 1,
|
|
308
|
-
}}
|
|
356
|
+
sx={barSx(theme, open !== null, compact, animate)}
|
|
309
357
|
>
|
|
310
358
|
{barSlots(destinations, more !== undefined, primary !== undefined).map((slot) => (
|
|
311
359
|
<BarSlotView
|
|
@@ -313,7 +361,7 @@ export function SectionNavBar({
|
|
|
313
361
|
slot={slot}
|
|
314
362
|
primary={primary}
|
|
315
363
|
more={more}
|
|
316
|
-
context={{ open, toggle, close, linkComponent, copy, dataTestId }}
|
|
364
|
+
context={{ open, toggle, close, linkComponent, copy, dataTestId, compact }}
|
|
317
365
|
/>
|
|
318
366
|
))}
|
|
319
367
|
</Box>
|
|
@@ -325,7 +373,7 @@ export function SectionNavBar({
|
|
|
325
373
|
linkComponent={linkComponent}
|
|
326
374
|
copy={copy}
|
|
327
375
|
testId={`${dataTestId}-primary-sheet`}
|
|
328
|
-
bottomOffset={sectionNavBarInset(theme)}
|
|
376
|
+
bottomOffset={sectionNavBarInset(theme, { compact })}
|
|
329
377
|
/>
|
|
330
378
|
) : null}
|
|
331
379
|
{more ? (
|
|
@@ -336,7 +384,7 @@ export function SectionNavBar({
|
|
|
336
384
|
linkComponent={linkComponent}
|
|
337
385
|
copy={copy}
|
|
338
386
|
testId={`${dataTestId}-more-sheet`}
|
|
339
|
-
bottomOffset={sectionNavBarInset(theme)}
|
|
387
|
+
bottomOffset={sectionNavBarInset(theme, { compact })}
|
|
340
388
|
/>
|
|
341
389
|
) : null}
|
|
342
390
|
</>
|
|
@@ -50,6 +50,26 @@ screen.
|
|
|
50
50
|
carries no words. `PT_BR_SECTION_NAV_COPY` and `EN_US_SECTION_NAV_COPY` are
|
|
51
51
|
named packs; `SECTION_NAV_COPY` is the locale pack.
|
|
52
52
|
- **dataTestId**: the prefix for every test id (`section-nav`).
|
|
53
|
+
- **compact**: `boolean`, default `false`. Icons only, a size down, for a host
|
|
54
|
+
that folds its chrome so the content gets the screen. See *Compact*.
|
|
55
|
+
|
|
56
|
+
## Compact
|
|
57
|
+
|
|
58
|
+
`compact` draws the same navigation as icons only. Nothing is removed: every
|
|
59
|
+
label stays its control's accessible name (out of sight) and its `title`
|
|
60
|
+
tooltip, every count stays on its icon, every menu still opens.
|
|
61
|
+
|
|
62
|
+
| `layout` | compact draws |
|
|
63
|
+
|---|---|
|
|
64
|
+
| `bar` | 48px instead of 60; each slot its icon, its label folding away (shrinking and fading) as the bar shrinks; the raised button 40px instead of 52, lifted less, with its label as a tooltip and no caption under an action. Height and labels animate (200ms) unless the reader asked for reduced motion. |
|
|
65
|
+
| `rail` | each row, the way back (an arrow when it brings no icon) and a `primary` menu's button as their icon, centred; the heading, `more`'s title and its group titles out of sight. Made for a column 64px wide; the host sets the width. |
|
|
66
|
+
|
|
67
|
+
`sectionNavBarInset(theme, { compact: true })` is the compact bar's full
|
|
68
|
+
height, so a host's reserved foot follows the bar as it folds.
|
|
69
|
+
|
|
70
|
+
A slot's name includes its count ("Board, 3 pending") while its tooltip is the
|
|
71
|
+
label alone, so a screen reader may read the label a second time as the
|
|
72
|
+
description; the tooltip is there for a pointer, which sees no words otherwise.
|
|
53
73
|
|
|
54
74
|
## A bar of verbs
|
|
55
75
|
|
|
@@ -103,8 +123,8 @@ every label is semibold.
|
|
|
103
123
|
|
|
104
124
|
## Docking the bar
|
|
105
125
|
|
|
106
|
-
Dock the bar at the foot of a flex column. `sectionNavBarInset(theme)`
|
|
107
|
-
full height, the phone's safe area included. Reserve it at the foot of the
|
|
126
|
+
Dock the bar at the foot of a flex column. `sectionNavBarInset(theme)` (with
|
|
127
|
+
`{ compact: true }` for the compact bar) is its full height, the phone's safe area included. Reserve it at the foot of the
|
|
108
128
|
content, so nothing the page floats (a toast, a receipt) lands under the bar.
|
|
109
129
|
|
|
110
130
|
The bar rises above a modal backdrop only while one of its OWN sheets is open,
|
|
@@ -123,7 +143,8 @@ the slot reports the sheet through `aria-expanded`.
|
|
|
123
143
|
The raised round button on its own, for a host that already draws its own bar:
|
|
124
144
|
drop it between two tabs in a flex row. Without `open` it is a plain action.
|
|
125
145
|
With `captioned` its label is drawn under it, hidden from assistive tech so
|
|
126
|
-
the button is named once. `
|
|
146
|
+
the button is named once. `compact` draws it 40px rather than 52, with no
|
|
147
|
+
caption. `disabled` is native; `loading` keeps it focusable
|
|
127
148
|
with `aria-busy` and `aria-disabled`, and drops the click.
|
|
128
149
|
With `open` it reports `aria-expanded`, takes `closeLabel` as its name, and its
|
|
129
150
|
icon turns 45° while open.
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import Box from '@mui/material/Box/index.js';
|
|
2
2
|
import CircularProgress from '@mui/material/CircularProgress/index.js';
|
|
3
3
|
import type { SxProps, Theme } from '@mui/material/styles/index.js';
|
|
4
|
-
import type
|
|
4
|
+
import { useEffect, useState, type ElementType, type ReactNode } from 'react';
|
|
5
5
|
|
|
6
6
|
import { rem } from '../../../tokens/scales';
|
|
7
|
+
import { SR_ONLY_SX } from '../../form/Label/Label.styles';
|
|
7
8
|
import { Badge } from '../../data-display/Badge';
|
|
8
9
|
|
|
9
10
|
import { shownCount } from './SectionNav.helpers';
|
|
@@ -153,4 +154,21 @@ export const CONTROL_RESET = {
|
|
|
153
154
|
[NOT_LIVE]: { cursor: 'default' },
|
|
154
155
|
} as const;
|
|
155
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Out of sight, still read: a compact nav keeps each label as its control's
|
|
159
|
+
* accessible name. The same box `Label`'s `srOnly` draws.
|
|
160
|
+
*/
|
|
161
|
+
export const VISUALLY_HIDDEN = SR_ONLY_SX;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* False on the first render, true from then on — so a fold animates when the
|
|
165
|
+
* host CHANGES `compact`, never when a page simply opens folded (which drew
|
|
166
|
+
* the labels sliding out over the neighbouring badges on every load).
|
|
167
|
+
*/
|
|
168
|
+
export function useMounted(): boolean {
|
|
169
|
+
const [mounted, setMounted] = useState(false);
|
|
170
|
+
useEffect(() => setMounted(true), []);
|
|
171
|
+
return mounted;
|
|
172
|
+
}
|
|
173
|
+
|
|
156
174
|
export { Box };
|
|
@@ -4,7 +4,7 @@ import type { ReactNode } from 'react';
|
|
|
4
4
|
|
|
5
5
|
import { rem } from '../../../tokens/scales';
|
|
6
6
|
|
|
7
|
-
import { Box, CONTROL_RESET, NOT_LIVE, SlotIcon
|
|
7
|
+
import { Box, CONTROL_RESET, NOT_LIVE, SlotIcon } from './SectionNav.parts';
|
|
8
8
|
|
|
9
9
|
export interface RaisedActionButtonProps {
|
|
10
10
|
/**
|
|
@@ -28,6 +28,12 @@ export interface RaisedActionButtonProps {
|
|
|
28
28
|
* bar of places can leave its one action to the icon.
|
|
29
29
|
*/
|
|
30
30
|
captioned?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* A size down — 40px rather than 52, lifted less — for a compact bar. It
|
|
33
|
+
* draws no caption: a compact bar is icons only, and the name stays the
|
|
34
|
+
* button's `aria-label`.
|
|
35
|
+
*/
|
|
36
|
+
compact?: boolean;
|
|
31
37
|
/** Dimmed and not operable: a native `disabled` button. */
|
|
32
38
|
disabled?: boolean;
|
|
33
39
|
/**
|
|
@@ -58,6 +64,7 @@ export function RaisedActionButton({
|
|
|
58
64
|
open,
|
|
59
65
|
closeLabel,
|
|
60
66
|
captioned = false,
|
|
67
|
+
compact = false,
|
|
61
68
|
disabled = false,
|
|
62
69
|
loading = false,
|
|
63
70
|
dataTestId = 'raised-action',
|
|
@@ -79,18 +86,36 @@ export function RaisedActionButton({
|
|
|
79
86
|
component="button"
|
|
80
87
|
type="button"
|
|
81
88
|
{...raisedState({ onClick, disabled, loading })}
|
|
82
|
-
|
|
89
|
+
{...raisedNames({ label, closeLabel, expanded, compact })}
|
|
83
90
|
aria-expanded={open}
|
|
84
91
|
data-testid={dataTestId}
|
|
85
|
-
sx={raisedSx(theme, expanded)}
|
|
92
|
+
sx={raisedSx(theme, expanded, compact)}
|
|
86
93
|
>
|
|
87
94
|
<SlotIcon icon={icon} loading={loading} />
|
|
88
95
|
</Box>
|
|
89
|
-
{captioned
|
|
96
|
+
<RaisedCaption shown={captioned && !compact} label={label} inert={disabled || loading} />
|
|
90
97
|
</Box>
|
|
91
98
|
);
|
|
92
99
|
}
|
|
93
100
|
|
|
101
|
+
/**
|
|
102
|
+
* The button's name — `closeLabel` while what it opened is open — and, on a
|
|
103
|
+
* compact bar where no word is drawn, the label as its tooltip.
|
|
104
|
+
*/
|
|
105
|
+
function raisedNames({
|
|
106
|
+
label,
|
|
107
|
+
closeLabel,
|
|
108
|
+
expanded,
|
|
109
|
+
compact,
|
|
110
|
+
}: {
|
|
111
|
+
label: string;
|
|
112
|
+
closeLabel: string | undefined;
|
|
113
|
+
expanded: boolean;
|
|
114
|
+
compact: boolean;
|
|
115
|
+
}): { 'aria-label': string; title: string | undefined } {
|
|
116
|
+
return { 'aria-label': expanded && closeLabel ? closeLabel : label, title: compact ? label : undefined };
|
|
117
|
+
}
|
|
118
|
+
|
|
94
119
|
/**
|
|
95
120
|
* The button's operability. Only `disabled` is native: an in-flight button
|
|
96
121
|
* keeps its focus, reports `aria-busy` and `aria-disabled`, and drops the click.
|
|
@@ -114,10 +139,11 @@ function raisedState({
|
|
|
114
139
|
}
|
|
115
140
|
|
|
116
141
|
/**
|
|
117
|
-
* The label under a captioned button. Hidden from assistive tech: the button
|
|
142
|
+
* The label under a captioned button — none on a compact bar. Hidden from assistive tech: the button
|
|
118
143
|
* already carries the same words as its name, and reading them twice is noise.
|
|
119
144
|
*/
|
|
120
|
-
function RaisedCaption({ label, inert }: { label: string; inert: boolean }): React.JSX.Element {
|
|
145
|
+
function RaisedCaption({ shown, label, inert }: { shown: boolean; label: string; inert: boolean }): React.JSX.Element | null {
|
|
146
|
+
if (!shown) return null;
|
|
121
147
|
return (
|
|
122
148
|
<Typography
|
|
123
149
|
component="span"
|
|
@@ -131,15 +157,17 @@ function RaisedCaption({ label, inert }: { label: string; inert: boolean }): Rea
|
|
|
131
157
|
}
|
|
132
158
|
|
|
133
159
|
/** The round button: lifted half out of the bar, its icon turning while what it opened is open. */
|
|
134
|
-
function raisedSx(theme: Theme, expanded: boolean): SxProps<Theme> {
|
|
135
|
-
const size = rem(theme, 52);
|
|
160
|
+
function raisedSx(theme: Theme, expanded: boolean, compact: boolean): SxProps<Theme> {
|
|
161
|
+
const size = rem(theme, compact ? 40 : 52);
|
|
136
162
|
return {
|
|
137
163
|
...CONTROL_RESET,
|
|
138
|
-
|
|
164
|
+
// The ring OUTSIDE the button: the shared ring sits inside the box, in the
|
|
165
|
+
// primary colour, where this button's own fill swallowed it whole.
|
|
166
|
+
'&:focus-visible': { outline: `${rem(theme, 2)} solid ${theme.palette.primary.main}`, outlineOffset: rem(theme, 2) },
|
|
139
167
|
width: size,
|
|
140
168
|
height: size,
|
|
141
169
|
// Lifted half out of the bar: the one control that is not a place.
|
|
142
|
-
marginTop: rem(theme, -18),
|
|
170
|
+
marginTop: rem(theme, compact ? -12 : -18),
|
|
143
171
|
borderRadius: '50%',
|
|
144
172
|
display: 'flex',
|
|
145
173
|
alignItems: 'center',
|
|
@@ -149,7 +177,7 @@ function raisedSx(theme: Theme, expanded: boolean): SxProps<Theme> {
|
|
|
149
177
|
boxShadow: theme.shadows[6],
|
|
150
178
|
[NOT_LIVE]: { cursor: 'default', bgcolor: 'action.disabledBackground', color: 'text.disabled', boxShadow: 'none' },
|
|
151
179
|
'& svg': {
|
|
152
|
-
fontSize: rem(theme, 26),
|
|
180
|
+
fontSize: rem(theme, compact ? 22 : 26),
|
|
153
181
|
transition: theme.transitions.create('transform', { duration: theme.transitions.duration.shorter }),
|
|
154
182
|
transform: expanded ? 'rotate(45deg)' : 'none',
|
|
155
183
|
},
|