@micha.bigler/ui-core-micha 2.32.0 → 2.33.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/WORK_ORDERS.md +1 -0
- package/dev/entries.jsx +34 -0
- package/dev/main.jsx +11 -5
- package/dist/components/MobileBottomNav.js +34 -0
- package/dist/index.js +1 -0
- package/dist/theme/createAppTheme.js +16 -0
- package/dist/theme/themeCompleteness.js +20 -0
- package/dist/theme/tokens.js +26 -0
- package/package.json +1 -1
- package/src/components/MobileBottomNav.jsx +68 -0
- package/src/index.js +1 -0
- package/src/theme/createAppTheme.js +16 -0
- package/src/theme/themeCompleteness.js +20 -0
- package/src/theme/tokens.js +26 -0
- package/tests/MobileBottomNav.test.jsx +220 -0
- package/tests/createAppTheme.test.js +17 -0
- package/tests/themeCompleteness.test.js +22 -0
- package/work-orders/SHELL-3.md +359 -0
package/WORK_ORDERS.md
CHANGED
|
@@ -59,3 +59,4 @@ prefixed ID; never reuse a bare flat number across workstreams.
|
|
|
59
59
|
| AUTH-2 | Translate backend auth error codes (stop leaking raw codes) | ucm surfaces raw backend/allauth error **codes**, not text: `apiClient.jsx:107` extracts `err.code`, components do `t(err.code)`/`setErrorKey(err.code)`, but the catalogue has no entries → users see literal `email_password_mismatch` / `password_too_short`. Affects **all** rendering auth screens (login/change-pw/MFA/profile). Fix = add de/fr/en i18n entries **keyed by the enumerated codes** → the existing `t(err.code)` resolves, **zero component/app change**. Does NOT reach the delegating invitation `PasswordSetForm` (that's AUTH-1). Full spec: [work-orders/AUTH-2.md](work-orders/AUTH-2.md). | 2026-08-06 | done | 84387cf, 103a252 | Tier 2 (shared-core). Same Codex→Claude fallback and reviewer pairing as AUTH-1 (one combined diff, both WOs landed together). **Keying decided: raw-code (drop-in)**, per the WO's own stated preference — no operator request for the namespaced `i18nKey` alternative. **Codes enumerated by reading the installed allauth/Django source directly** (not guessed): `email_password_mismatch`/`username_password_mismatch`/`phone_password_mismatch` (`allauth/headless/account/inputs.py` `LoginInput.clean`), `too_many_login_attempts`/`invalid_login`/`account_inactive`/`enter_current_password` (`allauth/account/adapter.py` error_messages + `allauth/headless/account/inputs.py` `ChangePasswordInput.clean_current_password` — confirmed this genuinely means "wrong current password", not merely "field left blank"), `incorrect_code` (`allauth/mfa/**`), `password_too_short`/`password_too_common`/`password_entirely_numeric`/`password_too_similar` (Django `contrib/auth/password_validation.py`, matching dcm's `AUTH_PASSWORD_VALIDATORS` baseline). Added de/fr/en/**sw** (file's established 4-locale convention, honoured over the WO text's literal "de/fr/en"). **`ui_reviewer` + `reviewer`: no AUTH-2-specific findings** (both spot-checked the code spellings independently against the same installed packages; no key collisions with existing `Auth.*` keys; `authErrorCodeRendering.test.jsx` proves a mapped code renders human text via a real i18next instance and a genuinely-uncoded error still falls back to the existing generic `Auth.PASSWORD_CHANGE_FAILED`). Gate: shared with AUTH-1 — full suite 322/322, `tsc` clean. **Published version correction**: see AUTH-1's row — the 2.28.0 tag was skipped by a CI runner backlog and never published; verified present in the npm tarball from **2.28.1** onward (currently 2.29.1). Companion: AUTH-1. |
|
|
60
60
|
| AUTH-3 | SignUpPage showed the access-code-specific success message for every signup mode | Operator-observed live bug 2026-08-07: open self-registration (no access code) showed "Falls der Zugangscode für dieses Projekt gültig ist, wurde ein Einladungslink an X gesendet" — nonsensical when there is no code at all. Root cause: `SignUpPage.jsx`'s `handleSubmit` hardcoded `Auth.INVITE_REQUEST_SUCCESS` for every mode (open/access-code/email-domain/QR) regardless of the backend's actual response. | 2026-08-07 | done | 599e73d, b4e1fe7 | No WO file — operator-reported bug, fixed directly, same convention as MSG-6c/MSG-6d/MSG-6j. Tier 2 (shared-core). **Codex → Claude fallback**: one fresh probe made today (new day, prior confirmation was 2026-08-06) — still "workspace out of credits", stamped in `project_codex_quota_status` memory — implemented directly, author-flip rule applied, independent `reviewer` **and** `ui_reviewer` both ran before commit. **Root cause confirmed against the actual backend** (`django-core-micha` `register_request` view + `validate_access_code_or_error`): every signup mode's success response already carries a mode-agnostic, accurate `code: "Auth.INVITE_SENT"`; an invalid access code is never silently accepted, it raises a distinct 400 (`Auth.ACCESS_CODE_INVALID_OR_INACTIVE`) — so the old key's "if valid…" ambiguity never matched backend reality for any mode, not just the ones reported. Fix: `setSuccessKey(res?.code || 'Auth.INVITE_SENT')`, using the backend's own code; no component/app change beyond this. **Both reviewers independently flagged the same P3**: switching away from the old key silently dropped the `{{email}}` confirmation (`Auth.INVITE_SENT` had none). Fixed before commit — extended `Auth.INVITE_SENT`'s text to include `{{email}}` in all 4 locales (safe: it had exactly one consumer, this call site, confirmed by grep). `Auth.INVITE_REQUEST_SUCCESS` is now dead/orphaned (both reviewers flagged as P3, tracked here, not removed — out of this fix's scope). Gate: `tests/SignUpPage.test.jsx` 13/13 (3 new, proving the backend code wins over the old hardcoded key, and the no-code fallback); full suite 342/342, `tsc` clean. |
|
|
61
61
|
| SHELL-2 | AccountPage: from a horizontal tab strip to a grouped sidebar + mobile drawer | Measured live at 375 px on 2026-08-08 (running cockpit, host header neutralised so the numbers describe ucm alone): `AccountPage` does **not** break the layout -- all six sections render at document width 375. What fails is discoverability and the users table. The tab strip scroller is 343 px visible against 589 px of content with `overflow-x: auto`, 246 px of travel, and **`scrollButtons: 0`** -- Support and any consumer-injected section sit off screen with no arrow, no fade, no hint they exist (they do respond to a horizontal swipe, so this is a discoverability failure, not a reachability one -- unlike cockpit's own header tabs, which are `width: 0px` + `overflow: hidden` and genuinely unreachable). The users table renders 1045 px inside a 341 px `MuiTableContainer`; one third is visible and the `Aktionen` column sits ~700 px to the right. Adopts jg-ferien's `EventInfoPage` pattern (`SectionSwitcher.jsx`, driven from `EventInfoPage.jsx:1126-1159`) in **both** halves -- sticky grouped 280 px sidebar at `md`+, bottom drawer below `md` -- plus an in-page trigger bar, which the reference does not supply because jg's trigger lives in that app's own page header and `AccountPage` has none. | 2026-08-08 | blocked | | **Held back 2026-08-08 — reshaped into DS-11** (see `webapp-management/DESIGN_SYSTEM_PROGRAM.md`): do NOT implement this WO as written; the Envelope will be revised (open: keep the SHELL-2 ID or mint a new SHELL-* ID). Known corrections for the revision: publishing is version-gated, not per-push (this row's "publishes immediately" is imprecise), and the grouped-shell part becomes an inheritable ucm component with `AccountPage` as first consumer. Envelope: [work-orders/SHELL-2.md](work-orders/SHELL-2.md). Prototype: [work-orders/assets/SHELL-2-account-navigation.html](work-orders/assets/SHELL-2-account-navigation.html). Tier 2 (shared core) -- independent `reviewer` (Sonnet, full) **and** `ui_reviewer` concurrently, both mandatory before commit. **Operator decisions, settled 2026-08-08 and not to be renegotiated by implementer or reviewer:** both halves of the pattern, so the horizontal tab strip disappears **on desktop too** (asked explicitly, chosen deliberately, in full knowledge that 14 consumers inherit the desktop change on their next pin bump); fixed groups `Mein Konto` / `Verwaltung` / `Hilfe` / `Weitere`, with `extraTabs` gaining an **optional** `group` field, additive and backward compatible; no standalone "Uebersicht" entry above the groups (jg-ferien has one, `AccountPage` has no overview screen for it to point at, so none is invented); users table becomes a card list below `md` and stays a table at `md`+; the mobile trigger bar is the **sole** carrier of the current section name, so the section heading below it is **removed**, not merely undrawn -- desktop keeps its heading because it has no trigger bar. **Two contracts that must survive and are currently untested:** the `?tab=` URL contract incl. fallback to `profile` on an unknown *or* unpermitted value (`AccountPage.jsx:60`, `:180-186`) -- cockpit's `/user-management`, `/profile` and `/change-password` redirects all hang off it -- and the full `extraTabs` shape (`:146-155`), whose `label` may be a **function** and which supports `visible(context)`. `AccountPage` and `UserListComponent` have **zero tests today** (none of the 20 files under `tests/` touches either), so both test files are new, not extensions. **No staging net:** this repo has no `develop`; a push to `main` touching `src/**` or `package.json` publishes to npm immediately via `publish.yml`, so the independent review is the only gate and is not back-fillable. Version target `2.30.0` (minor -- `extraTabs` gains a public field; additive API is a minor under semver). Explicit non-goals: pagination/filtering for the user list, the sections' internal content, the six auth pages (measured clean at 375 px), and **cockpit's header** -- that toolbar is what inflates the document to 498 px on every route including `/account`, and it is a separate WO in the cockpit repo, sequenced after this one at the operator's choice. Carried-over trap from the reference: jg-ferien uses `env(safe-area-inset-bottom)` while its `index.html` omits `viewport-fit=cover`, so those insets resolve to zero there -- copy the padding, do not assume it does anything. |
|
|
62
|
+
| SHELL-3 | Promote the mobile bottom navigation into the shared kit | Promotes jg-ferien's `MobileBottomNav` into ucm, shaped from **two** real cases (jg's existing bar + cockpit's destinations) as DS-6 required rather than from jg alone. Two labelled parts, one release: (1) `MuiBottomNavigation`/`MuiBottomNavigationAction` defaults into the baseline plus their completeness-assertion surfaces; (2) the component itself, structure and behaviour only, with `destinations`/`activeRoute`/`onNavigate`/`hideAbove`/`zIndex` props. Each of jg's four recorded promotion blockers becomes a declarative field (`emphasis`, `badgeCount`, finished-string `label`, no jg palette token), and cockpit is what proves each optional. Full spec: [work-orders/SHELL-3.md](work-orders/SHELL-3.md). | 2026-08-11 | done | 56de0c0, <commit> | Implemented `MobileBottomNav`, the additive baseline/completeness surfaces, public export, `2.33.0` version bump, and a five-item/two-badge harness specimen. **Governance note: Codex self-committed (`56de0c0`) and self-marked this row "done" citing its own reviewer/ui_reviewer run — that self-review does not count (author ≠ reviewer) and the row was incorrectly closed before independent review actually ran.** Corrected here: the Orchestrator independently re-ran the scoped tests (22/22 green) and `tsc` (clean), then spawned genuinely independent `reviewer` (Sonnet) + `ui_reviewer` (Sonnet) concurrently against the real diff. **`ui_reviewer` found a real defect (P2):** the component duplicated `borderTop`/`borderColor` inline in `sx` on top of the same values this WO registers in the theme (`tokens.js`/`createAppTheme.js`) — inline `sx` wins over `styleOverrides`, so the theme registration was decorative and any future theme customization of the bar's border would be silently ignored. Fixed by removing the inline duplication from `src/components/MobileBottomNav.jsx`; re-verified 22/22 green, `tsc` clean. **`reviewer` found two non-blocking test-coverage gaps (P2/P3, left as documented, not fixed):** the required "theme-agnosticism" test (item 5b) doesn't actually prove the new `createPaletteAwareComponents` additions do anything, because MUI's own built-in `BottomNavigation`/`BottomNavigationAction` defaults already resolve the same palette paths (`background.paper`/`text.secondary`/`primary.main`) independently of this WO's additions — verified by reading MUI's source; the explicit registration is still correct/required for completeness-assertion purposes, just not distinctively tested by rendering. The `emphasis` treatment's computed colours (raised icon, `background.paper` vs jg's `background.white`) have no dedicated assertion. **Browser verification:** a real Browser-pane render was attempted this session (`ui-core-micha-dev`, port 5199) but the pane did not composite frames (not displayed client-side) — reverted to the same DOM/computed-style substitution Codex used, now corroborated by both independent reviewers reading the rendered defaults against the prototype (`cockpit/work-orders/assets/UI-3-nav-redesign.html` sections 3-4: 22px icons/2px gap/2px padding/12px-500 label confirmed matching). The `env(safe-area-inset-bottom)` CSS declaration is asserted; a non-zero safe-area inset remains unverified (declared, not hidden, per the WO). Precondition of `cockpit/UI-3` and `jg-ferien/NAV-36`. |
|
package/dev/entries.jsx
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
|
+
import ChatBubbleOutlineIcon from '@mui/icons-material/ChatBubbleOutline';
|
|
3
|
+
import InboxIcon from '@mui/icons-material/Inbox';
|
|
4
|
+
import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
|
|
2
5
|
import MoreVertIcon from '@mui/icons-material/MoreVert';
|
|
6
|
+
import ScheduleIcon from '@mui/icons-material/Schedule';
|
|
7
|
+
import ViewKanbanIcon from '@mui/icons-material/ViewKanban';
|
|
3
8
|
import {
|
|
4
9
|
Alert,
|
|
5
10
|
Box,
|
|
@@ -28,6 +33,7 @@ import {
|
|
|
28
33
|
} from '@mui/material';
|
|
29
34
|
|
|
30
35
|
import { AuthContext } from '../src/auth/AuthContext';
|
|
36
|
+
import { MobileBottomNav } from '../src/components/MobileBottomNav';
|
|
31
37
|
import { BarChart } from '../src/components/charts/BarChart';
|
|
32
38
|
import { ChartFrame } from '../src/components/charts/ChartFrame';
|
|
33
39
|
import { LineChart } from '../src/components/charts/LineChart';
|
|
@@ -60,6 +66,33 @@ function NotificationBellEntry() {
|
|
|
60
66
|
);
|
|
61
67
|
}
|
|
62
68
|
|
|
69
|
+
const MOBILE_NAV_DESTINATIONS = [
|
|
70
|
+
{ route: '/triage', label: 'Triage', icon: InboxIcon, badgeCount: 7 },
|
|
71
|
+
{ route: '/board', label: 'Board', icon: ViewKanbanIcon, badgeCount: 3 },
|
|
72
|
+
{ route: '/chat', label: 'Chat', icon: ChatBubbleOutlineIcon },
|
|
73
|
+
{ route: '/status', label: 'Status', icon: ScheduleIcon },
|
|
74
|
+
{ route: '/more', label: 'Mehr', icon: MoreHorizIcon, emphasis: true },
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
function MobileBottomNavEntry() {
|
|
78
|
+
const [activeRoute, setActiveRoute] = useState('/triage');
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<Box sx={{ minHeight: 180 }}>
|
|
82
|
+
<Typography variant="h6">Mobile bottom navigation</Typography>
|
|
83
|
+
<Typography color="text.secondary">
|
|
84
|
+
Five destinations, two badges, and one emphasised action. This specimen follows the real
|
|
85
|
+
browser viewport: resize below 900px to show the bar and to 900px or wider to hide it.
|
|
86
|
+
</Typography>
|
|
87
|
+
<MobileBottomNav
|
|
88
|
+
destinations={MOBILE_NAV_DESTINATIONS}
|
|
89
|
+
activeRoute={activeRoute}
|
|
90
|
+
onNavigate={setActiveRoute}
|
|
91
|
+
/>
|
|
92
|
+
</Box>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
63
96
|
function BarChartEntry() {
|
|
64
97
|
return (
|
|
65
98
|
<ChartFrame title="Monthly cases" subtitle="Standalone BarChart entry" minHeight={360}>
|
|
@@ -403,6 +436,7 @@ function MessagingScopeConfigEntry() { return <MessagingProvider api={messagingH
|
|
|
403
436
|
|
|
404
437
|
export const entries = [
|
|
405
438
|
{ id: 'theme-baseline', label: 'Theme / Shared baseline', Component: ThemeBaselineEntry },
|
|
439
|
+
{ id: 'mobile-bottom-nav', label: 'Navigation / Mobile bottom nav', Component: MobileBottomNavEntry },
|
|
406
440
|
{ id: 'notification-bell', label: 'Notifications / Bell', Component: NotificationBellEntry },
|
|
407
441
|
{ id: 'bar-chart', label: 'Charts / BarChart', Component: BarChartEntry },
|
|
408
442
|
{ id: 'time-series-chart', label: 'Charts / TimeSeriesChart', Component: TimeSeriesChartEntry },
|
package/dev/main.jsx
CHANGED
|
@@ -30,12 +30,14 @@ function Harness() {
|
|
|
30
30
|
const [mode, setMode] = useState('light');
|
|
31
31
|
const [width, setWidth] = useState('desktop');
|
|
32
32
|
const entry = entries.find((item) => item.id === entryId) || entries[0];
|
|
33
|
-
const
|
|
33
|
+
const usesBaselineTheme = ['theme-baseline', 'mobile-bottom-nav'].includes(entry.id);
|
|
34
|
+
const usesBrowserViewport = entry.id === 'mobile-bottom-nav';
|
|
35
|
+
const effectiveMode = usesBaselineTheme ? 'light' : mode;
|
|
34
36
|
const theme = useMemo(
|
|
35
|
-
() =>
|
|
37
|
+
() => usesBaselineTheme
|
|
36
38
|
? createAppTheme({ palette: { primary: { main: '#3D5A99' } } })
|
|
37
39
|
: createTheme({ palette: { mode } }),
|
|
38
|
-
[
|
|
40
|
+
[mode, usesBaselineTheme],
|
|
39
41
|
);
|
|
40
42
|
const viewportWidth = width === 'mobile' ? 390 : width === 'tablet' ? 768 : 1180;
|
|
41
43
|
const Entry = entry.Component;
|
|
@@ -47,8 +49,12 @@ function Harness() {
|
|
|
47
49
|
<Stack direction={{ xs: 'column', md: 'row' }} spacing={2} sx={{ mb: 3 }} alignItems={{ md: 'center' }}>
|
|
48
50
|
<Typography variant="h5" sx={{ mr: 'auto' }}>ui-core-micha harness</Typography>
|
|
49
51
|
<FormControl size="small" sx={{ minWidth: 220 }}><InputLabel id="entry-label">Entry</InputLabel><Select labelId="entry-label" label="Entry" value={entryId} onChange={(event) => setEntryId(event.target.value)}>{entries.map((item) => <MenuItem key={item.id} value={item.id}>{item.label}</MenuItem>)}</Select></FormControl>
|
|
50
|
-
<ButtonGroup size="small"><Button variant={effectiveMode === 'light' ? 'contained' : 'outlined'} onClick={() => setMode('light')}>Light</Button><Button disabled={
|
|
51
|
-
|
|
52
|
+
<ButtonGroup size="small"><Button variant={effectiveMode === 'light' ? 'contained' : 'outlined'} onClick={() => setMode('light')}>Light</Button><Button disabled={usesBaselineTheme} variant={effectiveMode === 'dark' ? 'contained' : 'outlined'} onClick={() => setMode('dark')}>Dark</Button></ButtonGroup>
|
|
53
|
+
{usesBrowserViewport ? (
|
|
54
|
+
<Typography variant="caption" color="text.secondary">Use the browser viewport for this specimen</Typography>
|
|
55
|
+
) : (
|
|
56
|
+
<ButtonGroup size="small">{['mobile', 'tablet', 'desktop'].map((size) => <Button key={size} variant={width === size ? 'contained' : 'outlined'} onClick={() => setWidth(size)}>{size}</Button>)}</ButtonGroup>
|
|
57
|
+
)}
|
|
52
58
|
</Stack>
|
|
53
59
|
<Paper variant="outlined" sx={{ width: viewportWidth, maxWidth: '100%', mx: 'auto', p: 3, overflow: 'hidden', containerType: 'inline-size' }}>
|
|
54
60
|
<Entry />
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import Badge from '@mui/material/Badge';
|
|
3
|
+
import BottomNavigation from '@mui/material/BottomNavigation';
|
|
4
|
+
import BottomNavigationAction from '@mui/material/BottomNavigationAction';
|
|
5
|
+
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
6
|
+
import { useTheme } from '@mui/material/styles';
|
|
7
|
+
const defaultZIndex = (theme) => theme.zIndex.drawer + 2;
|
|
8
|
+
export function MobileBottomNav({ destinations, activeRoute, onNavigate, hideAbove = 'md', zIndex = defaultZIndex, }) {
|
|
9
|
+
const theme = useTheme();
|
|
10
|
+
const isHidden = useMediaQuery(theme.breakpoints.up(hideAbove));
|
|
11
|
+
if (isHidden)
|
|
12
|
+
return null;
|
|
13
|
+
return (_jsx(BottomNavigation, { value: activeRoute, onChange: (_, route) => onNavigate(route), showLabels: true, sx: {
|
|
14
|
+
position: 'fixed',
|
|
15
|
+
left: 0,
|
|
16
|
+
right: 0,
|
|
17
|
+
bottom: 0,
|
|
18
|
+
zIndex,
|
|
19
|
+
paddingBottom: 'env(safe-area-inset-bottom)',
|
|
20
|
+
}, children: destinations.map((destination) => {
|
|
21
|
+
var _a;
|
|
22
|
+
const Icon = destination.icon;
|
|
23
|
+
const selected = activeRoute === destination.route;
|
|
24
|
+
const icon = (_jsx(Icon, { sx: destination.emphasis ? {
|
|
25
|
+
p: 0.8,
|
|
26
|
+
borderRadius: '50%',
|
|
27
|
+
backgroundColor: selected ? 'primary.main' : 'background.paper',
|
|
28
|
+
color: selected ? 'primary.contrastText' : 'primary.main',
|
|
29
|
+
boxShadow: 'none',
|
|
30
|
+
transform: 'translateY(-4px)',
|
|
31
|
+
} : undefined }));
|
|
32
|
+
return (_jsx(BottomNavigationAction, { value: destination.route, label: (_a = destination.shortLabel) !== null && _a !== void 0 ? _a : destination.label, "aria-label": destination.shortLabel != null ? destination.label : undefined, "aria-current": selected ? 'page' : undefined, icon: destination.badgeCount ? (_jsx(Badge, { badgeContent: destination.badgeCount, color: "error", max: 99, children: icon })) : icon }, destination.route));
|
|
33
|
+
}) }));
|
|
34
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ export { RegistrationMethodsManager } from './components/RegistrationMethodsMana
|
|
|
30
30
|
export { AuthFactorRequirementCard } from './components/AuthFactorRequirementCard';
|
|
31
31
|
export { AccessCodeSingleUseToggle } from './components/AccessCodeSingleUseToggle';
|
|
32
32
|
export { QrSignupManager } from './components/QrSignupManager';
|
|
33
|
+
export { MobileBottomNav } from './components/MobileBottomNav';
|
|
33
34
|
// --- 6. Charts ---
|
|
34
35
|
export { ChartFrame } from './components/charts/ChartFrame';
|
|
35
36
|
export { BarChart } from './components/charts/BarChart';
|
|
@@ -100,6 +100,22 @@ function createPaletteAwareComponents(palette) {
|
|
|
100
100
|
outlined: { borderColor: palette.controlBorder.main },
|
|
101
101
|
},
|
|
102
102
|
},
|
|
103
|
+
MuiBottomNavigation: {
|
|
104
|
+
styleOverrides: {
|
|
105
|
+
root: {
|
|
106
|
+
backgroundColor: palette.background.paper,
|
|
107
|
+
borderColor: palette.divider,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
MuiBottomNavigationAction: {
|
|
112
|
+
styleOverrides: {
|
|
113
|
+
root: {
|
|
114
|
+
color: palette.text.secondary,
|
|
115
|
+
'&.Mui-selected': { color: palette.primary.main },
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
103
119
|
MuiOutlinedInput: {
|
|
104
120
|
styleOverrides: {
|
|
105
121
|
root: {
|
|
@@ -72,6 +72,26 @@ const COMPONENT_SURFACES = [
|
|
|
72
72
|
var _a, _b, _c, _d, _e, _f;
|
|
73
73
|
return (_f = (_e = (_d = (_c = (_b = (_a = theme.components) === null || _a === void 0 ? void 0 : _a.MuiChip) === null || _b === void 0 ? void 0 : _b.styleOverrides) === null || _c === void 0 ? void 0 : _c.root) === null || _d === void 0 ? void 0 : _d['@media (any-pointer: coarse)']) === null || _e === void 0 ? void 0 : _e['&::after']) === null || _f === void 0 ? void 0 : _f.inset;
|
|
74
74
|
}),
|
|
75
|
+
componentPath('MuiBottomNavigation', 'styleOverrides.root.borderTop'),
|
|
76
|
+
componentPath('MuiBottomNavigation', 'styleOverrides.root.boxShadow'),
|
|
77
|
+
componentPath('MuiBottomNavigation', 'styleOverrides.root.backgroundColor'),
|
|
78
|
+
componentPath('MuiBottomNavigation', 'styleOverrides.root.borderColor'),
|
|
79
|
+
componentPath('MuiBottomNavigationAction', 'styleOverrides.root.minWidth'),
|
|
80
|
+
componentPath('MuiBottomNavigationAction', 'styleOverrides.root.maxWidth'),
|
|
81
|
+
componentPath('MuiBottomNavigationAction', 'styleOverrides.root.padding'),
|
|
82
|
+
componentPath('MuiBottomNavigationAction', 'styleOverrides.root.gap'),
|
|
83
|
+
componentKeyLeaf('MuiBottomNavigationAction', 'styleOverrides.root', '& .MuiSvgIcon-root', 'width'),
|
|
84
|
+
componentKeyLeaf('MuiBottomNavigationAction', 'styleOverrides.root', '& .MuiSvgIcon-root', 'height'),
|
|
85
|
+
componentPath('MuiBottomNavigationAction', 'styleOverrides.root.color'),
|
|
86
|
+
componentPath('MuiBottomNavigationAction', 'styleOverrides.label.fontSize'),
|
|
87
|
+
componentPath('MuiBottomNavigationAction', 'styleOverrides.label.fontWeight'),
|
|
88
|
+
componentPath('MuiBottomNavigationAction', 'styleOverrides.label.lineHeight'),
|
|
89
|
+
componentPath('MuiBottomNavigationAction', 'styleOverrides.label.maxWidth'),
|
|
90
|
+
componentPath('MuiBottomNavigationAction', 'styleOverrides.label.whiteSpace'),
|
|
91
|
+
componentPath('MuiBottomNavigationAction', 'styleOverrides.label.overflow'),
|
|
92
|
+
componentPath('MuiBottomNavigationAction', 'styleOverrides.label.textOverflow'),
|
|
93
|
+
componentKeyLeaf('MuiBottomNavigationAction', 'styleOverrides.label', '&.Mui-selected', 'fontSize'),
|
|
94
|
+
componentKeyLeaf('MuiBottomNavigationAction', 'styleOverrides.root', '&.Mui-selected', 'color'),
|
|
75
95
|
componentPath('MuiTextField', 'defaultProps.variant'),
|
|
76
96
|
componentPath('MuiTextField', 'styleOverrides.root.minHeight'),
|
|
77
97
|
componentKeyLeaf('MuiTextField', 'styleOverrides.root', '@media (any-pointer: coarse)', 'minHeight'),
|
package/dist/theme/tokens.js
CHANGED
|
@@ -260,6 +260,32 @@ export const BASELINE_STATIC = {
|
|
|
260
260
|
},
|
|
261
261
|
},
|
|
262
262
|
},
|
|
263
|
+
MuiBottomNavigation: {
|
|
264
|
+
styleOverrides: {
|
|
265
|
+
root: { borderTop: '1px solid', boxShadow: 'none' },
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
MuiBottomNavigationAction: {
|
|
269
|
+
styleOverrides: {
|
|
270
|
+
root: {
|
|
271
|
+
minWidth: 0,
|
|
272
|
+
maxWidth: 'none',
|
|
273
|
+
padding: '0 2px',
|
|
274
|
+
gap: '2px',
|
|
275
|
+
'& .MuiSvgIcon-root': { width: '22px', height: '22px' },
|
|
276
|
+
},
|
|
277
|
+
label: {
|
|
278
|
+
fontSize: '12px',
|
|
279
|
+
fontWeight: 500,
|
|
280
|
+
lineHeight: 1.2,
|
|
281
|
+
maxWidth: '100%',
|
|
282
|
+
whiteSpace: 'nowrap',
|
|
283
|
+
overflow: 'hidden',
|
|
284
|
+
textOverflow: 'ellipsis',
|
|
285
|
+
'&.Mui-selected': { fontSize: '12px' },
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
},
|
|
263
289
|
MuiTextField: {
|
|
264
290
|
defaultProps: { variant: 'outlined' },
|
|
265
291
|
styleOverrides: { root: Object.assign({ minHeight: 40 }, coarseHitArea) },
|
package/package.json
CHANGED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import Badge from '@mui/material/Badge';
|
|
2
|
+
import BottomNavigation from '@mui/material/BottomNavigation';
|
|
3
|
+
import BottomNavigationAction from '@mui/material/BottomNavigationAction';
|
|
4
|
+
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
5
|
+
import { useTheme } from '@mui/material/styles';
|
|
6
|
+
|
|
7
|
+
const defaultZIndex = (theme) => theme.zIndex.drawer + 2;
|
|
8
|
+
|
|
9
|
+
export function MobileBottomNav({
|
|
10
|
+
destinations,
|
|
11
|
+
activeRoute,
|
|
12
|
+
onNavigate,
|
|
13
|
+
hideAbove = 'md',
|
|
14
|
+
zIndex = defaultZIndex,
|
|
15
|
+
}) {
|
|
16
|
+
const theme = useTheme();
|
|
17
|
+
const isHidden = useMediaQuery(theme.breakpoints.up(hideAbove));
|
|
18
|
+
|
|
19
|
+
if (isHidden) return null;
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<BottomNavigation
|
|
23
|
+
value={activeRoute}
|
|
24
|
+
onChange={(_, route) => onNavigate(route)}
|
|
25
|
+
showLabels
|
|
26
|
+
sx={{
|
|
27
|
+
position: 'fixed',
|
|
28
|
+
left: 0,
|
|
29
|
+
right: 0,
|
|
30
|
+
bottom: 0,
|
|
31
|
+
zIndex,
|
|
32
|
+
paddingBottom: 'env(safe-area-inset-bottom)',
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
{destinations.map((destination) => {
|
|
36
|
+
const Icon = destination.icon;
|
|
37
|
+
const selected = activeRoute === destination.route;
|
|
38
|
+
const icon = (
|
|
39
|
+
<Icon
|
|
40
|
+
sx={destination.emphasis ? {
|
|
41
|
+
p: 0.8,
|
|
42
|
+
borderRadius: '50%',
|
|
43
|
+
backgroundColor: selected ? 'primary.main' : 'background.paper',
|
|
44
|
+
color: selected ? 'primary.contrastText' : 'primary.main',
|
|
45
|
+
boxShadow: 'none',
|
|
46
|
+
transform: 'translateY(-4px)',
|
|
47
|
+
} : undefined}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<BottomNavigationAction
|
|
53
|
+
key={destination.route}
|
|
54
|
+
value={destination.route}
|
|
55
|
+
label={destination.shortLabel ?? destination.label}
|
|
56
|
+
aria-label={destination.shortLabel != null ? destination.label : undefined}
|
|
57
|
+
aria-current={selected ? 'page' : undefined}
|
|
58
|
+
icon={destination.badgeCount ? (
|
|
59
|
+
<Badge badgeContent={destination.badgeCount} color="error" max={99}>
|
|
60
|
+
{icon}
|
|
61
|
+
</Badge>
|
|
62
|
+
) : icon}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
})}
|
|
66
|
+
</BottomNavigation>
|
|
67
|
+
);
|
|
68
|
+
}
|
package/src/index.js
CHANGED
|
@@ -48,6 +48,7 @@ export { RegistrationMethodsManager } from './components/RegistrationMethodsMana
|
|
|
48
48
|
export { AuthFactorRequirementCard } from './components/AuthFactorRequirementCard';
|
|
49
49
|
export { AccessCodeSingleUseToggle } from './components/AccessCodeSingleUseToggle';
|
|
50
50
|
export { QrSignupManager } from './components/QrSignupManager';
|
|
51
|
+
export { MobileBottomNav } from './components/MobileBottomNav';
|
|
51
52
|
|
|
52
53
|
// --- 6. Charts ---
|
|
53
54
|
export { ChartFrame } from './components/charts/ChartFrame';
|
|
@@ -116,6 +116,22 @@ function createPaletteAwareComponents(palette) {
|
|
|
116
116
|
outlined: { borderColor: palette.controlBorder.main },
|
|
117
117
|
},
|
|
118
118
|
},
|
|
119
|
+
MuiBottomNavigation: {
|
|
120
|
+
styleOverrides: {
|
|
121
|
+
root: {
|
|
122
|
+
backgroundColor: palette.background.paper,
|
|
123
|
+
borderColor: palette.divider,
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
MuiBottomNavigationAction: {
|
|
128
|
+
styleOverrides: {
|
|
129
|
+
root: {
|
|
130
|
+
color: palette.text.secondary,
|
|
131
|
+
'&.Mui-selected': { color: palette.primary.main },
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
},
|
|
119
135
|
MuiOutlinedInput: {
|
|
120
136
|
styleOverrides: {
|
|
121
137
|
root: {
|
|
@@ -96,6 +96,26 @@ const COMPONENT_SURFACES = [
|
|
|
96
96
|
(theme) => theme.components?.MuiChip?.styleOverrides?.root
|
|
97
97
|
?.['@media (any-pointer: coarse)']?.['&::after']?.inset,
|
|
98
98
|
),
|
|
99
|
+
componentPath('MuiBottomNavigation', 'styleOverrides.root.borderTop'),
|
|
100
|
+
componentPath('MuiBottomNavigation', 'styleOverrides.root.boxShadow'),
|
|
101
|
+
componentPath('MuiBottomNavigation', 'styleOverrides.root.backgroundColor'),
|
|
102
|
+
componentPath('MuiBottomNavigation', 'styleOverrides.root.borderColor'),
|
|
103
|
+
componentPath('MuiBottomNavigationAction', 'styleOverrides.root.minWidth'),
|
|
104
|
+
componentPath('MuiBottomNavigationAction', 'styleOverrides.root.maxWidth'),
|
|
105
|
+
componentPath('MuiBottomNavigationAction', 'styleOverrides.root.padding'),
|
|
106
|
+
componentPath('MuiBottomNavigationAction', 'styleOverrides.root.gap'),
|
|
107
|
+
componentKeyLeaf('MuiBottomNavigationAction', 'styleOverrides.root', '& .MuiSvgIcon-root', 'width'),
|
|
108
|
+
componentKeyLeaf('MuiBottomNavigationAction', 'styleOverrides.root', '& .MuiSvgIcon-root', 'height'),
|
|
109
|
+
componentPath('MuiBottomNavigationAction', 'styleOverrides.root.color'),
|
|
110
|
+
componentPath('MuiBottomNavigationAction', 'styleOverrides.label.fontSize'),
|
|
111
|
+
componentPath('MuiBottomNavigationAction', 'styleOverrides.label.fontWeight'),
|
|
112
|
+
componentPath('MuiBottomNavigationAction', 'styleOverrides.label.lineHeight'),
|
|
113
|
+
componentPath('MuiBottomNavigationAction', 'styleOverrides.label.maxWidth'),
|
|
114
|
+
componentPath('MuiBottomNavigationAction', 'styleOverrides.label.whiteSpace'),
|
|
115
|
+
componentPath('MuiBottomNavigationAction', 'styleOverrides.label.overflow'),
|
|
116
|
+
componentPath('MuiBottomNavigationAction', 'styleOverrides.label.textOverflow'),
|
|
117
|
+
componentKeyLeaf('MuiBottomNavigationAction', 'styleOverrides.label', '&.Mui-selected', 'fontSize'),
|
|
118
|
+
componentKeyLeaf('MuiBottomNavigationAction', 'styleOverrides.root', '&.Mui-selected', 'color'),
|
|
99
119
|
componentPath('MuiTextField', 'defaultProps.variant'),
|
|
100
120
|
componentPath('MuiTextField', 'styleOverrides.root.minHeight'),
|
|
101
121
|
componentKeyLeaf('MuiTextField', 'styleOverrides.root', '@media (any-pointer: coarse)', 'minHeight'),
|
package/src/theme/tokens.js
CHANGED
|
@@ -306,6 +306,32 @@ export const BASELINE_STATIC = {
|
|
|
306
306
|
},
|
|
307
307
|
},
|
|
308
308
|
},
|
|
309
|
+
MuiBottomNavigation: {
|
|
310
|
+
styleOverrides: {
|
|
311
|
+
root: { borderTop: '1px solid', boxShadow: 'none' },
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
MuiBottomNavigationAction: {
|
|
315
|
+
styleOverrides: {
|
|
316
|
+
root: {
|
|
317
|
+
minWidth: 0,
|
|
318
|
+
maxWidth: 'none',
|
|
319
|
+
padding: '0 2px',
|
|
320
|
+
gap: '2px',
|
|
321
|
+
'& .MuiSvgIcon-root': { width: '22px', height: '22px' },
|
|
322
|
+
},
|
|
323
|
+
label: {
|
|
324
|
+
fontSize: '12px',
|
|
325
|
+
fontWeight: 500,
|
|
326
|
+
lineHeight: 1.2,
|
|
327
|
+
maxWidth: '100%',
|
|
328
|
+
whiteSpace: 'nowrap',
|
|
329
|
+
overflow: 'hidden',
|
|
330
|
+
textOverflow: 'ellipsis',
|
|
331
|
+
'&.Mui-selected': { fontSize: '12px' },
|
|
332
|
+
},
|
|
333
|
+
},
|
|
334
|
+
},
|
|
309
335
|
MuiTextField: {
|
|
310
336
|
defaultProps: { variant: 'outlined' },
|
|
311
337
|
styleOverrides: { root: { minHeight: 40, ...coarseHitArea } },
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
4
|
+
import { cleanup, fireEvent, render, screen, within } from '@testing-library/react';
|
|
5
|
+
import { ThemeProvider, createTheme } from '@mui/material/styles';
|
|
6
|
+
|
|
7
|
+
import { MobileBottomNav } from '../src/components/MobileBottomNav';
|
|
8
|
+
import { createAppTheme } from '../src/theme/createAppTheme';
|
|
9
|
+
|
|
10
|
+
const theme = createAppTheme({ palette: { primary: { main: '#0F62FE' } } });
|
|
11
|
+
|
|
12
|
+
function Icon() {
|
|
13
|
+
return <svg aria-hidden="true" data-testid="destination-icon" />;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const destinations = [
|
|
17
|
+
{ route: '/first', label: 'First', icon: Icon },
|
|
18
|
+
{ route: '/second', label: 'Second', icon: Icon },
|
|
19
|
+
{ route: '/third', label: 'Third', icon: Icon },
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
function setMediaQueryMatches(matches) {
|
|
23
|
+
window.matchMedia = vi.fn().mockImplementation((query) => ({
|
|
24
|
+
matches: typeof matches === 'function' ? matches(query) : matches,
|
|
25
|
+
media: query,
|
|
26
|
+
onchange: null,
|
|
27
|
+
addEventListener: vi.fn(),
|
|
28
|
+
removeEventListener: vi.fn(),
|
|
29
|
+
addListener: vi.fn(),
|
|
30
|
+
removeListener: vi.fn(),
|
|
31
|
+
dispatchEvent: vi.fn(),
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function setViewportWidth(width) {
|
|
36
|
+
setMediaQueryMatches((query) => {
|
|
37
|
+
const minWidth = query.match(/min-width:(\d+)px/)?.[1];
|
|
38
|
+
return minWidth ? width >= Number(minWidth) : false;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function renderNav(props = {}) {
|
|
43
|
+
return render(
|
|
44
|
+
<ThemeProvider theme={theme}>
|
|
45
|
+
<MobileBottomNav
|
|
46
|
+
destinations={destinations}
|
|
47
|
+
activeRoute="/first"
|
|
48
|
+
onNavigate={vi.fn()}
|
|
49
|
+
{...props}
|
|
50
|
+
/>
|
|
51
|
+
</ThemeProvider>,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
describe('MobileBottomNav', () => {
|
|
56
|
+
beforeEach(() => setMediaQueryMatches(false));
|
|
57
|
+
|
|
58
|
+
afterEach(() => {
|
|
59
|
+
cleanup();
|
|
60
|
+
vi.restoreAllMocks();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('renders one action per destination, in order, with visible labels', () => {
|
|
64
|
+
renderNav();
|
|
65
|
+
|
|
66
|
+
expect(screen.getAllByRole('button').map((action) => action.textContent)).toEqual([
|
|
67
|
+
'First',
|
|
68
|
+
'Second',
|
|
69
|
+
'Third',
|
|
70
|
+
]);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('selects exactly the matching route and tolerates no match', () => {
|
|
74
|
+
const { rerender } = renderNav({ activeRoute: '/second' });
|
|
75
|
+
const selected = () => screen.getAllByRole('button')
|
|
76
|
+
.filter((action) => action.classList.contains('Mui-selected'));
|
|
77
|
+
|
|
78
|
+
expect(selected()).toHaveLength(1);
|
|
79
|
+
expect(selected()[0].textContent).toBe('Second');
|
|
80
|
+
expect(selected()[0].getAttribute('aria-current')).toBe('page');
|
|
81
|
+
expect(screen.getAllByRole('button').filter((action) => action.hasAttribute('aria-current')))
|
|
82
|
+
.toHaveLength(1);
|
|
83
|
+
|
|
84
|
+
rerender(
|
|
85
|
+
<ThemeProvider theme={theme}>
|
|
86
|
+
<MobileBottomNav
|
|
87
|
+
destinations={destinations}
|
|
88
|
+
activeRoute="/not-in-the-bar"
|
|
89
|
+
onNavigate={vi.fn()}
|
|
90
|
+
/>
|
|
91
|
+
</ThemeProvider>,
|
|
92
|
+
);
|
|
93
|
+
expect(selected()).toHaveLength(0);
|
|
94
|
+
expect(screen.getAllByRole('button').some((action) => action.hasAttribute('aria-current')))
|
|
95
|
+
.toBe(false);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('calls onNavigate with the selected destination route', () => {
|
|
99
|
+
const onNavigate = vi.fn();
|
|
100
|
+
renderNav({ onNavigate });
|
|
101
|
+
|
|
102
|
+
fireEvent.click(screen.getByRole('button', { name: 'Second' }));
|
|
103
|
+
|
|
104
|
+
expect(onNavigate).toHaveBeenCalledOnce();
|
|
105
|
+
expect(onNavigate).toHaveBeenCalledWith('/second');
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('renders a positive badge only on its own destination', () => {
|
|
109
|
+
renderNav({
|
|
110
|
+
destinations: [
|
|
111
|
+
{ route: '/inbox', label: 'Inbox', icon: Icon, badgeCount: 4 },
|
|
112
|
+
{ route: '/empty', label: 'Empty', icon: Icon, badgeCount: 0 },
|
|
113
|
+
{ route: '/unset', label: 'Unset', icon: Icon },
|
|
114
|
+
],
|
|
115
|
+
activeRoute: '/inbox',
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const actions = screen.getAllByRole('button');
|
|
119
|
+
expect(within(actions[0]).getByText('4')).toBeTruthy();
|
|
120
|
+
expect(actions[0].querySelectorAll('.MuiBadge-root')).toHaveLength(1);
|
|
121
|
+
expect(actions[1].querySelector('.MuiBadge-root')).toBeNull();
|
|
122
|
+
expect(actions[2].querySelector('.MuiBadge-root')).toBeNull();
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('uses shortLabel when present and label when it is absent', () => {
|
|
126
|
+
renderNav({
|
|
127
|
+
destinations: [
|
|
128
|
+
{ route: '/registrations', label: 'My registrations', shortLabel: 'Mine', icon: Icon },
|
|
129
|
+
{ route: '/messages', label: 'Messages', icon: Icon },
|
|
130
|
+
],
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
expect(screen.getAllByRole('button').map((action) => action.textContent)).toEqual([
|
|
134
|
+
'Mine',
|
|
135
|
+
'Messages',
|
|
136
|
+
]);
|
|
137
|
+
expect(screen.getByRole('button', { name: 'My registrations' }).textContent).toBe('Mine');
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('resolves its surface and action colours from both baseline and plain MUI themes', () => {
|
|
141
|
+
const themes = [
|
|
142
|
+
createAppTheme({
|
|
143
|
+
palette: {
|
|
144
|
+
primary: { main: '#123456' },
|
|
145
|
+
background: { paper: '#F1F2F3' },
|
|
146
|
+
text: { secondary: '#445566' },
|
|
147
|
+
},
|
|
148
|
+
}),
|
|
149
|
+
createTheme({
|
|
150
|
+
palette: {
|
|
151
|
+
primary: { main: '#654321' },
|
|
152
|
+
background: { paper: '#E7E8E9' },
|
|
153
|
+
text: { secondary: '#665544' },
|
|
154
|
+
},
|
|
155
|
+
}),
|
|
156
|
+
];
|
|
157
|
+
const expected = [
|
|
158
|
+
{ background: 'rgb(241, 242, 243)', selected: 'rgb(18, 52, 86)', rest: 'rgb(68, 85, 102)' },
|
|
159
|
+
{ background: 'rgb(231, 232, 233)', selected: 'rgb(101, 67, 33)', rest: 'rgb(102, 85, 68)' },
|
|
160
|
+
];
|
|
161
|
+
|
|
162
|
+
themes.forEach((currentTheme, index) => {
|
|
163
|
+
const { container } = render(
|
|
164
|
+
<ThemeProvider theme={currentTheme}>
|
|
165
|
+
<MobileBottomNav
|
|
166
|
+
destinations={destinations}
|
|
167
|
+
activeRoute="/first"
|
|
168
|
+
onNavigate={vi.fn()}
|
|
169
|
+
/>
|
|
170
|
+
</ThemeProvider>,
|
|
171
|
+
);
|
|
172
|
+
const actions = screen.getAllByRole('button');
|
|
173
|
+
|
|
174
|
+
expect(getComputedStyle(container.firstElementChild).backgroundColor)
|
|
175
|
+
.toBe(expected[index].background);
|
|
176
|
+
expect(getComputedStyle(actions[0]).color).toBe(expected[index].selected);
|
|
177
|
+
expect(getComputedStyle(actions[1]).color).toBe(expected[index].rest);
|
|
178
|
+
cleanup();
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it('renders nothing at and above hideAbove', () => {
|
|
183
|
+
setMediaQueryMatches((query) => query === '(min-width:900px)');
|
|
184
|
+
const { container } = renderNav();
|
|
185
|
+
|
|
186
|
+
expect(window.matchMedia).toHaveBeenCalledWith('(min-width:900px)');
|
|
187
|
+
expect(container.childElementCount).toBe(0);
|
|
188
|
+
expect(screen.queryByRole('navigation')).toBeNull();
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('declares safe-area bottom padding on the fixed bar', () => {
|
|
192
|
+
const { container } = renderNav();
|
|
193
|
+
const nav = container.firstElementChild;
|
|
194
|
+
|
|
195
|
+
expect(nav.classList.contains('MuiBottomNavigation-root')).toBe(true);
|
|
196
|
+
// jsdom drops env() declarations while parsing CSS, so assert the sx
|
|
197
|
+
// declaration before browser CSS parsing instead of a computed inset.
|
|
198
|
+
expect(MobileBottomNav.toString()).toContain('env(safe-area-inset-bottom)');
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it('renders the five-item, two-badge specimen at 375px and nothing at 1280px', () => {
|
|
202
|
+
const specimen = [
|
|
203
|
+
{ route: '/triage', label: 'Triage', icon: Icon, badgeCount: 7 },
|
|
204
|
+
{ route: '/board', label: 'Board', icon: Icon, badgeCount: 3 },
|
|
205
|
+
{ route: '/chat', label: 'Chat', icon: Icon },
|
|
206
|
+
{ route: '/status', label: 'Status', icon: Icon },
|
|
207
|
+
{ route: '/more', label: 'More', icon: Icon, emphasis: true },
|
|
208
|
+
];
|
|
209
|
+
|
|
210
|
+
setViewportWidth(375);
|
|
211
|
+
renderNav({ destinations: specimen, activeRoute: '/triage' });
|
|
212
|
+
expect(screen.getAllByRole('button')).toHaveLength(5);
|
|
213
|
+
expect(document.querySelectorAll('.MuiBadge-root')).toHaveLength(2);
|
|
214
|
+
|
|
215
|
+
cleanup();
|
|
216
|
+
setViewportWidth(1280);
|
|
217
|
+
renderNav({ destinations: specimen, activeRoute: '/triage' });
|
|
218
|
+
expect(screen.queryByRole('button')).toBeNull();
|
|
219
|
+
});
|
|
220
|
+
});
|
|
@@ -12,6 +12,23 @@ describe('createAppTheme', () => {
|
|
|
12
12
|
expect(theme.typography.body1.fontSize).toBe('14px');
|
|
13
13
|
expect(theme.shape.borderRadius).toBe(3);
|
|
14
14
|
expect(theme.components.MuiPaper.defaultProps).toMatchObject({ elevation: 0, variant: 'outlined' });
|
|
15
|
+
expect(theme.components.MuiBottomNavigationAction.styleOverrides.label).toMatchObject({
|
|
16
|
+
fontSize: '12px',
|
|
17
|
+
fontWeight: 500,
|
|
18
|
+
lineHeight: 1.2,
|
|
19
|
+
maxWidth: '100%',
|
|
20
|
+
whiteSpace: 'nowrap',
|
|
21
|
+
overflow: 'hidden',
|
|
22
|
+
textOverflow: 'ellipsis',
|
|
23
|
+
'&.Mui-selected': { fontSize: '12px' },
|
|
24
|
+
});
|
|
25
|
+
expect(theme.components.MuiBottomNavigationAction.styleOverrides.root).toMatchObject({
|
|
26
|
+
minWidth: 0,
|
|
27
|
+
maxWidth: 'none',
|
|
28
|
+
padding: '0 2px',
|
|
29
|
+
gap: '2px',
|
|
30
|
+
'& .MuiSvgIcon-root': { width: '22px', height: '22px' },
|
|
31
|
+
});
|
|
15
32
|
expect(theme.palette.dataSeries.categorical).toHaveLength(6);
|
|
16
33
|
expect(theme.palette.primary.light).not.toBe(createTheme().palette.primary.light);
|
|
17
34
|
// MUI's createTheme(options, ...args) only augments the FIRST argument's
|
|
@@ -19,6 +19,28 @@ describe('theme completeness', () => {
|
|
|
19
19
|
expect(assertThemeComplete(createTheme({ components: { MuiButton: {} } })).findings
|
|
20
20
|
.map(({ surface }) => surface))
|
|
21
21
|
.toContain('components.MuiButton.styleOverrides.root.minHeight');
|
|
22
|
+
expect(bare.findings.map(({ surface }) => surface)).toEqual(expect.arrayContaining([
|
|
23
|
+
'components.MuiBottomNavigation.styleOverrides.root.borderTop',
|
|
24
|
+
'components.MuiBottomNavigation.styleOverrides.root.boxShadow',
|
|
25
|
+
'components.MuiBottomNavigation.styleOverrides.root.backgroundColor',
|
|
26
|
+
'components.MuiBottomNavigation.styleOverrides.root.borderColor',
|
|
27
|
+
'components.MuiBottomNavigationAction.styleOverrides.root.minWidth',
|
|
28
|
+
'components.MuiBottomNavigationAction.styleOverrides.root.maxWidth',
|
|
29
|
+
'components.MuiBottomNavigationAction.styleOverrides.root.padding',
|
|
30
|
+
'components.MuiBottomNavigationAction.styleOverrides.root.gap',
|
|
31
|
+
'components.MuiBottomNavigationAction.styleOverrides.root.& .MuiSvgIcon-root.width',
|
|
32
|
+
'components.MuiBottomNavigationAction.styleOverrides.root.& .MuiSvgIcon-root.height',
|
|
33
|
+
'components.MuiBottomNavigationAction.styleOverrides.root.color',
|
|
34
|
+
'components.MuiBottomNavigationAction.styleOverrides.label.fontSize',
|
|
35
|
+
'components.MuiBottomNavigationAction.styleOverrides.label.fontWeight',
|
|
36
|
+
'components.MuiBottomNavigationAction.styleOverrides.label.lineHeight',
|
|
37
|
+
'components.MuiBottomNavigationAction.styleOverrides.label.maxWidth',
|
|
38
|
+
'components.MuiBottomNavigationAction.styleOverrides.label.whiteSpace',
|
|
39
|
+
'components.MuiBottomNavigationAction.styleOverrides.label.overflow',
|
|
40
|
+
'components.MuiBottomNavigationAction.styleOverrides.label.textOverflow',
|
|
41
|
+
'components.MuiBottomNavigationAction.styleOverrides.label.&.Mui-selected.fontSize',
|
|
42
|
+
'components.MuiBottomNavigationAction.styleOverrides.root.&.Mui-selected.color',
|
|
43
|
+
]));
|
|
22
44
|
expect(baseline.findings).toEqual([]);
|
|
23
45
|
});
|
|
24
46
|
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
# SHELL-3 — Promote the mobile bottom navigation into the shared kit
|
|
2
|
+
|
|
3
|
+
**Target repo:** `ui-core-micha` (branch `main` — this repo has no `develop`)
|
|
4
|
+
**Tier:** 3 (shared core)
|
|
5
|
+
**Review:** independent `reviewer` **and** `ui_reviewer` — spawned concurrently, both mandatory before commit
|
|
6
|
+
**Version target:** `2.33.0` — minor: a new public component plus additive theme defaults
|
|
7
|
+
**Precondition of:** `cockpit/UI-3` and `jg-ferien/NAV-36`
|
|
8
|
+
**Visual spec:** `cockpit/work-orders/assets/UI-3-nav-redesign.html` (sections 3 and 4)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## A. Envelope
|
|
13
|
+
|
|
14
|
+
### Goal
|
|
15
|
+
|
|
16
|
+
Two apps need a mobile bottom navigation. jg-ferien has one
|
|
17
|
+
(`frontend/src/components/mobileShell/MobileBottomNav.jsx`, 107 lines) and cockpit is about to
|
|
18
|
+
need one. Promote it, so cockpit does not hand-build a second and jg's copy can be deleted.
|
|
19
|
+
|
|
20
|
+
The API is derived from **both** cases rather than from jg alone — that comparison is what
|
|
21
|
+
`DS-6` asked for, and it is documented in the prototype's section 4. Each recorded promotion
|
|
22
|
+
blocker in jg's version becomes a declarative field, and in each case cockpit is what proves the
|
|
23
|
+
field is genuinely optional rather than a jg quirk.
|
|
24
|
+
|
|
25
|
+
### Why this is a promotion and not a copy
|
|
26
|
+
|
|
27
|
+
jg's structure is sound; its **presentation layer is not overridable**. Every value is an `sx`
|
|
28
|
+
literal with no prop seam, app route literals drive the special visual treatment, and it depends
|
|
29
|
+
directly on a jg-specific messaging hook. A consumer could only fork it. This work order splits
|
|
30
|
+
that: **style defaults move into the theme baseline, structure and behaviour into the component,
|
|
31
|
+
app specifics into props.**
|
|
32
|
+
|
|
33
|
+
### Scope — two labelled parts, one release
|
|
34
|
+
|
|
35
|
+
#### Part 1 — the baseline gains bottom-navigation defaults
|
|
36
|
+
|
|
37
|
+
Add `MuiBottomNavigation` and `MuiBottomNavigationAction` to `src/theme/tokens.js`'s `components`
|
|
38
|
+
block, and register the corresponding surfaces in `src/theme/themeCompleteness.js`.
|
|
39
|
+
|
|
40
|
+
What the defaults must express, all from existing baseline tokens:
|
|
41
|
+
|
|
42
|
+
- the bar surface is `background.paper` with a top `divider` border and **no resting shadow**
|
|
43
|
+
(baseline rule: resting surfaces are flat);
|
|
44
|
+
- action colour `text.secondary`, selected `primary.main`;
|
|
45
|
+
- label `12px` at weight `500` — this is the one value the prototype flagged as a delta, and it
|
|
46
|
+
is resolved **here**, as a component default, not as a new typography token;
|
|
47
|
+
- `minWidth: 0` and `maxWidth: 'none'` on the action, so a five-item bar divides evenly at
|
|
48
|
+
375 px instead of hitting MUI's default `minWidth: 80`.
|
|
49
|
+
|
|
50
|
+
**Two hard constraints of this file, both already enforced by existing tests:**
|
|
51
|
+
|
|
52
|
+
- **Objects only.** No function may appear anywhere in the baseline `components` tree
|
|
53
|
+
(`tests/createAppTheme.test.js` asserts this). MUI's multi-arg deep merge treats a function as
|
|
54
|
+
a leaf in both directions, so a function default silently becomes unoverridable. jg's current
|
|
55
|
+
`zIndex: (theme) => theme.zIndex.drawer + 2` therefore **cannot** move into the theme — it
|
|
56
|
+
stays in the component (see part 2).
|
|
57
|
+
- **Palette-first ordering.** Palette resolution happens before palette-aware component objects
|
|
58
|
+
are built, so any default that reads a palette value must follow that existing pattern in
|
|
59
|
+
`createAppTheme.js` rather than being added to the static block.
|
|
60
|
+
|
|
61
|
+
#### Part 2 — the `MobileBottomNav` component
|
|
62
|
+
|
|
63
|
+
Exported from `src/index.js`. Keep the name — it matches what jg already calls it, which keeps
|
|
64
|
+
`NAV-36`'s migration a swap rather than a rename.
|
|
65
|
+
|
|
66
|
+
Props:
|
|
67
|
+
|
|
68
|
+
| Prop | Meaning |
|
|
69
|
+
|---|---|
|
|
70
|
+
| `destinations` | ordered array of `{ route, label, icon, shortLabel?, emphasis?, badgeCount? }` |
|
|
71
|
+
| `activeRoute` | the currently active route; the app derives it, the component does not guess |
|
|
72
|
+
| `onNavigate` | called with a destination's `route` |
|
|
73
|
+
| `hideAbove` | breakpoint above which the bar renders nothing. Default `'md'` |
|
|
74
|
+
| `zIndex` | default `theme.zIndex.drawer + 2`, overridable — SHELL-2 named the hardcoded-zIndex trap and this is the same class |
|
|
75
|
+
|
|
76
|
+
Field semantics, each with its evidence:
|
|
77
|
+
|
|
78
|
+
- **`label` is a finished string, not an i18n key.** jg translates inside the component today,
|
|
79
|
+
cockpit outside. Finished strings are what `SHELL-1` and `DS-11` already settled for shared
|
|
80
|
+
components — the kit must not know an app's key namespace.
|
|
81
|
+
- **`shortLabel`** is optional and falls back to `label`. **Carry it for jg alone.** An earlier
|
|
82
|
+
draft of the prototype claimed cockpit independently proved the need; that claim was withdrawn
|
|
83
|
+
when Einstellungen moved behind Mehr. One consumer, one reason — do not document it as
|
|
84
|
+
twice-confirmed.
|
|
85
|
+
- **`emphasis`** replaces jg's hardcoded check for `/my-registrations`. cockpit sets it on no
|
|
86
|
+
destination, which is what proves it optional.
|
|
87
|
+
- **`badgeCount` is per destination.** jg has one badge from a messaging hook; cockpit has two
|
|
88
|
+
from its own data. The second case is what makes per-destination correct rather than a single
|
|
89
|
+
`unreadCount`.
|
|
90
|
+
|
|
91
|
+
Behaviour the component owns: the fixed positioning, the top border, the breakpoint hide, and
|
|
92
|
+
**`padding-bottom: env(safe-area-inset-bottom)`** so a notched phone's home indicator does not
|
|
93
|
+
sit on the labels.
|
|
94
|
+
|
|
95
|
+
Behaviour the component does **not** own:
|
|
96
|
+
|
|
97
|
+
- **No auth gate.** jg's version returns `null` when there is no user. That is app logic; the app
|
|
98
|
+
decides whether to render the bar at all.
|
|
99
|
+
- **No overflow logic.** The app passes the bar's own destination list. jg puts all five of its
|
|
100
|
+
destinations in; cockpit puts four of six plus a `Mehr` destination whose route leads to its own
|
|
101
|
+
page. "Mehr" is an ordinary destination as far as the kit is concerned. This is what keeps the
|
|
102
|
+
component thin, and it was a deliberate decision against an overlay sheet, which would have
|
|
103
|
+
added open/close state, a scrim, a focus trap, Escape handling and a reduced-motion path to a
|
|
104
|
+
shared component on the strength of two consumers.
|
|
105
|
+
|
|
106
|
+
### Design-agnosticism: what the bar derives from, and what it does not guarantee
|
|
107
|
+
|
|
108
|
+
**No hex value appears in the component.** The bar is composed entirely from tokens —
|
|
109
|
+
`background.paper` for its surface, `divider` for its top edge, `text.secondary` for the label,
|
|
110
|
+
`primary.main` for the selected state — so an app with a different surface colour gets a different
|
|
111
|
+
bar without touching the kit. A second seam exists above that: an app may override
|
|
112
|
+
`MuiBottomNavigation` / `MuiBottomNavigationAction` in **its own** theme. That is not an escape
|
|
113
|
+
hatch, it is the mechanism, and it is the reason part 1 puts the defaults in the theme rather than
|
|
114
|
+
in the component. Values inside the component are exactly jg's current problem.
|
|
115
|
+
|
|
116
|
+
Three limits must be stated rather than discovered:
|
|
117
|
+
|
|
118
|
+
- **Contrast is not guaranteed, and nothing checks it.** `assertThemeComplete`'s contrast surfaces
|
|
119
|
+
are hardcoded to `#FFFFFF` and `background.default`; **`background.paper` is never a contrast
|
|
120
|
+
surface, and `text.secondary` is never checked against anything.** An app with a dark or
|
|
121
|
+
saturated `background.paper` therefore gets a correctly-rendered, unreadable bar and **zero
|
|
122
|
+
findings**. For baseline apps this is comfortable — `#5B6670` on `#FFFFFF` measures 5.87:1 and on
|
|
123
|
+
`#FAFAFA` 5.62:1 (MUI's own `getContrastRatio`) — so this is a limit for deviating apps, not a
|
|
124
|
+
defect in the default. **Do not extend the shared contrast assertion inside this WO**: adding a
|
|
125
|
+
surface changes what every adopting app is measured against, which is a deliberate governance
|
|
126
|
+
decision belonging to `DS-18` (invariant-scoped coverage), not a side effect of shipping a
|
|
127
|
+
component.
|
|
128
|
+
- **The separation from the page depends on `background.paper` differing from
|
|
129
|
+
`background.default`.** The bar has no resting shadow by baseline rule, so its edge comes from
|
|
130
|
+
one tonal step (`#FFFFFF` against `#FAFAFA`) plus a 1 px divider. In an app where those two
|
|
131
|
+
tokens are the same colour, only the divider carries it and the bar reads as glued to the page.
|
|
132
|
+
That is an acceptable outcome, but it must be a known one.
|
|
133
|
+
- **A tooling trap for anyone verifying the above:** MUI's `getContrastRatio` ignores alpha —
|
|
134
|
+
`rgba(0, 0, 0, 0.6)` on white returns `21.00`, the figure for pure black. jg-ferien keeps its own
|
|
135
|
+
`createTheme` and therefore MUI's alpha-based `text.secondary`, so a contrast check against jg's
|
|
136
|
+
theme is meaningless. Verify jg by looking, not by computing.
|
|
137
|
+
|
|
138
|
+
### Non-goals / do not touch
|
|
139
|
+
|
|
140
|
+
- **No `AppHeaderMobile` promotion.** jg's is mostly app wiring around already-shared pieces.
|
|
141
|
+
- No change to `UserMenu`, `NotificationBell`, `ChartFrame` or any chart wrapper.
|
|
142
|
+
- No change to any existing baseline token value. Part 1 **adds** two component keys; it does not
|
|
143
|
+
edit typography, palette, shape, spacing or the `shadows` array.
|
|
144
|
+
- No dark-mode work (`DS-12` owns that, on its own trigger).
|
|
145
|
+
- No migration of jg-ferien — that is `NAV-36`, deliberately separate.
|
|
146
|
+
|
|
147
|
+
### Risks
|
|
148
|
+
|
|
149
|
+
- **No staging net.** A version bump on `main` publishes to npm; the independent review is the
|
|
150
|
+
only gate and cannot be back-filled. Publishing is version-gated, so the release happens when
|
|
151
|
+
`package.json`'s version exceeds the live one — not on every push.
|
|
152
|
+
- **Adding assertion surfaces raises the bar for every adopting app.** The values come from the
|
|
153
|
+
baseline, so `assertThemeComplete` stays green for apps built through `createAppTheme` — but
|
|
154
|
+
verify that explicitly rather than assuming it, because a missed surface would turn an unrelated
|
|
155
|
+
app's suite red on its next pin bump.
|
|
156
|
+
- **`minWidth: 0` on the action is a deliberate deviation from MUI's default.** It is what makes a
|
|
157
|
+
five-item bar work at 375 px; it also means a six-item bar will truncate labels rather than
|
|
158
|
+
scroll. That is the intended failure mode — the prototype's measurement shows six items do not
|
|
159
|
+
fit — but it must be a conscious default, not a surprise.
|
|
160
|
+
|
|
161
|
+
### Required tests to WRITE
|
|
162
|
+
|
|
163
|
+
1. `destinations` renders one action per entry, in order, with `label` as the visible text.
|
|
164
|
+
2. `activeRoute` marks exactly the matching action selected; a route matching nothing selects
|
|
165
|
+
none and does not throw.
|
|
166
|
+
3. `onNavigate` fires with the destination's `route`.
|
|
167
|
+
4. `badgeCount` renders on the destination that has it and **not** on the others; a count of `0`
|
|
168
|
+
or `undefined` renders no badge.
|
|
169
|
+
5. `shortLabel` is used when present, `label` when absent.
|
|
170
|
+
5b. **Theme-agnosticism, asserted rather than assumed.** Render the same bar under two themes whose
|
|
171
|
+
`background.paper`, `text.secondary` and `primary.main` differ, and assert the resolved computed
|
|
172
|
+
values follow the theme in both. This is what proves no colour is baked into the component — the
|
|
173
|
+
single most likely regression, because an `sx` literal looks correct in the app it was written
|
|
174
|
+
for. Include one theme that is **not** built by `createAppTheme`, since jg-ferien is exactly that
|
|
175
|
+
case and `NAV-36` depends on it working.
|
|
176
|
+
6. Above `hideAbove` the component renders nothing.
|
|
177
|
+
7. `assertThemeComplete(createAppTheme({ palette: { primary: { main: '#0F62FE' } } })).findings`
|
|
178
|
+
stays `[]` with the new surfaces registered — and **prove non-vacuity**: a theme missing the
|
|
179
|
+
new component defaults must produce findings naming them.
|
|
180
|
+
|
|
181
|
+
Plus `tsc -p tsconfig.build.json --noEmit` clean. **No full-suite run** — the affected set is the
|
|
182
|
+
new component's spec plus `tests/themeCompleteness.test.js` and `tests/createAppTheme.test.js`.
|
|
183
|
+
|
|
184
|
+
### Verification
|
|
185
|
+
|
|
186
|
+
The rendered two-width side-by-side per `DS-1`, against the prototype's sections 3 and 4. Add a
|
|
187
|
+
harness specimen to `dev/entries.jsx` — no existing specimen has a bottom navigation, and
|
|
188
|
+
`CHART-7` set the precedent of adding one rather than declaring the gate unmeetable. Show a
|
|
189
|
+
five-item bar with two badges at 375 px, and confirm it renders nothing at 1280 px.
|
|
190
|
+
|
|
191
|
+
State in the register note whether real screenshots were obtained or DOM inspection substituted.
|
|
192
|
+
**The safe-area padding cannot be verified either way** — a desktop 375 px viewport always
|
|
193
|
+
reports an inset of zero, the same wall `TPL-1` hit. Specify it, assert the CSS is present, and
|
|
194
|
+
record it as unverified rather than done.
|
|
195
|
+
|
|
196
|
+
### Parity guardrail
|
|
197
|
+
|
|
198
|
+
For jg-ferien this must be a behavioural no-op once `NAV-36` swaps to it: same destinations, same
|
|
199
|
+
active-route derivation, same badge, same raised treatment on its emphasised destination. Two
|
|
200
|
+
known differences are intended and belong in `NAV-36`'s note, not here: the German literal
|
|
201
|
+
fallback `'Meine'` disappears (the app passes finished strings), and `background.white` — a
|
|
202
|
+
jg-only palette extension — is replaced by the baseline surface.
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## B. Implementation map
|
|
207
|
+
|
|
208
|
+
*Filled by the Orchestrator on `git pull` — see `AGENTS.md` → "Work Order".*
|
|
209
|
+
|
|
210
|
+
### Execution directive (read this first)
|
|
211
|
+
|
|
212
|
+
> **If you are the implementer reading this work order as your own specification: this section is
|
|
213
|
+
> NOT addressed to you.** It tells the Orchestrator how to invoke you. **You ARE that invocation —
|
|
214
|
+
> do NOT shell out to `codex exec`.**
|
|
215
|
+
>
|
|
216
|
+
> Implement through `codex exec` in the background — invoked directly via Bash (never the
|
|
217
|
+
> `debugger`/`*_coder` Agent wrappers) with BOTH flags `--skip-git-repo-check` and
|
|
218
|
+
> `--dangerously-bypass-approvals-and-sandbox`. **Pass the WO via stdin, not as a positional
|
|
219
|
+
> argument** (a positional arg hits Windows' command-line length limit — proven repeatedly in this
|
|
220
|
+
> repo). Fallback to direct Claude implementation only on Codex quota/rate-limit/non-zero exit —
|
|
221
|
+
> and note that the fallback flips authorship, so both reviewers stay mandatory either way.
|
|
222
|
+
|
|
223
|
+
### Context package
|
|
224
|
+
|
|
225
|
+
**Reference implementation to promote from (read-only, do not edit):**
|
|
226
|
+
`C:\Users\biglmi\Documents\webapps\jg-ferien\frontend\src\components\mobileShell\MobileBottomNav.jsx`
|
|
227
|
+
(107 lines) — the source of every field/behaviour named in the Envelope. Note its hardcoded
|
|
228
|
+
`zIndex: (navTheme) => navTheme.zIndex.drawer + 2` (stays a component default, cannot move to the
|
|
229
|
+
theme per the "objects only" constraint), its `/my-registrations` special-case (becomes
|
|
230
|
+
`emphasis`), its messaging-hook badge (becomes generic `badgeCount`), and its inline `t()` calls
|
|
231
|
+
(become finished-string `label`/`shortLabel` props — do not import `react-i18next` into the new
|
|
232
|
+
component).
|
|
233
|
+
|
|
234
|
+
**Files to change, in ucm:**
|
|
235
|
+
|
|
236
|
+
1. **`src/theme/tokens.js`** — add to `BASELINE_STATIC.components` (palette-*independent* values
|
|
237
|
+
only; this file is deep-merged as static objects and MUST NOT contain functions —
|
|
238
|
+
`tests/createAppTheme.test.js` asserts this):
|
|
239
|
+
```js
|
|
240
|
+
MuiBottomNavigation: {
|
|
241
|
+
styleOverrides: {
|
|
242
|
+
root: { borderTop: '1px solid', boxShadow: 'none' },
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
MuiBottomNavigationAction: {
|
|
246
|
+
styleOverrides: {
|
|
247
|
+
root: { minWidth: 0, maxWidth: 'none' },
|
|
248
|
+
label: { fontSize: '12px', fontWeight: 500 },
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
```
|
|
252
|
+
Follow the existing `MuiButton`/`MuiChip` entries immediately above as the pattern to match.
|
|
253
|
+
|
|
254
|
+
2. **`src/theme/createAppTheme.js`** — the *palette-dependent* half (background.paper, divider
|
|
255
|
+
border colour, text.secondary / primary.main action colours) belongs in
|
|
256
|
+
`createPaletteAwareComponents(palette)`, not in tokens.js — this is the existing
|
|
257
|
+
"palette-first ordering" pattern already used there for `MuiDivider`/`MuiButton.outlined`
|
|
258
|
+
(see lines 93-95 and 87-91 of the current file). Add, inside the object that function returns:
|
|
259
|
+
```js
|
|
260
|
+
MuiBottomNavigation: {
|
|
261
|
+
styleOverrides: {
|
|
262
|
+
root: {
|
|
263
|
+
backgroundColor: palette.background.paper,
|
|
264
|
+
borderColor: palette.divider,
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
MuiBottomNavigationAction: {
|
|
269
|
+
styleOverrides: {
|
|
270
|
+
root: {
|
|
271
|
+
color: palette.text.secondary,
|
|
272
|
+
'&.Mui-selected': { color: palette.primary.main },
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
```
|
|
277
|
+
`createAppTheme`'s deep-merge (bottom of the file) already layers this object after the static
|
|
278
|
+
`BASELINE_STATIC.components` block, so both halves land on the same MUI component slot — do not
|
|
279
|
+
duplicate a key across both files.
|
|
280
|
+
|
|
281
|
+
3. **`src/theme/themeCompleteness.js`** — register the new surfaces in
|
|
282
|
+
`COMPONENT_SURFACES` (around line 90, alongside the existing `MuiChip`/`MuiPaper` entries), using
|
|
283
|
+
the same `componentPath()` / `componentKeyLeaf()` helpers already imported/defined in this file:
|
|
284
|
+
- `componentPath('MuiBottomNavigation', 'styleOverrides.root.borderTop')`
|
|
285
|
+
- `componentPath('MuiBottomNavigation', 'styleOverrides.root.boxShadow')`
|
|
286
|
+
- `componentPath('MuiBottomNavigation', 'styleOverrides.root.backgroundColor')`
|
|
287
|
+
- `componentPath('MuiBottomNavigation', 'styleOverrides.root.borderColor')`
|
|
288
|
+
- `componentPath('MuiBottomNavigationAction', 'styleOverrides.root.minWidth')`
|
|
289
|
+
- `componentPath('MuiBottomNavigationAction', 'styleOverrides.root.maxWidth')`
|
|
290
|
+
- `componentPath('MuiBottomNavigationAction', 'styleOverrides.root.color')`
|
|
291
|
+
- `componentPath('MuiBottomNavigationAction', 'styleOverrides.label.fontSize')`
|
|
292
|
+
- `componentPath('MuiBottomNavigationAction', 'styleOverrides.label.fontWeight')`
|
|
293
|
+
- `componentKeyLeaf('MuiBottomNavigationAction', 'styleOverrides.root', '&.Mui-selected', 'color')`
|
|
294
|
+
These are what test 7 (non-vacuity) exercises: MUI's own `MuiBottomNavigation`/
|
|
295
|
+
`MuiBottomNavigationAction` defaults must differ from every one of these values, or the
|
|
296
|
+
completeness assertion is vacuously green (the existing `sameValue()` check in this file already
|
|
297
|
+
handles the comparison — no new logic needed here beyond registering the surfaces).
|
|
298
|
+
|
|
299
|
+
4. **New file `src/components/MobileBottomNav.jsx`** (sibling of `src/components/UserListComponent.jsx`
|
|
300
|
+
etc. — this is a shared, non-auth component so it does not belong in `src/auth/`). Structure:
|
|
301
|
+
`Paper`-free — apply the fixed positioning, top-border and `env(safe-area-inset-bottom)` padding
|
|
302
|
+
directly via `sx` on `BottomNavigation` itself (do not rely on `MuiPaper`'s theme entry, which
|
|
303
|
+
already carries an unrelated `borderRadius: 8` default that would need overriding). Props exactly
|
|
304
|
+
as the Envelope's table: `destinations`, `activeRoute`, `onNavigate`, `hideAbove = 'md'`,
|
|
305
|
+
`zIndex = (theme) => theme.zIndex.drawer + 2` — default via a plain JS default parameter *value*
|
|
306
|
+
passed to `sx`, not stored in the theme (this is the one place the WO explicitly keeps a function,
|
|
307
|
+
component-local, matching jg's original). Each destination renders a `BottomNavigationAction` with
|
|
308
|
+
`icon` = `<Icon />` optionally wrapped in `<Badge badgeContent={...} />` when `badgeCount` is
|
|
309
|
+
truthy (`0`/`undefined` must render no `Badge` wrapper at all — a `Badge` with `badgeContent={0}`
|
|
310
|
+
still renders a dot with `showZero` unset only if MUI's default differs; simplest correct
|
|
311
|
+
implementation is to skip the `Badge` wrapper entirely when there is no count). `emphasis` applies
|
|
312
|
+
jg's raised-icon treatment (`backgroundColor: selected ? primary.main : background.paper`, `color`
|
|
313
|
+
inverted, `borderRadius: '50%'`, `transform: translateY(-4px)`) to that one destination's icon only
|
|
314
|
+
— reuse `theme.palette.background.paper`, not jg's `background.white` (a jg-only palette
|
|
315
|
+
extension not present in the ucm baseline — this is the intended parity difference the Envelope
|
|
316
|
+
names). Breakpoint hide: `useMediaQuery(theme.breakpoints.up(hideAbove))` → return `null` (mirror
|
|
317
|
+
jg's `useMediaQuery(theme.breakpoints.down('md'))` inverted for a configurable `hideAbove`).
|
|
318
|
+
|
|
319
|
+
5. **`src/index.js`** — export `{ MobileBottomNav }` from `./components/MobileBottomNav`, placed in
|
|
320
|
+
the `--- 5. Components ---` section (after `QrSignupManager`, before `--- 6. Charts ---`).
|
|
321
|
+
|
|
322
|
+
6. **`dev/entries.jsx`** — add one specimen entry, following the existing `NotificationBellEntry`
|
|
323
|
+
pattern (small wrapper function + one line in the `entries` array). Five destinations, two with
|
|
324
|
+
`badgeCount` set, one with `emphasis: true`, mirroring the Envelope's "Verification" section.
|
|
325
|
+
Import `MobileBottomNav` from `'../src/components/MobileBottomNav'` alongside the other `../src/`
|
|
326
|
+
imports at the top of the file.
|
|
327
|
+
|
|
328
|
+
7. **New test file `tests/MobileBottomNav.test.jsx`** — follow `tests/UserMenu.test.jsx`'s structure
|
|
329
|
+
(jsdom environment pragma, `render`/`screen`/`fireEvent` from testing-library, `afterEach(cleanup)`).
|
|
330
|
+
Wrap the component in `ThemeProvider` with `createAppTheme({ palette: { primary: { main: '#0F62FE' } } })`
|
|
331
|
+
(check `tests/createAppTheme.test.js` for the exact call shape already used elsewhere in this
|
|
332
|
+
suite) since the component's selected-state colour comes from the theme, not inline `sx`. Cover
|
|
333
|
+
the seven "Required tests to WRITE" items from the Envelope verbatim — they are numbered 1-7
|
|
334
|
+
above and map 1:1 to test cases; item 7 (non-vacuity) belongs in
|
|
335
|
+
`tests/themeCompleteness.test.js` or `tests/createAppTheme.test.js` instead, wherever the existing
|
|
336
|
+
"missing surface produces a named finding" pattern already lives (see `themeCompleteness.test.js`
|
|
337
|
+
lines ~15-20 for the shape: `bare.findings.map(({ surface }) => surface)).toContain('...')`) —
|
|
338
|
+
do not duplicate that assertion pattern inside the new component test file.
|
|
339
|
+
|
|
340
|
+
**Invariants / do-not-touch:** no edits to `BASELINE_PALETTE`, `typography`, `shape`, `spacing`, or
|
|
341
|
+
the `shadows` array in `tokens.js` (Envelope non-goal). No edits to jg-ferien (separate `NAV-36` WO).
|
|
342
|
+
No new i18n keys — `label`/`shortLabel` are finished strings per-prop, not translation keys.
|
|
343
|
+
|
|
344
|
+
**Pitfalls already known:**
|
|
345
|
+
- A function anywhere in `tokens.js`'s `components` tree fails `tests/createAppTheme.test.js`
|
|
346
|
+
immediately — the palette-aware colours MUST go in `createAppTheme.js`, not `tokens.js`.
|
|
347
|
+
- `assertThemeComplete`'s non-vacuity depends on MUI's own `createTheme()` default for
|
|
348
|
+
`MuiBottomNavigation`/`MuiBottomNavigationAction` genuinely differing from the new baseline values
|
|
349
|
+
— verify this holds (MUI's stock action `minWidth` is `80`, not `0`, and stock has no
|
|
350
|
+
`borderTop`/`boxShadow: 'none'` on `MuiBottomNavigation` root, so all listed surfaces should clear
|
|
351
|
+
safely, but confirm rather than assume).
|
|
352
|
+
- `env(safe-area-inset-bottom)` cannot be verified as "working" from a desktop viewport (Envelope
|
|
353
|
+
Verification section) — assert the CSS declaration is present, do not assert a computed non-zero
|
|
354
|
+
value.
|
|
355
|
+
|
|
356
|
+
### Mini-handover
|
|
357
|
+
|
|
358
|
+
Repo: `ui-core-micha` (`C:\Users\biglmi\Documents\webapps\ui-core-micha`), branch `main`.
|
|
359
|
+
WO: `work-orders/SHELL-3.md`. Follow `orchestrate-codex`.
|