@coffre/ui 0.1.18 → 0.2.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/README.md +23 -3
- package/dist/{server/_coffre/assets/affordances-CKANXDTG.js → chunks/affordances-DAvsVz7u.js} +12 -7
- package/dist/chunks/affordances-DAvsVz7u.js.map +1 -0
- package/dist/chunks/directory-CSjWWUQ1.js +370 -0
- package/dist/chunks/directory-CSjWWUQ1.js.map +1 -0
- package/dist/{server/_coffre/assets/grants-DdKT11Ny.js → chunks/grants-saMQagmG.js} +41 -39
- package/dist/chunks/grants-saMQagmG.js.map +1 -0
- package/dist/chunks/icons-D-PfAfnH.js +203 -0
- package/dist/chunks/icons-D-PfAfnH.js.map +1 -0
- package/dist/chunks/mounted-jJmqqV_n.js +17 -0
- package/dist/chunks/mounted-jJmqqV_n.js.map +1 -0
- package/dist/{server/_coffre/assets/offboarding-CRz-K82H.js → chunks/offboarding-C6l30DZR.js} +70 -69
- package/dist/chunks/offboarding-C6l30DZR.js.map +1 -0
- package/dist/chunks/page-C5HcNqf2.js +190 -0
- package/dist/chunks/page-C5HcNqf2.js.map +1 -0
- package/dist/chunks/page-route-Drfw7lmn.js +20 -0
- package/dist/chunks/page-route-Drfw7lmn.js.map +1 -0
- package/dist/{server/_coffre/assets/principal-page-C-EFwJQw.js → chunks/principal-page-D_91OA0l.js} +105 -103
- package/dist/chunks/principal-page-D_91OA0l.js.map +1 -0
- package/dist/{server/_coffre/assets → chunks}/project-environments-lEzFHUt4.js +2 -0
- package/dist/chunks/project-environments-lEzFHUt4.js.map +1 -0
- package/dist/chunks/queries-CQ81o4so.js +376 -0
- package/dist/chunks/queries-CQ81o4so.js.map +1 -0
- package/dist/{server/_coffre/assets/row-state-C2P57xT1.js → chunks/row-state-0PsrEzOL.js} +22 -21
- package/dist/chunks/row-state-0PsrEzOL.js.map +1 -0
- package/dist/{server/_coffre/assets → chunks}/signin-errors-BEFlVDbQ.js +2 -0
- package/dist/chunks/signin-errors-BEFlVDbQ.js.map +1 -0
- package/dist/chunks/theme-B2vQolVR.js +86 -0
- package/dist/chunks/theme-B2vQolVR.js.map +1 -0
- package/dist/chunks/ui-DixXLQvQ.js +405 -0
- package/dist/chunks/ui-DixXLQvQ.js.map +1 -0
- package/dist/{server/_coffre/assets/use-action-B-xpvVRO.js → chunks/use-action-CWsg_YWU.js} +8 -6
- package/dist/chunks/use-action-CWsg_YWU.js.map +1 -0
- package/dist/{server/_coffre/assets/use-change-C8BCf3oU.js → chunks/use-change-c6CeLRin.js} +10 -474
- package/dist/chunks/use-change-c6CeLRin.js.map +1 -0
- package/dist/chunks/use-shell-jxd7Tzd-.js +26 -0
- package/dist/chunks/use-shell-jxd7Tzd-.js.map +1 -0
- package/dist/{server/_coffre/assets → chunks}/validation-BQtqPe2V.js +2 -0
- package/dist/chunks/validation-BQtqPe2V.js.map +1 -0
- package/dist/index.d.ts +386 -18
- package/dist/index.js +1147 -0
- package/dist/index.js.map +1 -0
- package/dist/pages/account.d.ts +9 -0
- package/dist/pages/account.js +334 -0
- package/dist/pages/account.js.map +1 -0
- package/dist/pages/audit.d.ts +3 -0
- package/dist/{server/_coffre/assets/audit-qB9G2AQJ.js → pages/audit.js} +102 -100
- package/dist/pages/audit.js.map +1 -0
- package/dist/pages/device-login.d.ts +9 -0
- package/dist/pages/device-login.js +211 -0
- package/dist/pages/device-login.js.map +1 -0
- package/dist/pages/environment.d.ts +3 -0
- package/dist/{server/_coffre/assets/projects._project._environment-C6uybzeU.js → pages/environment.js} +323 -469
- package/dist/pages/environment.js.map +1 -0
- package/dist/pages/login.d.ts +10 -0
- package/dist/pages/login.js +104 -0
- package/dist/pages/login.js.map +1 -0
- package/dist/pages/project.d.ts +2 -0
- package/dist/{server/_coffre/assets/projects._project.index-3CXwkyTh.js → pages/project.js} +223 -225
- package/dist/pages/project.js.map +1 -0
- package/dist/pages/projects.d.ts +3 -0
- package/dist/{server/_coffre/assets/projects.index-iSoBpRFz.js → pages/projects.js} +83 -81
- package/dist/pages/projects.js.map +1 -0
- package/dist/pages/settings.d.ts +3 -0
- package/dist/{server/_coffre/assets/settings-BDQTF5XW.js → pages/settings.js} +20 -18
- package/dist/pages/settings.js.map +1 -0
- package/dist/pages/token.d.ts +3 -0
- package/dist/{server/_coffre/assets/tokens._token-CrBMpcbN.js → pages/token.js} +195 -265
- package/dist/pages/token.js.map +1 -0
- package/dist/pages/tokens.d.ts +3 -0
- package/dist/pages/tokens.js +39 -0
- package/dist/pages/tokens.js.map +1 -0
- package/dist/pages/unregistered.d.ts +8 -0
- package/dist/pages/unregistered.js +54 -0
- package/dist/pages/unregistered.js.map +1 -0
- package/dist/pages/user.d.ts +3 -0
- package/dist/pages/user.js +16 -0
- package/dist/pages/user.js.map +1 -0
- package/dist/pages/users.d.ts +3 -0
- package/dist/pages/users.js +39 -0
- package/dist/pages/users.js.map +1 -0
- package/dist/project-BqIy8gYR.d.ts +5 -0
- package/dist/vite.d.ts +16 -0
- package/dist/vite.js +52 -0
- package/package.json +36 -21
- package/src/assets/icon.svg +1 -0
- package/src/components/affordances.ts +10 -4
- package/src/components/command-palette.tsx +229 -203
- package/src/components/directory.tsx +34 -38
- package/src/components/principal.tsx +7 -3
- package/src/components/shell.tsx +89 -127
- package/src/components/theme.tsx +14 -81
- package/src/components/ui.tsx +97 -68
- package/src/index.ts +29 -0
- package/src/layout.tsx +113 -0
- package/src/lib/coffre.ts +8 -4
- package/src/lib/mounted.ts +13 -0
- package/src/lib/page-context.ts +31 -0
- package/src/lib/page-route.ts +22 -0
- package/src/lib/preferences.tsx +46 -0
- package/src/options.ts +240 -0
- package/src/{routes → pages}/account.tsx +7 -24
- package/src/{routes → pages}/audit.tsx +5 -16
- package/src/{routes/auth.device.tsx → pages/device-login.tsx} +8 -21
- package/src/{routes/projects.$project.$environment.tsx → pages/environment.tsx} +43 -52
- package/src/{routes → pages}/login.tsx +5 -16
- package/src/{routes/projects.$project.index.tsx → pages/project.tsx} +38 -50
- package/src/{routes/projects.index.tsx → pages/projects.tsx} +2 -7
- package/src/{routes → pages}/settings.tsx +3 -10
- package/src/{routes/tokens.$token.tsx → pages/token.tsx} +6 -7
- package/src/{routes/tokens.index.tsx → pages/tokens.tsx} +3 -8
- package/src/{routes → pages}/unregistered.tsx +1 -6
- package/src/pages/user.tsx +10 -0
- package/src/{routes/users.index.tsx → pages/users.tsx} +3 -8
- package/src/register.ts +55 -0
- package/src/router.tsx +31 -62
- package/src/styles/globals.css +104 -46
- package/src/vite.ts +78 -0
- package/dist/client/.assetsignore +0 -2
- package/dist/client/_coffre/assets/account-BoLGAxbD.js +0 -2
- package/dist/client/_coffre/assets/account-CnnuRTDB.js +0 -1
- package/dist/client/_coffre/assets/affordances-CEafRJcN.js +0 -1
- package/dist/client/_coffre/assets/audit-CHSvKLWX.js +0 -1
- package/dist/client/_coffre/assets/audit-Cn4hmS4u.js +0 -2
- package/dist/client/_coffre/assets/auth.device-Co5vrpaA.js +0 -2
- package/dist/client/_coffre/assets/auth.device-DAlqWacc.js +0 -1
- package/dist/client/_coffre/assets/directory-H8Eh3MnS.js +0 -1
- package/dist/client/_coffre/assets/dist-Braunv_x.js +0 -1
- package/dist/client/_coffre/assets/globals-CpMrgkV6.css +0 -1
- package/dist/client/_coffre/assets/grants-DPDxJXU1.js +0 -1
- package/dist/client/_coffre/assets/icons-Dc_-t0lp.js +0 -1
- package/dist/client/_coffre/assets/index-sUCIXRgJ.js +0 -12
- package/dist/client/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/client/_coffre/assets/link-DBINMwm6.js +0 -1
- package/dist/client/_coffre/assets/login-BZFYfL1Y.js +0 -1
- package/dist/client/_coffre/assets/login-CYCKWTOD.js +0 -2
- package/dist/client/_coffre/assets/offboarding-Bwpftp3g.js +0 -1
- package/dist/client/_coffre/assets/page-C_hnzdaR.js +0 -1
- package/dist/client/_coffre/assets/preload-helper-CLkO85Nq.js +0 -1
- package/dist/client/_coffre/assets/principal-page-DLho8TSJ.js +0 -1
- package/dist/client/_coffre/assets/project-environments-CfIH5kFM.js +0 -1
- package/dist/client/_coffre/assets/projects._project._environment-DHRRvQw0.js +0 -3
- package/dist/client/_coffre/assets/projects._project._environment-TLI-RjBZ.js +0 -2
- package/dist/client/_coffre/assets/projects._project.index-BO-8FZIY.js +0 -2
- package/dist/client/_coffre/assets/projects._project.index-DGl921dP.js +0 -1
- package/dist/client/_coffre/assets/projects.index-BDn7Bhoo.js +0 -1
- package/dist/client/_coffre/assets/row-state-DJ-KLamZ.js +0 -1
- package/dist/client/_coffre/assets/settings-q9G1QvR_.js +0 -1
- package/dist/client/_coffre/assets/signin-errors-CroZWZgm.js +0 -1
- package/dist/client/_coffre/assets/suspense-O8sP0mEC.js +0 -1
- package/dist/client/_coffre/assets/tokens._token-B_qczpT9.js +0 -2
- package/dist/client/_coffre/assets/tokens._token-T-sqwMbz.js +0 -2
- package/dist/client/_coffre/assets/tokens.index-CcXSZnAG.js +0 -1
- package/dist/client/_coffre/assets/ui-BXP2IqrW.js +0 -46
- package/dist/client/_coffre/assets/unregistered-D2JXJ90x.js +0 -1
- package/dist/client/_coffre/assets/use-action-BpzKWhgg.js +0 -1
- package/dist/client/_coffre/assets/use-change-CKj3Inq9.js +0 -1
- package/dist/client/_coffre/assets/use-shell-W0SusPkz.js +0 -1
- package/dist/client/_coffre/assets/useQuery-B-lxFSES.js +0 -1
- package/dist/client/_coffre/assets/useSuspenseQuery-BZ-nzHST.js +0 -1
- package/dist/client/_coffre/assets/users._user-Bb3BGYHl.js +0 -1
- package/dist/client/_coffre/assets/users._user-DXmvKrzE.js +0 -2
- package/dist/client/_coffre/assets/users.index-BvzP3qwW.js +0 -1
- package/dist/client/_coffre/assets/validation-9Cl_XS-l.js +0 -1
- package/dist/server/.vite/manifest.json +0 -668
- package/dist/server/_coffre/assets/_tanstack-start-manifest_v-GsKnGGRy.js +0 -162
- package/dist/server/_coffre/assets/account-CV-a2IU2.js +0 -329
- package/dist/server/_coffre/assets/account-hk6wcIXU.js +0 -162
- package/dist/server/_coffre/assets/async-local-storage-C10uQtMM.js +0 -3108
- package/dist/server/_coffre/assets/audit-C1_Ej6YB.js +0 -31
- package/dist/server/_coffre/assets/auth.device-6JRrWbSV.js +0 -210
- package/dist/server/_coffre/assets/auth.device-CLoAxC2T.js +0 -29
- package/dist/server/_coffre/assets/directory-B-_rqsPx.js +0 -371
- package/dist/server/_coffre/assets/dist-CnnV3t2g.js +0 -908
- package/dist/server/_coffre/assets/empty-plugin-adapters-Cq4--YW-.js +0 -5
- package/dist/server/_coffre/assets/globals-CpMrgkV6.css +0 -1
- package/dist/server/_coffre/assets/icons-DOFT-eWB.js +0 -1704
- package/dist/server/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/server/_coffre/assets/lazyRouteComponent-CqBNCGuZ.js +0 -480
- package/dist/server/_coffre/assets/link-42ZWdjzZ.js +0 -422
- package/dist/server/_coffre/assets/login-DRKUKkaW.js +0 -22
- package/dist/server/_coffre/assets/login-DnwxVl4Y.js +0 -102
- package/dist/server/_coffre/assets/matchContext-qLfYbC6_.js +0 -56
- package/dist/server/_coffre/assets/page-D6n45dcK.js +0 -3561
- package/dist/server/_coffre/assets/projects._project._environment-CS8DdSMY.js +0 -48
- package/dist/server/_coffre/assets/projects._project.index-BGfcNpj0.js +0 -23
- package/dist/server/_coffre/assets/react-dom-bBoJXlK2.js +0 -1718
- package/dist/server/_coffre/assets/router-9BTgJhWG.js +0 -2322
- package/dist/server/_coffre/assets/start-DR3rN0St.js +0 -4
- package/dist/server/_coffre/assets/suspense-C-2QfDd2.js +0 -602
- package/dist/server/_coffre/assets/tokens._token-rY86Cjgp.js +0 -10
- package/dist/server/_coffre/assets/tokens.index-Bq5qDW9q.js +0 -37
- package/dist/server/_coffre/assets/ui-Cc0CGMtr.js +0 -14881
- package/dist/server/_coffre/assets/unregistered-D9ZKLOPJ.js +0 -53
- package/dist/server/_coffre/assets/use-shell-DwOzEi87.js +0 -462
- package/dist/server/_coffre/assets/useQuery-CTe86qFq.js +0 -8
- package/dist/server/_coffre/assets/useRouter-CaUSUNsw.js +0 -473
- package/dist/server/_coffre/assets/useSuspenseQuery-CSoHzrMb.js +0 -117
- package/dist/server/_coffre/assets/users._user-BmLKYeo_.js +0 -10
- package/dist/server/_coffre/assets/users._user-BmiHwQx3.js +0 -14
- package/dist/server/_coffre/assets/users.index-BiEax90r.js +0 -37
- package/dist/server/index.js +0 -13911
- package/src/assets/favicon-32.png +0 -0
- package/src/components/agentation.tsx +0 -34
- package/src/entry.ts +0 -19
- package/src/routeTree.gen.ts +0 -367
- package/src/routes/__root.tsx +0 -169
- package/src/routes/access.tsx +0 -11
- package/src/routes/index.tsx +0 -15
- package/src/routes/users.$user.tsx +0 -13
- package/src/types.ts +0 -21
package/src/components/shell.tsx
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
useEffect,
|
|
3
|
+
useRef,
|
|
4
|
+
useState,
|
|
5
|
+
type ReactElement,
|
|
6
|
+
type ReactNode,
|
|
7
|
+
} from 'react';
|
|
2
8
|
import { Link, useNavigate, useRouterState } from '@tanstack/react-router';
|
|
3
|
-
import { Dialog
|
|
9
|
+
import { Dialog } from '@base-ui/react/dialog';
|
|
10
|
+
import { Menu } from '@base-ui/react/menu';
|
|
4
11
|
import type { InstanceState } from '@coffre/client';
|
|
5
12
|
import type { ProjectSummary } from '../shared/models';
|
|
6
13
|
import { pendingMigrations, UPGRADE_DOC } from '../lib/instance';
|
|
7
14
|
import type { UiCapabilities } from '../lib/capabilities';
|
|
8
15
|
import { isActiveAccessibleEnvironment } from '../lib/project-environments';
|
|
16
|
+
import { useMounted } from '../lib/mounted';
|
|
17
|
+
import { usePreferences } from '../lib/preferences';
|
|
9
18
|
import { AdministrationItems } from './affordances';
|
|
10
19
|
import { CommandPalette } from './command-palette';
|
|
11
20
|
import { ThemeMenuItems } from './theme';
|
|
12
21
|
import { Tile } from './tile';
|
|
13
|
-
import { Notice, Tip } from './ui';
|
|
22
|
+
import { MenuPopup, Notice, Tip } from './ui';
|
|
14
23
|
import {
|
|
15
24
|
Check,
|
|
16
25
|
ChevronsUpDown,
|
|
@@ -19,7 +28,7 @@ import {
|
|
|
19
28
|
Key,
|
|
20
29
|
Ledger,
|
|
21
30
|
Mark,
|
|
22
|
-
Menu,
|
|
31
|
+
Menu as MenuIcon,
|
|
23
32
|
PanelLeft,
|
|
24
33
|
Settings,
|
|
25
34
|
SignOut,
|
|
@@ -42,47 +51,14 @@ type ShellProps = {
|
|
|
42
51
|
|
|
43
52
|
const REPOSITORY = 'https://github.com/erwinkn/coffre';
|
|
44
53
|
|
|
45
|
-
const SIDEBAR_KEY = 'coffre-sidebar';
|
|
46
|
-
|
|
47
54
|
/** Wide enough for the sidebar to sit beside the page; narrower, it is a drawer. */
|
|
48
55
|
const WIDE = '(width > 60rem)';
|
|
49
56
|
|
|
50
|
-
/**
|
|
51
|
-
* Collapses the sidebar before first paint, inlined in <head> like the
|
|
52
|
-
* theme's script: drawn wide and then snapped narrow, the whole page would
|
|
53
|
-
* lurch sideways on every load.
|
|
54
|
-
*/
|
|
55
|
-
export const sidebarBootScript = `(function(){try{if(localStorage.getItem(${JSON.stringify(
|
|
56
|
-
SIDEBAR_KEY,
|
|
57
|
-
)})==="collapsed"){document.documentElement.setAttribute("data-sidebar","collapsed")}}catch(e){}})()`;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Whether the sidebar is folded down to its icons, and the switch.
|
|
61
|
-
*
|
|
62
|
-
* The attribute on <html> is the truth and the stylesheet reads it, so the
|
|
63
|
-
* boot script has already drawn the right width. Server-rendered markup
|
|
64
|
-
* cannot know it, so this state starts expanded and catches up on mount.
|
|
65
|
-
*/
|
|
57
|
+
/** Whether the sidebar is folded down to its icons, as the visitor left it, and the switch. */
|
|
66
58
|
function useSidebarCollapsed(): [boolean, () => void] {
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const toggle = useCallback(() => {
|
|
72
|
-
const root = document.documentElement;
|
|
73
|
-
const next = root.dataset.sidebar !== 'collapsed';
|
|
74
|
-
if (next) root.dataset.sidebar = 'collapsed';
|
|
75
|
-
else delete root.dataset.sidebar;
|
|
76
|
-
try {
|
|
77
|
-
if (next) localStorage.setItem(SIDEBAR_KEY, 'collapsed');
|
|
78
|
-
else localStorage.removeItem(SIDEBAR_KEY);
|
|
79
|
-
} catch {
|
|
80
|
-
// Storage refused (private mode); the choice still holds for this page.
|
|
81
|
-
}
|
|
82
|
-
setCollapsed(next);
|
|
83
|
-
}, []);
|
|
84
|
-
|
|
85
|
-
return [collapsed, toggle];
|
|
59
|
+
const { sidebar, setSidebar } = usePreferences();
|
|
60
|
+
const collapsed = sidebar === 'collapsed';
|
|
61
|
+
return [collapsed, () => setSidebar(collapsed ? 'expanded' : 'collapsed')];
|
|
86
62
|
}
|
|
87
63
|
|
|
88
64
|
/** Marks the current route without each link having to compare paths itself. */
|
|
@@ -137,8 +113,10 @@ export function Brand() {
|
|
|
137
113
|
* own title says where you are, so the bar leaves it out rather than repeat it.
|
|
138
114
|
*/
|
|
139
115
|
export function Shell({ projects, principal, instanceRole, capabilities, instance, children }: ShellProps) {
|
|
116
|
+
const { portal } = usePreferences();
|
|
140
117
|
const pathname = useRouterState({ select: (state) => state.location.pathname });
|
|
141
118
|
const [drawerOpen, setDrawerOpen] = useState(false);
|
|
119
|
+
const drawerClose = useRef<HTMLButtonElement>(null);
|
|
142
120
|
const [collapsed, toggleSidebar] = useSidebarCollapsed();
|
|
143
121
|
|
|
144
122
|
// Following a link in the drawer should land on the page, not leave the
|
|
@@ -190,36 +168,32 @@ export function Shell({ projects, principal, instanceRole, capabilities, instanc
|
|
|
190
168
|
</Tip>
|
|
191
169
|
|
|
192
170
|
<Dialog.Root open={drawerOpen} onOpenChange={setDrawerOpen}>
|
|
193
|
-
<Dialog.Trigger
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
>
|
|
199
|
-
<Menu size={18} />
|
|
200
|
-
</button>
|
|
171
|
+
<Dialog.Trigger
|
|
172
|
+
className="btn btn-quiet btn-icon header-menu"
|
|
173
|
+
aria-label="Open navigation"
|
|
174
|
+
>
|
|
175
|
+
<MenuIcon size={18} />
|
|
201
176
|
</Dialog.Trigger>
|
|
202
|
-
<Dialog.Portal>
|
|
203
|
-
<Dialog.
|
|
204
|
-
|
|
177
|
+
<Dialog.Portal container={portal}>
|
|
178
|
+
<Dialog.Backdrop className="overlay" />
|
|
179
|
+
{/* The close button rather than the first link, the logo. */}
|
|
180
|
+
<Dialog.Popup className="drawer" initialFocus={drawerClose}>
|
|
205
181
|
<Dialog.Title className="visually-hidden">Navigation</Dialog.Title>
|
|
206
182
|
<Sidebar
|
|
207
183
|
principal={principal}
|
|
208
184
|
instanceRole={instanceRole}
|
|
209
185
|
capabilities={capabilities}
|
|
210
186
|
close={
|
|
211
|
-
<Dialog.Close
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
<X size={16} />
|
|
218
|
-
</button>
|
|
187
|
+
<Dialog.Close
|
|
188
|
+
ref={drawerClose}
|
|
189
|
+
className="btn btn-quiet btn-sm btn-icon"
|
|
190
|
+
aria-label="Close navigation"
|
|
191
|
+
>
|
|
192
|
+
<X size={16} />
|
|
219
193
|
</Dialog.Close>
|
|
220
194
|
}
|
|
221
195
|
/>
|
|
222
|
-
</Dialog.
|
|
196
|
+
</Dialog.Popup>
|
|
223
197
|
</Dialog.Portal>
|
|
224
198
|
</Dialog.Root>
|
|
225
199
|
|
|
@@ -269,6 +243,7 @@ function Sidebar({
|
|
|
269
243
|
collapsed?: boolean;
|
|
270
244
|
close?: ReactNode;
|
|
271
245
|
}) {
|
|
246
|
+
const mounted = useMounted();
|
|
272
247
|
return (
|
|
273
248
|
<>
|
|
274
249
|
<div className="sidebar-head">
|
|
@@ -312,6 +287,7 @@ function Sidebar({
|
|
|
312
287
|
{principal !== null && (
|
|
313
288
|
<div className="sidebar-foot">
|
|
314
289
|
<AccountMenu principal={principal} instanceRole={instanceRole} collapsed={collapsed} />
|
|
290
|
+
{mounted('/account') && (
|
|
315
291
|
<Tip label="Account settings" side={collapsed ? 'right' : undefined}>
|
|
316
292
|
<Link
|
|
317
293
|
className="btn btn-quiet btn-icon sidebar-foot-settings"
|
|
@@ -322,6 +298,7 @@ function Sidebar({
|
|
|
322
298
|
<UserCog size={16} />
|
|
323
299
|
</Link>
|
|
324
300
|
</Tip>
|
|
301
|
+
)}
|
|
325
302
|
</div>
|
|
326
303
|
)}
|
|
327
304
|
</>
|
|
@@ -336,7 +313,7 @@ function CollapsedTip({
|
|
|
336
313
|
}: {
|
|
337
314
|
collapsed: boolean;
|
|
338
315
|
label: string;
|
|
339
|
-
children:
|
|
316
|
+
children: ReactElement;
|
|
340
317
|
}) {
|
|
341
318
|
return collapsed ? (
|
|
342
319
|
<Tip label={label} side="right">
|
|
@@ -358,6 +335,9 @@ function NavLink({
|
|
|
358
335
|
icon: ReactNode;
|
|
359
336
|
collapsed: boolean;
|
|
360
337
|
}) {
|
|
338
|
+
// A page the deployment left out has no link.
|
|
339
|
+
const mounted = useMounted();
|
|
340
|
+
if (!mounted(to)) return null;
|
|
361
341
|
// Matching is by prefix, so Projects stays current inside a project and
|
|
362
342
|
// Audit stays current whatever its filters.
|
|
363
343
|
return (
|
|
@@ -394,42 +374,28 @@ function AccountMenu({
|
|
|
394
374
|
collapsed: boolean;
|
|
395
375
|
}) {
|
|
396
376
|
return (
|
|
397
|
-
<
|
|
377
|
+
<Menu.Root>
|
|
398
378
|
<CollapsedTip collapsed={collapsed} label={principal.id}>
|
|
399
|
-
<
|
|
400
|
-
<
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
<span className="
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
<span className="account-text">
|
|
409
|
-
<span className="account-name">{principal.id}</span>
|
|
410
|
-
<span className="account-role">{roleLabel(principal, instanceRole)}</span>
|
|
411
|
-
</span>
|
|
412
|
-
</button>
|
|
413
|
-
</DropdownMenu.Trigger>
|
|
379
|
+
<Menu.Trigger className="account" title={collapsed ? undefined : principal.id}>
|
|
380
|
+
<span className="avatar" aria-hidden>
|
|
381
|
+
{principal.id.slice(0, 1)}
|
|
382
|
+
</span>
|
|
383
|
+
<span className="account-text">
|
|
384
|
+
<span className="account-name">{principal.id}</span>
|
|
385
|
+
<span className="account-role">{roleLabel(principal, instanceRole)}</span>
|
|
386
|
+
</span>
|
|
387
|
+
</Menu.Trigger>
|
|
414
388
|
</CollapsedTip>
|
|
415
|
-
<
|
|
416
|
-
<
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
<DropdownMenu.Separator className="menu-sep" />
|
|
426
|
-
<DropdownMenu.Item className="menu-item" onSelect={signOut}>
|
|
427
|
-
<SignOut size={14} />
|
|
428
|
-
Sign out
|
|
429
|
-
</DropdownMenu.Item>
|
|
430
|
-
</DropdownMenu.Content>
|
|
431
|
-
</DropdownMenu.Portal>
|
|
432
|
-
</DropdownMenu.Root>
|
|
389
|
+
<MenuPopup className="menu-account" side="top" align="start">
|
|
390
|
+
<ThemeMenuItems />
|
|
391
|
+
|
|
392
|
+
<Menu.Separator className="menu-sep" />
|
|
393
|
+
<Menu.Item className="menu-item" onClick={signOut}>
|
|
394
|
+
<SignOut size={14} />
|
|
395
|
+
Sign out
|
|
396
|
+
</Menu.Item>
|
|
397
|
+
</MenuPopup>
|
|
398
|
+
</Menu.Root>
|
|
433
399
|
);
|
|
434
400
|
}
|
|
435
401
|
|
|
@@ -530,20 +496,18 @@ function ProjectCrumb({
|
|
|
530
496
|
<Tile name={slug} />
|
|
531
497
|
<span className="crumb-project-name">{slug}</span>
|
|
532
498
|
</Link>
|
|
533
|
-
<
|
|
534
|
-
<
|
|
535
|
-
<
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
<DropdownMenu.Content className="menu" sideOffset={6} align="start">
|
|
541
|
-
<DropdownMenu.Label className="menu-label">Projects</DropdownMenu.Label>
|
|
499
|
+
<Menu.Root>
|
|
500
|
+
<Menu.Trigger className="crumb-switch" aria-label="Switch project">
|
|
501
|
+
<ChevronsUpDown size={14} />
|
|
502
|
+
</Menu.Trigger>
|
|
503
|
+
<MenuPopup align="start">
|
|
504
|
+
<Menu.Group>
|
|
505
|
+
<Menu.GroupLabel className="menu-label">Projects</Menu.GroupLabel>
|
|
542
506
|
{projects.map((project) => (
|
|
543
|
-
<
|
|
507
|
+
<Menu.Item
|
|
544
508
|
key={project.slug}
|
|
545
509
|
className="menu-item"
|
|
546
|
-
|
|
510
|
+
onClick={() =>
|
|
547
511
|
navigate({ to: '/projects/$project', params: { project: project.slug } })
|
|
548
512
|
}
|
|
549
513
|
>
|
|
@@ -551,11 +515,11 @@ function ProjectCrumb({
|
|
|
551
515
|
{project.slug}
|
|
552
516
|
<span className="menu-hint">{project.name}</span>
|
|
553
517
|
{project.slug === slug && <Check size={14} className="menu-check" />}
|
|
554
|
-
</
|
|
518
|
+
</Menu.Item>
|
|
555
519
|
))}
|
|
556
|
-
</
|
|
557
|
-
</
|
|
558
|
-
</
|
|
520
|
+
</Menu.Group>
|
|
521
|
+
</MenuPopup>
|
|
522
|
+
</Menu.Root>
|
|
559
523
|
</span>
|
|
560
524
|
);
|
|
561
525
|
}
|
|
@@ -576,22 +540,20 @@ function EnvironmentCrumb({
|
|
|
576
540
|
<span>{slug}</span>
|
|
577
541
|
</span>
|
|
578
542
|
{environments.length > 0 && (
|
|
579
|
-
<
|
|
580
|
-
<
|
|
581
|
-
<
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
<DropdownMenu.Content className="menu" sideOffset={6} align="start">
|
|
587
|
-
<DropdownMenu.Label className="menu-label">
|
|
543
|
+
<Menu.Root>
|
|
544
|
+
<Menu.Trigger className="crumb-switch" aria-label="Switch environment">
|
|
545
|
+
<ChevronsUpDown size={14} />
|
|
546
|
+
</Menu.Trigger>
|
|
547
|
+
<MenuPopup align="start">
|
|
548
|
+
<Menu.Group>
|
|
549
|
+
<Menu.GroupLabel className="menu-label">
|
|
588
550
|
Environments in {projectSlug}
|
|
589
|
-
</
|
|
551
|
+
</Menu.GroupLabel>
|
|
590
552
|
{environments.map((environment) => (
|
|
591
|
-
<
|
|
553
|
+
<Menu.Item
|
|
592
554
|
key={environment.slug}
|
|
593
555
|
className="menu-item"
|
|
594
|
-
|
|
556
|
+
onClick={() =>
|
|
595
557
|
navigate({
|
|
596
558
|
to: '/projects/$project/$environment',
|
|
597
559
|
params: { project: projectSlug, environment: environment.slug },
|
|
@@ -604,11 +566,11 @@ function EnvironmentCrumb({
|
|
|
604
566
|
{environment.details?.secretCount === 1 ? '' : 's'}
|
|
605
567
|
</span>
|
|
606
568
|
{environment.slug === slug && <Check size={14} className="menu-check" />}
|
|
607
|
-
</
|
|
569
|
+
</Menu.Item>
|
|
608
570
|
))}
|
|
609
|
-
</
|
|
610
|
-
</
|
|
611
|
-
</
|
|
571
|
+
</Menu.Group>
|
|
572
|
+
</MenuPopup>
|
|
573
|
+
</Menu.Root>
|
|
612
574
|
)}
|
|
613
575
|
</span>
|
|
614
576
|
);
|
package/src/components/theme.tsx
CHANGED
|
@@ -1,91 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Menu } from '@base-ui/react/menu';
|
|
2
|
+
import { usePreferences, type Theme } from '../lib/preferences';
|
|
3
3
|
import { Check, Monitor, Moon, Sun } from './icons';
|
|
4
4
|
|
|
5
|
-
export type Theme = 'system' | 'light' | 'dark';
|
|
6
|
-
|
|
7
|
-
const STORAGE_KEY = 'coffre-theme';
|
|
8
|
-
const CHANGE_EVENT = 'coffre-theme-change';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Applied before first paint, inlined in <head>.
|
|
12
|
-
*
|
|
13
|
-
* Without this the page renders in the system palette and then snaps to the
|
|
14
|
-
* stored choice once React hydrates -- a full-screen flash on every load for
|
|
15
|
-
* anyone who overrode it. Kept as a string so it runs synchronously; there is
|
|
16
|
-
* no way to do this correctly from a component.
|
|
17
|
-
*/
|
|
18
|
-
export const themeBootScript = `(function(){try{var t=localStorage.getItem(${JSON.stringify(
|
|
19
|
-
STORAGE_KEY,
|
|
20
|
-
)});if(t==="light"||t==="dark"){document.documentElement.setAttribute("data-theme",t)}}catch(e){}})()`;
|
|
21
|
-
|
|
22
|
-
function stored(): Theme {
|
|
23
|
-
try {
|
|
24
|
-
const value = localStorage.getItem(STORAGE_KEY);
|
|
25
|
-
return value === 'light' || value === 'dark' ? value : 'system';
|
|
26
|
-
} catch {
|
|
27
|
-
return 'system';
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function apply(theme: Theme) {
|
|
32
|
-
const root = document.documentElement;
|
|
33
|
-
try {
|
|
34
|
-
if (theme === 'system') localStorage.removeItem(STORAGE_KEY);
|
|
35
|
-
else localStorage.setItem(STORAGE_KEY, theme);
|
|
36
|
-
} catch {
|
|
37
|
-
// Storage refused (private mode); the choice still holds for this page.
|
|
38
|
-
}
|
|
39
|
-
if (theme === 'system') root.removeAttribute('data-theme');
|
|
40
|
-
else root.setAttribute('data-theme', theme);
|
|
41
|
-
window.dispatchEvent(new CustomEvent(CHANGE_EVENT));
|
|
42
|
-
}
|
|
43
|
-
|
|
44
5
|
const OPTIONS: { value: Theme; label: string; Icon: typeof Sun }[] = [
|
|
45
6
|
{ value: 'system', label: 'Match system', Icon: Monitor },
|
|
46
7
|
{ value: 'light', label: 'Light', Icon: Sun },
|
|
47
8
|
{ value: 'dark', label: 'Dark', Icon: Moon },
|
|
48
9
|
];
|
|
49
10
|
|
|
50
|
-
/**
|
|
51
|
-
* The stored choice, kept in step with changes made elsewhere (the command
|
|
52
|
-
* palette, another tab).
|
|
53
|
-
*
|
|
54
|
-
* Server-rendered markup cannot know the stored preference, so it starts on
|
|
55
|
-
* "system" and corrects itself on mount. Any other approach hydration-mismatches.
|
|
56
|
-
*/
|
|
57
|
-
function useTheme(): Theme {
|
|
58
|
-
const [theme, setThemeState] = useState<Theme>('system');
|
|
59
|
-
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
const sync = () => setThemeState(stored());
|
|
62
|
-
sync();
|
|
63
|
-
window.addEventListener(CHANGE_EVENT, sync);
|
|
64
|
-
window.addEventListener('storage', sync);
|
|
65
|
-
return () => {
|
|
66
|
-
window.removeEventListener(CHANGE_EVENT, sync);
|
|
67
|
-
window.removeEventListener('storage', sync);
|
|
68
|
-
};
|
|
69
|
-
}, []);
|
|
70
|
-
|
|
71
|
-
return theme;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
11
|
/** The theme as a radio group inside a dropdown menu (the account menu). */
|
|
75
12
|
export function ThemeMenuItems() {
|
|
76
|
-
const theme =
|
|
13
|
+
const { theme, setTheme } = usePreferences();
|
|
77
14
|
return (
|
|
78
|
-
<
|
|
15
|
+
<Menu.RadioGroup value={theme} onValueChange={(value: Theme) => setTheme(value)}>
|
|
16
|
+
<Menu.GroupLabel className="menu-label">Theme</Menu.GroupLabel>
|
|
79
17
|
{OPTIONS.map(({ value, label, Icon }) => (
|
|
80
|
-
<
|
|
18
|
+
<Menu.RadioItem key={value} value={value} className="menu-item" closeOnClick>
|
|
81
19
|
<Icon size={15} />
|
|
82
20
|
{label}
|
|
83
|
-
<
|
|
21
|
+
<Menu.RadioItemIndicator className="menu-check">
|
|
84
22
|
<Check size={14} />
|
|
85
|
-
</
|
|
86
|
-
</
|
|
23
|
+
</Menu.RadioItemIndicator>
|
|
24
|
+
</Menu.RadioItem>
|
|
87
25
|
))}
|
|
88
|
-
</
|
|
26
|
+
</Menu.RadioGroup>
|
|
89
27
|
);
|
|
90
28
|
}
|
|
91
29
|
|
|
@@ -94,7 +32,7 @@ export function ThemeMenuItems() {
|
|
|
94
32
|
* A menu for a three-way choice costs a click to find out the current value.
|
|
95
33
|
*/
|
|
96
34
|
export function ThemeToggle() {
|
|
97
|
-
const theme =
|
|
35
|
+
const { theme, setTheme } = usePreferences();
|
|
98
36
|
|
|
99
37
|
return (
|
|
100
38
|
<div className="theme-choice" role="group" aria-label="Colour scheme">
|
|
@@ -105,7 +43,7 @@ export function ThemeToggle() {
|
|
|
105
43
|
aria-pressed={theme === value}
|
|
106
44
|
aria-label={label}
|
|
107
45
|
title={label}
|
|
108
|
-
onClick={() =>
|
|
46
|
+
onClick={() => setTheme(value)}
|
|
109
47
|
>
|
|
110
48
|
<Icon size={14} />
|
|
111
49
|
</button>
|
|
@@ -114,14 +52,9 @@ export function ThemeToggle() {
|
|
|
114
52
|
);
|
|
115
53
|
}
|
|
116
54
|
|
|
117
|
-
/** Imperative theme setter, so the command palette can offer the same options. */
|
|
118
|
-
export function setTheme(theme: Theme) {
|
|
119
|
-
apply(theme);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
55
|
/** The theme as three large choices, for the Settings page. */
|
|
123
56
|
export function ThemeCards() {
|
|
124
|
-
const theme =
|
|
57
|
+
const { theme, setTheme } = usePreferences();
|
|
125
58
|
return (
|
|
126
59
|
<div className="choice-grid" role="group" aria-label="Colour scheme">
|
|
127
60
|
{OPTIONS.map(({ value, label, Icon }) => (
|
|
@@ -130,7 +63,7 @@ export function ThemeCards() {
|
|
|
130
63
|
type="button"
|
|
131
64
|
className="choice"
|
|
132
65
|
aria-pressed={theme === value}
|
|
133
|
-
onClick={() =>
|
|
66
|
+
onClick={() => setTheme(value)}
|
|
134
67
|
>
|
|
135
68
|
<Icon size={16} />
|
|
136
69
|
{label}
|