@shellui/core 0.7.0-alpha.8 → 0.7.0-beta.1
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 +1 -1
- package/package.json +23 -6
- package/src/components/ui/drawer.tsx +47 -30
- package/src/components/ui/sheet.tsx +18 -12
- package/src/components/ui/shell-divider.spec.tsx +63 -0
- package/src/components/ui/shell-divider.tsx +20 -0
- package/src/components/ui/sidebar.tsx +26 -12
- package/src/components/ui/tooltip.tsx +4 -2
- package/src/features/admin/AdminView.tsx +9 -6
- package/src/features/auth/AuthProvider.tsx +10 -1
- package/src/features/auth/components/LoginButton.spec.tsx +203 -0
- package/src/features/auth/components/LoginButton.tsx +77 -28
- package/src/features/auth/components/LoginButtonIcons.tsx +4 -8
- package/src/features/auth/utils/index.ts +1 -0
- package/src/features/auth/utils/resolveSdkLoginRedirectPath.spec.ts +41 -0
- package/src/features/auth/utils/resolveSdkLoginRedirectPath.ts +31 -0
- package/src/features/chromeActions/ChromeActionsHost.tsx +5 -1
- package/src/features/chromeActions/computeActionInsets.ts +7 -4
- package/src/features/layouts/OverlayShell.tsx +58 -40
- package/src/features/layouts/appbar/AppBarItemIcon.spec.tsx +45 -0
- package/src/features/layouts/appbar/AppBarItemIcon.tsx +19 -0
- package/src/features/layouts/appbar/AppBarLayout.tsx +115 -110
- package/src/features/layouts/appbar/appBarOverflow.spec.ts +27 -0
- package/src/features/layouts/appbar/appBarOverflow.ts +42 -0
- package/src/features/layouts/chrome/CollapsedDesktopTitlebar.tsx +13 -24
- package/src/features/layouts/chrome/ContentDragOverlay.tsx +5 -6
- package/src/features/layouts/chrome/DesktopChrome.tsx +37 -0
- package/src/features/layouts/chrome/DesktopHistoryButtons.tsx +15 -4
- package/src/features/layouts/chrome/MacStrip.tsx +33 -0
- package/src/features/layouts/chrome/constants.ts +36 -8
- package/src/features/layouts/chrome/index.ts +8 -0
- package/src/features/layouts/chrome/stripDragMap.ts +35 -0
- package/src/features/layouts/chrome/stripNoDrag.spec.tsx +103 -0
- package/src/features/layouts/chrome/useScrollHideChrome.ts +3 -8
- package/src/features/layouts/chrome/viewport.ts +11 -4
- package/src/features/layouts/filterNavigationForAuthState.spec.ts +5 -3
- package/src/features/layouts/floating/FloatingBottomDock.tsx +263 -43
- package/src/features/layouts/floating/FloatingLayout.tsx +14 -8
- package/src/features/layouts/floating/FloatingSidebar.tsx +178 -81
- package/src/features/layouts/floating/computeFloatingInsets.ts +22 -4
- package/src/features/layouts/floating/moreSections.spec.ts +28 -0
- package/src/features/layouts/floating/moreSections.ts +31 -0
- package/src/features/layouts/floating/useFloatingChrome.ts +3 -1
- package/src/features/layouts/floating/useSoftKeyboard.spec.ts +39 -0
- package/src/features/layouts/floating/useSoftKeyboard.ts +82 -0
- package/src/features/layouts/fullscreen/FullscreenLayout.spec.tsx +68 -0
- package/src/features/layouts/fullscreen/FullscreenLayout.tsx +47 -10
- package/src/features/layouts/sidebar/NavigationContent.tsx +17 -9
- package/src/features/layouts/sidebar/SidebarIcons.tsx +70 -9
- package/src/features/layouts/sidebar/SidebarInner.spec.tsx +149 -0
- package/src/features/layouts/sidebar/SidebarInner.tsx +103 -43
- package/src/features/layouts/sidebar/SidebarLayout.tsx +24 -17
- package/src/features/layouts/utils.ts +4 -3
- package/src/features/layouts/windows/DesktopDots.tsx +76 -0
- package/src/features/layouts/windows/WindowsLayout.tsx +265 -160
- package/src/features/layouts/windows/deskDots.spec.ts +54 -0
- package/src/features/layouts/windows/deskDots.ts +314 -0
- package/src/features/overlays/ResponsiveModal.tsx +5 -3
- package/src/features/overlays/overlaySize.spec.ts +56 -16
- package/src/features/overlays/overlaySize.ts +114 -31
- package/src/features/overlays/phoneDrawerAnchoring.spec.ts +187 -0
- package/src/features/overlays/useOverlayReportedSize.ts +8 -3
- package/src/features/theme/applyTheme.ts +8 -0
- package/src/features/theme/navContrast.spec.ts +49 -0
- package/src/features/theme/navContrast.ts +108 -0
- package/src/i18n/translations/en/common.json +26 -0
- package/src/i18n/translations/fr/common.json +26 -0
- package/src/index.css +1156 -77
- package/src/service-worker/devCaches.spec.ts +32 -0
- package/src/service-worker/devCaches.ts +27 -0
- package/src/service-worker/sw-dev.ts +23 -23
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @shellui/core
|
|
2
2
|
|
|
3
|
-
React runtime for the
|
|
3
|
+
React runtime for Shellui, the open-source app shell: navigation, layouts, light and dark themes, sign-in, and your apps hosted as micro frontends in one interface. `@shellui/cli` depends on this package. Install it yourself when you import config types or `useAuth` from host code.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
npm install @shellui/core
|
package/package.json
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shellui/core",
|
|
3
|
-
"version": "0.7.0-
|
|
4
|
-
"description": "Shellui
|
|
3
|
+
"version": "0.7.0-beta.1",
|
|
4
|
+
"description": "React runtime for Shellui, the open-source app shell. Renders navigation, layouts, themes with light and dark modes, sign-in and identity, and hosts your apps as micro frontends in one interface. MIT licensed.",
|
|
5
|
+
"homepage": "https://shellui.com",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/shellui/shellui.git",
|
|
9
|
+
"directory": "packages/core"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/shellui/shellui/issues"
|
|
13
|
+
},
|
|
5
14
|
"main": "src/index.ts",
|
|
6
15
|
"type": "module",
|
|
7
16
|
"exports": {
|
|
@@ -37,9 +46,17 @@
|
|
|
37
46
|
],
|
|
38
47
|
"keywords": [
|
|
39
48
|
"shellui",
|
|
40
|
-
"
|
|
49
|
+
"app shell",
|
|
50
|
+
"micro frontends",
|
|
41
51
|
"react",
|
|
42
|
-
"
|
|
52
|
+
"admin dashboard",
|
|
53
|
+
"internal tools",
|
|
54
|
+
"navigation",
|
|
55
|
+
"layout",
|
|
56
|
+
"themes",
|
|
57
|
+
"dark mode",
|
|
58
|
+
"authentication",
|
|
59
|
+
"open source"
|
|
43
60
|
],
|
|
44
61
|
"author": "Shellui",
|
|
45
62
|
"license": "MIT",
|
|
@@ -73,7 +90,7 @@
|
|
|
73
90
|
"workbox-routing": "^7.4.0",
|
|
74
91
|
"workbox-strategies": "^7.4.0",
|
|
75
92
|
"workbox-window": "^7.4.0",
|
|
76
|
-
"@shellui/sdk": "0.7.0-
|
|
93
|
+
"@shellui/sdk": "0.7.0-beta.1"
|
|
77
94
|
},
|
|
78
95
|
"peerDependencies": {
|
|
79
96
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -92,7 +109,7 @@
|
|
|
92
109
|
"tailwindcss-animate": "^1.0.7",
|
|
93
110
|
"ts-json-schema-generator": "^2.9.0",
|
|
94
111
|
"typescript": "^5.9.3",
|
|
95
|
-
"vitest": "^4.1.
|
|
112
|
+
"vitest": "^4.1.12"
|
|
96
113
|
},
|
|
97
114
|
"scripts": {
|
|
98
115
|
"test": "node scripts/test.js",
|
|
@@ -17,11 +17,13 @@ import {
|
|
|
17
17
|
import { Drawer as VaulDrawer } from 'vaul';
|
|
18
18
|
import { cn } from '../../lib/utils';
|
|
19
19
|
import { Z_INDEX } from '../../lib/z-index';
|
|
20
|
+
import { readCssLengthPx } from '../../features/layouts/chrome/viewport';
|
|
20
21
|
|
|
21
22
|
export type DrawerDirection = 'top' | 'bottom' | 'left' | 'right';
|
|
22
23
|
|
|
23
24
|
const MIN_DRAWER_SIZE = 240;
|
|
24
|
-
|
|
25
|
+
/** Fallback edge offset (desktop gap) when the CSS token cannot be read. */
|
|
26
|
+
const FALLBACK_DRAWER_OFFSET_PX = 12;
|
|
25
27
|
|
|
26
28
|
const Drawer = ({
|
|
27
29
|
open,
|
|
@@ -65,7 +67,7 @@ const DrawerOverlay = forwardRef<
|
|
|
65
67
|
<VaulDrawer.Overlay
|
|
66
68
|
ref={ref}
|
|
67
69
|
data-drawer-overlay
|
|
68
|
-
className={cn('fixed inset-0 bg-
|
|
70
|
+
className={cn('fixed inset-0 bg-[var(--shellui-scrim)]', className)}
|
|
69
71
|
style={{ zIndex: Z_INDEX.DRAWER_OVERLAY }}
|
|
70
72
|
onClick={(e) => {
|
|
71
73
|
if (!closeOnClick) {
|
|
@@ -80,42 +82,53 @@ const DrawerOverlay = forwardRef<
|
|
|
80
82
|
));
|
|
81
83
|
DrawerOverlay.displayName = VaulDrawer.Overlay.displayName;
|
|
82
84
|
|
|
83
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* Floating panel: a gap away from the window edge on its outer sides (the offsets
|
|
87
|
+
* include the safe area), all corners rounded, hairline border and soft shadow.
|
|
88
|
+
*/
|
|
89
|
+
const drawerPanel =
|
|
90
|
+
'fixed flex flex-col overflow-clip border border-[var(--shellui-drawer-border)] bg-background rounded-[var(--shellui-drawer-radius)] shadow-[var(--shellui-drawer-shadow)]';
|
|
91
|
+
|
|
92
|
+
/** Base layout classes per direction. Max dimension is applied via style so size prop can override. */
|
|
84
93
|
const drawerContentByDirection: Record<DrawerDirection, string> = {
|
|
85
|
-
bottom:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
right:
|
|
90
|
-
'fixed inset-y-0 right-0 ml-24 flex h-full w-auto flex-col rounded-l-xl border border-border bg-background pr-[var(--shellui-safe-area-right)]',
|
|
94
|
+
bottom: `${drawerPanel} bottom-[var(--shellui-drawer-bottom)] left-[var(--shellui-drawer-left)] right-[var(--shellui-drawer-right)] h-auto max-md:rounded-[var(--shellui-sheet-radius)]`,
|
|
95
|
+
top: `${drawerPanel} top-[var(--shellui-drawer-top)] left-[var(--shellui-drawer-left)] right-[var(--shellui-drawer-right)] h-auto`,
|
|
96
|
+
left: `${drawerPanel} top-[var(--shellui-drawer-top)] bottom-[var(--shellui-drawer-bottom)] left-[var(--shellui-drawer-left)] h-auto w-auto`,
|
|
97
|
+
right: `${drawerPanel} top-[var(--shellui-drawer-top)] bottom-[var(--shellui-drawer-bottom)] right-[var(--shellui-drawer-right)] h-auto w-auto`,
|
|
91
98
|
};
|
|
92
99
|
|
|
93
|
-
/** Free-edge resize handle (opposite the anchored side). */
|
|
100
|
+
/** Free-edge resize handle (opposite the anchored side), 8px, inside the panel. */
|
|
94
101
|
const resizeHandleByDirection: Record<DrawerDirection, { className: string; cursor: string }> = {
|
|
95
102
|
right: {
|
|
96
|
-
className: 'absolute left-0 top-3 bottom-3 w-
|
|
103
|
+
className: 'absolute left-0 top-3 bottom-3 w-2',
|
|
97
104
|
cursor: 'ew-resize',
|
|
98
105
|
},
|
|
99
106
|
left: {
|
|
100
|
-
className: 'absolute right-0 top-3 bottom-3 w-
|
|
107
|
+
className: 'absolute right-0 top-3 bottom-3 w-2',
|
|
101
108
|
cursor: 'ew-resize',
|
|
102
109
|
},
|
|
103
110
|
bottom: {
|
|
104
|
-
className: 'absolute top-0 left-3 right-3 h-
|
|
111
|
+
className: 'absolute top-0 left-3 right-3 h-2',
|
|
105
112
|
cursor: 'ns-resize',
|
|
106
113
|
},
|
|
107
114
|
top: {
|
|
108
|
-
className: 'absolute bottom-0 left-3 right-3 h-
|
|
115
|
+
className: 'absolute bottom-0 left-3 right-3 h-2',
|
|
109
116
|
cursor: 'ns-resize',
|
|
110
117
|
},
|
|
111
118
|
};
|
|
112
119
|
|
|
120
|
+
function readDrawerOffsetPx(side: 'top' | 'right' | 'bottom' | 'left'): number {
|
|
121
|
+
const px = readCssLengthPx(`var(--shellui-drawer-${side})`);
|
|
122
|
+
return px > 0 ? px : FALLBACK_DRAWER_OFFSET_PX;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Largest panel size: the viewport minus the offsets on both ends of the size axis. */
|
|
113
126
|
function maxPrimarySize(direction: DrawerDirection): number {
|
|
114
127
|
const isVertical = direction === 'top' || direction === 'bottom';
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
);
|
|
128
|
+
const margin = isVertical
|
|
129
|
+
? readDrawerOffsetPx('top') + readDrawerOffsetPx('bottom')
|
|
130
|
+
: readDrawerOffsetPx('left') + readDrawerOffsetPx('right');
|
|
131
|
+
return Math.max(MIN_DRAWER_SIZE, (isVertical ? window.innerHeight : window.innerWidth) - margin);
|
|
119
132
|
}
|
|
120
133
|
|
|
121
134
|
function clampDrawerSize(px: number, direction: DrawerDirection): number {
|
|
@@ -264,22 +277,25 @@ const DrawerContent = forwardRef<ComponentRef<typeof VaulDrawer.Content>, Drawer
|
|
|
264
277
|
? isVertical
|
|
265
278
|
? {
|
|
266
279
|
height: effectiveSize,
|
|
267
|
-
maxHeight: `min(${effectiveSize},
|
|
280
|
+
maxHeight: `min(${effectiveSize}, var(--shellui-drawer-max-height))`,
|
|
268
281
|
}
|
|
269
282
|
: {
|
|
270
283
|
width: effectiveSize,
|
|
271
|
-
maxWidth: `min(${effectiveSize},
|
|
284
|
+
maxWidth: `min(${effectiveSize}, var(--shellui-drawer-max-width))`,
|
|
272
285
|
}
|
|
273
286
|
: size === null
|
|
274
287
|
? isVertical
|
|
275
|
-
? { maxHeight: 'var(--shellui-
|
|
276
|
-
: { maxWidth: 'min(90vw,
|
|
288
|
+
? { maxHeight: 'var(--shellui-drawer-max-height)' }
|
|
289
|
+
: { maxWidth: 'min(90vw, var(--shellui-drawer-max-width))' }
|
|
277
290
|
: isVertical
|
|
278
291
|
? {
|
|
279
292
|
height: effectiveSize,
|
|
280
|
-
maxHeight: `min(${effectiveSize}, var(--shellui-
|
|
293
|
+
maxHeight: `min(${effectiveSize}, var(--shellui-drawer-max-height))`,
|
|
281
294
|
}
|
|
282
|
-
: {
|
|
295
|
+
: {
|
|
296
|
+
width: effectiveSize,
|
|
297
|
+
maxWidth: `min(${effectiveSize}, var(--shellui-drawer-max-width))`,
|
|
298
|
+
};
|
|
283
299
|
|
|
284
300
|
const resizeHandle = resizeHandleByDirection[pos];
|
|
285
301
|
|
|
@@ -387,7 +403,7 @@ DrawerHeader.displayName = 'DrawerHeader';
|
|
|
387
403
|
const DrawerFooter = ({ className, ...props }: HTMLAttributes<HTMLDivElement>) => (
|
|
388
404
|
<div
|
|
389
405
|
className={cn(
|
|
390
|
-
'mt-auto flex flex-col-reverse gap-2 border-t border-border px-6
|
|
406
|
+
'mt-auto flex flex-col-reverse gap-2 border-t border-border px-6 py-4 sm:flex-row sm:justify-end',
|
|
391
407
|
className,
|
|
392
408
|
)}
|
|
393
409
|
{...props}
|
|
@@ -428,14 +444,15 @@ const DrawerHandle = forwardRef<
|
|
|
428
444
|
ref={ref}
|
|
429
445
|
data-drawer-handle
|
|
430
446
|
className={cn(
|
|
431
|
-
//
|
|
432
|
-
'mx-auto mt-1.5 h-[
|
|
447
|
+
// Same pill as the More sheet handle: 36 x 5px, 6px from the top (Vaul adds the 44px hit area).
|
|
448
|
+
'mx-auto mt-1.5 h-[5px] w-9 shrink-0 rounded-full !opacity-100',
|
|
433
449
|
className,
|
|
434
450
|
)}
|
|
435
451
|
style={{
|
|
436
|
-
// Inline wins over Vaul
|
|
437
|
-
background: 'color-mix(in oklch, var(--
|
|
438
|
-
|
|
452
|
+
// Inline wins over Vaul's injected `background: #e2e2e4`
|
|
453
|
+
background: 'color-mix(in oklch, var(--foreground) 22%, transparent)',
|
|
454
|
+
width: '36px',
|
|
455
|
+
height: '5px',
|
|
439
456
|
borderRadius: '9999px',
|
|
440
457
|
...style,
|
|
441
458
|
}}
|
|
@@ -35,26 +35,32 @@ const SheetOverlay = forwardRef<
|
|
|
35
35
|
<SheetPrimitive.Overlay
|
|
36
36
|
ref={ref}
|
|
37
37
|
data-sheet-overlay=""
|
|
38
|
-
className={cn('fixed inset-0 bg-
|
|
38
|
+
className={cn('fixed inset-0 bg-[var(--shellui-scrim)]', className)}
|
|
39
39
|
style={{ zIndex: Z_INDEX.SIDEBAR_SHEET_OVERLAY, ...style }}
|
|
40
40
|
{...props}
|
|
41
41
|
/>
|
|
42
42
|
));
|
|
43
43
|
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
/** Floating sheet: same offsets, radius, border and shadow as the drawer panel. */
|
|
46
|
+
const sheetVariants = cva(
|
|
47
|
+
'fixed flex flex-col gap-4 overflow-clip border border-[var(--shellui-drawer-border)] bg-background rounded-[var(--shellui-drawer-radius)] shadow-[var(--shellui-drawer-shadow)]',
|
|
48
|
+
{
|
|
49
|
+
variants: {
|
|
50
|
+
side: {
|
|
51
|
+
top: 'top-[var(--shellui-drawer-top)] left-[var(--shellui-drawer-left)] right-[var(--shellui-drawer-right)]',
|
|
52
|
+
bottom:
|
|
53
|
+
'bottom-[var(--shellui-drawer-bottom)] left-[var(--shellui-drawer-left)] right-[var(--shellui-drawer-right)] max-md:rounded-[var(--shellui-sheet-radius)]',
|
|
54
|
+
left: 'top-[var(--shellui-drawer-top)] bottom-[var(--shellui-drawer-bottom)] left-[var(--shellui-drawer-left)] w-3/4 max-w-[var(--shellui-drawer-max-width)] sm:max-w-sm',
|
|
55
|
+
right:
|
|
56
|
+
'top-[var(--shellui-drawer-top)] bottom-[var(--shellui-drawer-bottom)] right-[var(--shellui-drawer-right)] w-3/4 max-w-[var(--shellui-drawer-max-width)] sm:max-w-sm',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
defaultVariants: {
|
|
60
|
+
side: 'right',
|
|
52
61
|
},
|
|
53
62
|
},
|
|
54
|
-
|
|
55
|
-
side: 'right',
|
|
56
|
-
},
|
|
57
|
-
});
|
|
63
|
+
);
|
|
58
64
|
|
|
59
65
|
interface SheetContentProps
|
|
60
66
|
extends
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
import { act } from 'react';
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client';
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
5
|
+
import { readFileSync } from 'node:fs';
|
|
6
|
+
import { resolve } from 'node:path';
|
|
7
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuSeparator } from './dropdown-menu';
|
|
8
|
+
import { ShellDivider } from './shell-divider';
|
|
9
|
+
|
|
10
|
+
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
11
|
+
|
|
12
|
+
let container: HTMLDivElement;
|
|
13
|
+
let root: Root;
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
container = document.createElement('div');
|
|
17
|
+
document.body.appendChild(container);
|
|
18
|
+
root = createRoot(container);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
act(() => root.unmount());
|
|
23
|
+
container.remove();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const css = readFileSync(resolve(__dirname, '../../index.css'), 'utf8');
|
|
27
|
+
|
|
28
|
+
describe('ShellDivider', () => {
|
|
29
|
+
it('renders the shared divider as a separator', () => {
|
|
30
|
+
act(() => root.render(<ShellDivider className="-mx-2" />));
|
|
31
|
+
const el = container.firstElementChild;
|
|
32
|
+
expect(el?.getAttribute('role')).toBe('separator');
|
|
33
|
+
expect(el?.className).toBe('shellui-divider -mx-2');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('is a full-width hairline with no margin of its own (kit shell.css)', () => {
|
|
37
|
+
const rule = /\.shellui-divider \{([^}]*)\}/.exec(css)?.[1] ?? '';
|
|
38
|
+
expect(rule).toContain('height: 1px');
|
|
39
|
+
expect(rule).toContain('background: var(--shellui-hairline)');
|
|
40
|
+
expect(rule).not.toContain('margin');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('is hidden in the sidebar inset footer (sidebar-inset spec: no footer hairline)', () => {
|
|
44
|
+
expect(css).toMatch(
|
|
45
|
+
/\[data-shellui-layout-variant='inset'\]\s+\.shellui-nav\[data-shellui-nav-footer\]\s+>\s+\[data-shellui-footer-divider\]\s*\{\s*background: transparent;/,
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('menus keep the full-bleed shadcn separator (kit .menu hr)', () => {
|
|
50
|
+
act(() =>
|
|
51
|
+
root.render(
|
|
52
|
+
<DropdownMenu open>
|
|
53
|
+
<DropdownMenuContent>
|
|
54
|
+
<DropdownMenuSeparator />
|
|
55
|
+
</DropdownMenuContent>
|
|
56
|
+
</DropdownMenu>,
|
|
57
|
+
),
|
|
58
|
+
);
|
|
59
|
+
const sep = document.body.querySelector('[role="separator"]');
|
|
60
|
+
expect(sep?.className).toContain('-mx-1');
|
|
61
|
+
expect(sep?.className).toContain('bg-border');
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
import { cn } from '../../lib/utils';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The one divider used inside the shell panels (see `.shellui-divider` in
|
|
6
|
+
* index.css): a full-width 1px --shellui-hairline, as in the layouts redesign
|
|
7
|
+
* kit. Inside a padded container, pass negative inline margins (e.g. `-mx-2`)
|
|
8
|
+
* so it still runs edge to edge.
|
|
9
|
+
*/
|
|
10
|
+
export function ShellDivider({ className, ...props }: ComponentPropsWithoutRef<'div'>) {
|
|
11
|
+
return (
|
|
12
|
+
<div
|
|
13
|
+
role="separator"
|
|
14
|
+
aria-orientation="horizontal"
|
|
15
|
+
data-shellui-divider=""
|
|
16
|
+
className={cn('shellui-divider', className)}
|
|
17
|
+
{...props}
|
|
18
|
+
/>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
3
|
import { Slot } from '@radix-ui/react-slot';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
4
5
|
|
|
5
6
|
import { useIsMobile } from '../../hooks/use-mobile';
|
|
6
7
|
import { cn } from '../../lib/utils';
|
|
@@ -46,7 +47,8 @@ const SIDEBAR_WIDTH_DEFAULT_PX = 256;
|
|
|
46
47
|
const SIDEBAR_WIDTH_MIN_PX = 230;
|
|
47
48
|
const SIDEBAR_WIDTH_MAX_PX = 480;
|
|
48
49
|
/** Cap at the viewport so a phone narrower than 18rem still gets a full-width sheet. */
|
|
49
|
-
|
|
50
|
+
/** Phone nav sheet width, capped so the floating sheet keeps its gap on both sides. */
|
|
51
|
+
const SIDEBAR_WIDTH_MOBILE = 'min(18rem, 100%, calc(100% - 2 * var(--shellui-drawer-gap)))';
|
|
50
52
|
const SIDEBAR_WIDTH_ICON = '3rem';
|
|
51
53
|
const SIDEBAR_KEYBOARD_SHORTCUT = 'b';
|
|
52
54
|
/** Ignore tiny pointer moves so a rail click still toggles. */
|
|
@@ -222,7 +224,7 @@ function SidebarProvider({
|
|
|
222
224
|
|
|
223
225
|
return (
|
|
224
226
|
<SidebarContext.Provider value={contextValue}>
|
|
225
|
-
<TooltipProvider delayDuration={
|
|
227
|
+
<TooltipProvider delayDuration={200}>
|
|
226
228
|
<div
|
|
227
229
|
data-slot="sidebar-wrapper"
|
|
228
230
|
data-resizing={isResizing ? '' : undefined}
|
|
@@ -248,6 +250,9 @@ function SidebarProvider({
|
|
|
248
250
|
);
|
|
249
251
|
}
|
|
250
252
|
|
|
253
|
+
/** DOM id of the sidebar panel, for the trigger's `aria-controls`. */
|
|
254
|
+
export const SIDEBAR_PANEL_ID = 'shellui-sidebar';
|
|
255
|
+
|
|
251
256
|
function Sidebar({
|
|
252
257
|
side = 'left',
|
|
253
258
|
variant = 'sidebar',
|
|
@@ -260,6 +265,7 @@ function Sidebar({
|
|
|
260
265
|
variant?: 'sidebar' | 'floating' | 'inset';
|
|
261
266
|
collapsible?: 'offcanvas' | 'icon' | 'none';
|
|
262
267
|
}) {
|
|
268
|
+
const { t } = useTranslation();
|
|
263
269
|
const context = React.useContext(SidebarContext);
|
|
264
270
|
|
|
265
271
|
if (collapsible === 'none') {
|
|
@@ -294,6 +300,7 @@ function Sidebar({
|
|
|
294
300
|
data-sidebar="sidebar"
|
|
295
301
|
data-slot="sidebar"
|
|
296
302
|
data-mobile="true"
|
|
303
|
+
id={SIDEBAR_PANEL_ID}
|
|
297
304
|
className="w-(--sidebar-width) max-w-full overflow-x-hidden bg-sidebar p-0 text-sidebar-foreground sm:max-w-full [&>button]:hidden"
|
|
298
305
|
style={
|
|
299
306
|
{
|
|
@@ -305,12 +312,10 @@ function Sidebar({
|
|
|
305
312
|
side={side}
|
|
306
313
|
>
|
|
307
314
|
<SheetHeader className="sr-only">
|
|
308
|
-
<SheetTitle>
|
|
309
|
-
<SheetDescription>
|
|
315
|
+
<SheetTitle>{t('desktopChrome.navigation')}</SheetTitle>
|
|
316
|
+
<SheetDescription>{t('shellChrome.sheetDescription')}</SheetDescription>
|
|
310
317
|
</SheetHeader>
|
|
311
|
-
<div className="flex h-full min-h-0 w-full flex-col overflow-hidden
|
|
312
|
-
{children}
|
|
313
|
-
</div>
|
|
318
|
+
<div className="flex h-full min-h-0 w-full flex-col overflow-hidden">{children}</div>
|
|
314
319
|
</SheetContent>
|
|
315
320
|
</Sheet>
|
|
316
321
|
);
|
|
@@ -361,6 +366,7 @@ function Sidebar({
|
|
|
361
366
|
<div
|
|
362
367
|
data-sidebar="sidebar"
|
|
363
368
|
data-slot="sidebar-inner"
|
|
369
|
+
id={SIDEBAR_PANEL_ID}
|
|
364
370
|
className={cn(
|
|
365
371
|
'flex h-full w-full flex-col bg-sidebar',
|
|
366
372
|
'group-data-[variant=inset]:bg-transparent',
|
|
@@ -375,7 +381,8 @@ function Sidebar({
|
|
|
375
381
|
}
|
|
376
382
|
|
|
377
383
|
function SidebarTrigger({ className, onClick, ...props }: React.ComponentProps<typeof Button>) {
|
|
378
|
-
const { toggleSidebar } = useSidebar();
|
|
384
|
+
const { toggleSidebar, isMobile, open, openMobile } = useSidebar();
|
|
385
|
+
const { t } = useTranslation();
|
|
379
386
|
|
|
380
387
|
return (
|
|
381
388
|
<Button
|
|
@@ -384,7 +391,9 @@ function SidebarTrigger({ className, onClick, ...props }: React.ComponentProps<t
|
|
|
384
391
|
data-slot="sidebar-trigger"
|
|
385
392
|
variant="ghost"
|
|
386
393
|
size="icon"
|
|
387
|
-
aria-label=
|
|
394
|
+
aria-label={t('shellChrome.toggleSidebar')}
|
|
395
|
+
aria-expanded={isMobile ? openMobile : open}
|
|
396
|
+
aria-controls={SIDEBAR_PANEL_ID}
|
|
388
397
|
className={cn(
|
|
389
398
|
'size-7 touch-manipulation select-none [-webkit-touch-callout:none]',
|
|
390
399
|
className,
|
|
@@ -413,6 +422,7 @@ function SidebarRail({
|
|
|
413
422
|
side?: 'left' | 'right';
|
|
414
423
|
}) {
|
|
415
424
|
const { toggleSidebar, state, width, setWidth, setIsResizing } = useSidebar();
|
|
425
|
+
const { t } = useTranslation();
|
|
416
426
|
const dragRef = React.useRef<{
|
|
417
427
|
startX: number;
|
|
418
428
|
startWidth: number;
|
|
@@ -486,9 +496,11 @@ function SidebarRail({
|
|
|
486
496
|
data-slot="sidebar-rail"
|
|
487
497
|
data-shellui-no-drag=""
|
|
488
498
|
data-placement={placement}
|
|
489
|
-
aria-label={
|
|
499
|
+
aria-label={
|
|
500
|
+
state === 'expanded' ? t('shellChrome.resizeSidebar') : t('shellChrome.toggleSidebar')
|
|
501
|
+
}
|
|
490
502
|
tabIndex={-1}
|
|
491
|
-
title={state === 'expanded' ? '
|
|
503
|
+
title={state === 'expanded' ? t('shellChrome.dragToResize') : t('shellChrome.toggleSidebar')}
|
|
492
504
|
onClick={(event) => {
|
|
493
505
|
if (didDragRef.current) {
|
|
494
506
|
didDragRef.current = false;
|
|
@@ -586,7 +598,7 @@ function SidebarSeparator({ className, ...props }: React.ComponentProps<typeof S
|
|
|
586
598
|
<Separator
|
|
587
599
|
data-slot="sidebar-separator"
|
|
588
600
|
data-sidebar="separator"
|
|
589
|
-
className={cn('
|
|
601
|
+
className={cn('shellui-divider', className)}
|
|
590
602
|
{...props}
|
|
591
603
|
/>
|
|
592
604
|
);
|
|
@@ -763,6 +775,8 @@ function SidebarMenuButton({
|
|
|
763
775
|
<TooltipContent
|
|
764
776
|
side="right"
|
|
765
777
|
align="center"
|
|
778
|
+
sideOffset={8}
|
|
779
|
+
className="rounded-[calc(var(--shellui-r-row)-1px)] border-0 bg-foreground px-2 py-1 text-xs font-medium text-background shadow-none"
|
|
766
780
|
hidden={state !== 'collapsed' || isMobile}
|
|
767
781
|
{...tooltip}
|
|
768
782
|
/>
|
|
@@ -32,15 +32,17 @@ TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
|
32
32
|
export interface AppBarTooltipProps {
|
|
33
33
|
label: string;
|
|
34
34
|
children: ReactNode;
|
|
35
|
+
/** Defaults to below; the windows taskbar opens it above. */
|
|
36
|
+
side?: 'top' | 'bottom';
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
/** Themed tooltip for app-bar end buttons: no arrow, no animation. */
|
|
38
|
-
function AppBarTooltip({ label, children }: AppBarTooltipProps) {
|
|
40
|
+
function AppBarTooltip({ label, children, side = 'bottom' }: AppBarTooltipProps) {
|
|
39
41
|
return (
|
|
40
42
|
<Tooltip delayDuration={200}>
|
|
41
43
|
<TooltipTrigger asChild>{children}</TooltipTrigger>
|
|
42
44
|
<TooltipContent
|
|
43
|
-
side=
|
|
45
|
+
side={side}
|
|
44
46
|
align="center"
|
|
45
47
|
>
|
|
46
48
|
{label}
|
|
@@ -10,8 +10,8 @@ import { useConfig } from '../config/useConfig';
|
|
|
10
10
|
import type { NavigationItem } from '../config/types';
|
|
11
11
|
import { AppLayout } from '../layouts/AppLayout';
|
|
12
12
|
import {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
14
|
+
MAC_LIGHTS_SAFE_PX,
|
|
15
15
|
isShellUiRootWindow,
|
|
16
16
|
SafeAreaTopbarOffset,
|
|
17
17
|
SafeAreaTopbarStrip,
|
|
@@ -74,9 +74,9 @@ export const AdminView = () => {
|
|
|
74
74
|
|
|
75
75
|
const showSafeAreaTopbar = isShellUiRootWindow();
|
|
76
76
|
const trafficLights = useMacTrafficLights();
|
|
77
|
-
const chromeInset = trafficLights
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
const chromeInset = trafficLights ? MAC_LIGHTS_SAFE_PX : undefined;
|
|
78
|
+
// macOS desktop: the header is the 32px strip, controls centre on the lights line.
|
|
79
|
+
const macStrip = trafficLights && !isMobile;
|
|
80
80
|
const headerStyle = {
|
|
81
81
|
paddingLeft: chromeInset ?? 'max(0.5rem, var(--shellui-safe-area-left))',
|
|
82
82
|
paddingRight: 'max(0.75rem, var(--shellui-safe-area-right))',
|
|
@@ -85,7 +85,7 @@ export const AdminView = () => {
|
|
|
85
85
|
paddingTop: 'var(--shellui-safe-area-top)',
|
|
86
86
|
height: `calc(${ADMIN_HEADER_HEIGHT_PX}px + var(--shellui-safe-area-top))`,
|
|
87
87
|
}
|
|
88
|
-
: { height: ADMIN_HEADER_HEIGHT_PX }),
|
|
88
|
+
: { height: macStrip ? DESKTOP_TITLEBAR_HEIGHT_PX : ADMIN_HEADER_HEIGHT_PX }),
|
|
89
89
|
} as const;
|
|
90
90
|
|
|
91
91
|
return (
|
|
@@ -102,11 +102,13 @@ export const AdminView = () => {
|
|
|
102
102
|
{...(trafficLights
|
|
103
103
|
? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
|
|
104
104
|
: {})}
|
|
105
|
+
{...(macStrip ? { 'data-shellui-mac-strip': '' } : {})}
|
|
105
106
|
>
|
|
106
107
|
<Button
|
|
107
108
|
type="button"
|
|
108
109
|
variant="ghost"
|
|
109
110
|
size="sm"
|
|
111
|
+
className={macStrip ? 'h-6 px-2 text-[13px]' : undefined}
|
|
110
112
|
data-shellui-no-drag=""
|
|
111
113
|
onClick={() => navigate('/')}
|
|
112
114
|
>
|
|
@@ -127,6 +129,7 @@ export const AdminView = () => {
|
|
|
127
129
|
</Button>
|
|
128
130
|
<div
|
|
129
131
|
data-shellui-no-drag=""
|
|
132
|
+
data-shellui-strip-end=""
|
|
130
133
|
className="flex items-center gap-2"
|
|
131
134
|
>
|
|
132
135
|
<LoginButton
|
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
type InFlightSlot,
|
|
40
40
|
} from './utils';
|
|
41
41
|
import { buildAuthUrlWithNext } from './utils/buildAuthUrlWithNext';
|
|
42
|
+
import { resolveSdkLoginRedirectPath } from './utils/resolveSdkLoginRedirectPath';
|
|
42
43
|
import {
|
|
43
44
|
beginDesktopOAuth,
|
|
44
45
|
clearDesktopPkce,
|
|
@@ -942,7 +943,15 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
|
|
|
942
943
|
return;
|
|
943
944
|
}
|
|
944
945
|
|
|
945
|
-
|
|
946
|
+
const currentPath =
|
|
947
|
+
typeof window !== 'undefined'
|
|
948
|
+
? `${window.location.pathname}${window.location.search}`
|
|
949
|
+
: '/';
|
|
950
|
+
startOAuth(
|
|
951
|
+
provider,
|
|
952
|
+
resolveSdkLoginRedirectPath(payload.redirectPath, currentPath),
|
|
953
|
+
payload.oauthClientId,
|
|
954
|
+
);
|
|
946
955
|
});
|
|
947
956
|
|
|
948
957
|
return () => cleanup();
|