@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
|
@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
4
4
|
import { shellui } from '@shellui/sdk';
|
|
5
5
|
import type { NavigationItem } from '../config/types';
|
|
6
6
|
import { Drawer, DrawerContent, DrawerTitle, DrawerDescription } from '../../components/ui/drawer';
|
|
7
|
+
import type { WithFadeFromProps, WithoutFadeFromProps } from 'vaul';
|
|
7
8
|
import { ContentView } from '../../components/ContentView';
|
|
8
9
|
import { useModal } from '../modal/ModalContext';
|
|
9
10
|
import { useDrawer } from '../drawer/DrawerContext';
|
|
@@ -23,6 +24,7 @@ import {
|
|
|
23
24
|
resolveDrawerSize,
|
|
24
25
|
resolveDrawerSizeForViewport,
|
|
25
26
|
resolveEffectiveDrawerPosition,
|
|
27
|
+
resolveDrawerChrome,
|
|
26
28
|
isDynamicSizing,
|
|
27
29
|
SHEET_EXPANDED_HEIGHT_CSS,
|
|
28
30
|
} from '../overlays/overlaySize';
|
|
@@ -33,6 +35,8 @@ import { OverlayDrawerPendingBar } from '../overlays/OverlayDrawerPendingBar';
|
|
|
33
35
|
|
|
34
36
|
/** Matches --shellui-overlay-max-height in index.css */
|
|
35
37
|
const OVERLAY_MAX_H = 'var(--shellui-overlay-max-height)';
|
|
38
|
+
/** Matches --shellui-drawer-max-height: the viewport minus the floating offsets. */
|
|
39
|
+
const DRAWER_MAX_H = 'var(--shellui-drawer-max-height)';
|
|
36
40
|
|
|
37
41
|
interface OverlayShellProps {
|
|
38
42
|
children: ReactNode;
|
|
@@ -228,11 +232,16 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
|
|
|
228
232
|
usedFallback: modalSizeFallback,
|
|
229
233
|
wasClamped: modalWasClamped,
|
|
230
234
|
} = useOverlayReportedSize(modalContentSized, isOpen && !isDrawerOpen);
|
|
235
|
+
// Phone sheets grow up to the drawer max height (CSS), so the report is not cut at 92%.
|
|
231
236
|
const {
|
|
232
237
|
reported: drawerReported,
|
|
233
238
|
usedFallback: drawerSizeFallback,
|
|
234
239
|
wasClamped: drawerWasClamped,
|
|
235
|
-
} = useOverlayReportedSize(
|
|
240
|
+
} = useOverlayReportedSize(
|
|
241
|
+
drawerSize.contentSized || drawerDynamic,
|
|
242
|
+
isDrawerOpen,
|
|
243
|
+
isMobile ? 1 : undefined,
|
|
244
|
+
);
|
|
236
245
|
|
|
237
246
|
const modalPending = isOpen && modalContentSized && !modalReported;
|
|
238
247
|
const drawerPending =
|
|
@@ -351,6 +360,10 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
|
|
|
351
360
|
}),
|
|
352
361
|
};
|
|
353
362
|
|
|
363
|
+
// Phone sheet from an app that never reports its size: use the requested preset.
|
|
364
|
+
const drawerPhoneFallback =
|
|
365
|
+
drawerSizeFallback && drawerSize.fallbackHeight ? drawerSize.fallbackHeight : null;
|
|
366
|
+
|
|
354
367
|
const drawerContentStyle: CSSProperties = {
|
|
355
368
|
...drawerSize.style,
|
|
356
369
|
...(drawerSize.contentSized || drawerDynamic ? { transition: 'none' } : {}),
|
|
@@ -366,17 +379,19 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
|
|
|
366
379
|
maxWidth: drawerPendingPx,
|
|
367
380
|
minWidth: drawerPendingPx,
|
|
368
381
|
}
|
|
369
|
-
:
|
|
370
|
-
?
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
382
|
+
: drawerPhoneFallback
|
|
383
|
+
? { height: drawerPhoneFallback, maxHeight: DRAWER_MAX_H }
|
|
384
|
+
: drawerReported
|
|
385
|
+
? drawerIsVertical
|
|
386
|
+
? {
|
|
387
|
+
height: drawerReported.height,
|
|
388
|
+
maxHeight: `min(${drawerReported.height}px, ${DRAWER_MAX_H})`,
|
|
389
|
+
}
|
|
390
|
+
: {
|
|
391
|
+
width: drawerReported.width ?? drawerReported.height,
|
|
392
|
+
maxWidth: `min(${drawerReported.width ?? drawerReported.height}px, 92vw)`,
|
|
393
|
+
}
|
|
394
|
+
: {}),
|
|
380
395
|
};
|
|
381
396
|
|
|
382
397
|
const handleModalOpenChange = (open: boolean) => {
|
|
@@ -397,22 +412,28 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
|
|
|
397
412
|
const drawerDesktopResizable =
|
|
398
413
|
!drawerPending && !isMobile && !drawerDynamic && drawerOptions?.resizable !== false;
|
|
399
414
|
|
|
400
|
-
//
|
|
401
|
-
|
|
415
|
+
// Phones: always a bottom sheet with a drag handle. Desktop: requested edge and options.
|
|
416
|
+
const drawerChrome = resolveDrawerChrome({
|
|
417
|
+
position: drawerPosition,
|
|
418
|
+
isMobile,
|
|
419
|
+
dismiss: drawerDismiss,
|
|
420
|
+
pending: drawerPending,
|
|
421
|
+
desktopResizable: drawerDesktopResizable,
|
|
422
|
+
contentSized: drawerSize.contentSized || drawerDynamic,
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
// Desktop bottom sheets: snap between the configured height and near-full so drag-up
|
|
426
|
+
// expands. Phones never snap (content-height sheets). Skip when desktop free-edge
|
|
427
|
+
// resize is active (those compete with Vaul snaps).
|
|
402
428
|
const drawerSnapPoints = useMemo(() => {
|
|
403
|
-
if (
|
|
404
|
-
if (!drawerDismiss.showDragHandle || !drawerDismiss.dismissible) return undefined;
|
|
405
|
-
if (drawerPending || drawerDesktopResizable) return undefined;
|
|
429
|
+
if (!drawerChrome.allowSnapPoints) return undefined;
|
|
406
430
|
return resolveBottomSheetSnapPoints(drawerOptions, drawerReported?.height ?? null) ?? undefined;
|
|
407
|
-
}, [
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
drawerOptions,
|
|
414
|
-
drawerReported?.height,
|
|
415
|
-
]);
|
|
431
|
+
}, [drawerChrome.allowSnapPoints, drawerOptions, drawerReported?.height]);
|
|
432
|
+
|
|
433
|
+
// Floating sheet: show the scrim from the first snap, not only when expanded.
|
|
434
|
+
const drawerSnapProps: WithFadeFromProps | WithoutFadeFromProps = drawerSnapPoints
|
|
435
|
+
? { snapPoints: drawerSnapPoints, fadeFromIndex: 0 }
|
|
436
|
+
: {};
|
|
416
437
|
|
|
417
438
|
const [drawerActiveSnap, setDrawerActiveSnap] = useState<number | string | null>(null);
|
|
418
439
|
|
|
@@ -482,7 +503,7 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
|
|
|
482
503
|
onOpenChange={handleDrawerOpenChange}
|
|
483
504
|
direction={effectiveDrawerPosition}
|
|
484
505
|
dismissible={drawerDismiss.dismissible}
|
|
485
|
-
|
|
506
|
+
{...drawerSnapProps}
|
|
486
507
|
activeSnapPoint={drawerSnapPoints ? drawerActiveSnap : undefined}
|
|
487
508
|
setActiveSnapPoint={drawerSnapPoints ? setDrawerActiveSnap : undefined}
|
|
488
509
|
>
|
|
@@ -492,13 +513,15 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
|
|
|
492
513
|
size={
|
|
493
514
|
drawerSnapPoints
|
|
494
515
|
? SHEET_EXPANDED_HEIGHT_CSS
|
|
495
|
-
:
|
|
496
|
-
?
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
:
|
|
516
|
+
: drawerPhoneFallback
|
|
517
|
+
? drawerPhoneFallback
|
|
518
|
+
: drawerReported
|
|
519
|
+
? drawerIsVertical
|
|
520
|
+
? `${drawerReported.height}px`
|
|
521
|
+
: `${drawerReported.width ?? drawerReported.height}px`
|
|
522
|
+
: drawerPending
|
|
523
|
+
? `${drawerPendingPx}px`
|
|
524
|
+
: drawerSize.drawerSize
|
|
502
525
|
}
|
|
503
526
|
style={
|
|
504
527
|
drawerSnapPoints
|
|
@@ -511,12 +534,7 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
|
|
|
511
534
|
}
|
|
512
535
|
className={drawerSize.className}
|
|
513
536
|
showCloseButton={!drawerPending && drawerDismiss.showCloseButton}
|
|
514
|
-
showDragHandle={
|
|
515
|
-
!drawerPending &&
|
|
516
|
-
drawerIsVertical &&
|
|
517
|
-
drawerDismiss.showDragHandle &&
|
|
518
|
-
drawerDismiss.dismissible
|
|
519
|
-
}
|
|
537
|
+
showDragHandle={drawerChrome.showDragHandle}
|
|
520
538
|
closeOnOverlayClick={drawerDismiss.closeOnOverlayClick}
|
|
521
539
|
resizable={drawerDesktopResizable}
|
|
522
540
|
>
|
|
@@ -0,0 +1,45 @@
|
|
|
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 type { NavigationItem } from '../../config/types';
|
|
6
|
+
import { AppBarItemIcon } from './AppBarItemIcon';
|
|
7
|
+
|
|
8
|
+
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
9
|
+
|
|
10
|
+
let container: HTMLDivElement;
|
|
11
|
+
let root: Root;
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
container = document.createElement('div');
|
|
15
|
+
document.body.appendChild(container);
|
|
16
|
+
root = createRoot(container);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
act(() => root.unmount());
|
|
21
|
+
container.remove();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
function render(item: Partial<NavigationItem>) {
|
|
25
|
+
act(() =>
|
|
26
|
+
root.render(<AppBarItemIcon item={{ path: 'x', url: '/x', label: 'Docs', ...item }} />),
|
|
27
|
+
);
|
|
28
|
+
return container.firstElementChild as HTMLElement;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
describe('AppBarItemIcon', () => {
|
|
32
|
+
it('renders a plain 16px icon with no muted tile', () => {
|
|
33
|
+
const el = render({ icon: '/icons/book.svg' });
|
|
34
|
+
expect(el.className).toContain('size-4');
|
|
35
|
+
expect(el.className).not.toContain('bg-muted');
|
|
36
|
+
expect(el.className).not.toContain('rounded-md');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('falls back to the default 16px glyph instead of a letter tile', () => {
|
|
40
|
+
const el = render({});
|
|
41
|
+
expect(el.tagName.toLowerCase()).toBe('svg');
|
|
42
|
+
expect(el.getAttribute('class')).toContain('size-4');
|
|
43
|
+
expect(container.textContent).toBe('');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { NavigationItem } from '../../config/types';
|
|
2
|
+
import { NavIcon } from '../sidebar/SidebarIcons';
|
|
3
|
+
import { getExternalFaviconUrl } from '../sidebar/sidebarUtils';
|
|
4
|
+
|
|
5
|
+
function itemIconSrc(item: NavigationItem): string | null {
|
|
6
|
+
if (item.icon) return item.icon;
|
|
7
|
+
if (item.openIn === 'external') return getExternalFaviconUrl(item.url);
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Plain 16px icon for start-nav links and their menus (no tile, like the mock). */
|
|
12
|
+
export function AppBarItemIcon({ item }: { item: NavigationItem }) {
|
|
13
|
+
return (
|
|
14
|
+
<NavIcon
|
|
15
|
+
src={itemIconSrc(item)}
|
|
16
|
+
className="size-4"
|
|
17
|
+
/>
|
|
18
|
+
);
|
|
19
|
+
}
|