@shellui/core 0.4.0 → 0.5.0-alpha.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 +2 -2
- package/package.json +15 -3
- package/schemas/curated-themes.json +4035 -0
- package/schemas/shellui.config.schema.json +961 -0
- package/schemas/shellui.theme.schema.json +187 -0
- package/src/app.tsx +4 -1
- package/src/components/ContentView.tsx +144 -9
- package/src/components/LoadingOverlay.tsx +1 -1
- package/src/components/ui/alert-dialog.tsx +1 -1
- package/src/components/ui/dialog.tsx +23 -5
- package/src/components/ui/drawer.tsx +282 -42
- package/src/components/ui/dropdown-menu.tsx +7 -2
- package/src/components/ui/input.tsx +21 -0
- package/src/components/ui/separator.tsx +23 -0
- package/src/components/ui/sheet.tsx +220 -0
- package/src/components/ui/sidebar.tsx +785 -221
- package/src/components/ui/skeleton.tsx +13 -0
- package/src/constants/urls.ts +1 -0
- package/src/features/admin/utils.ts +2 -45
- package/src/features/alertDialog/DialogContext.tsx +1 -1
- package/src/features/auth/components/LoginButton.tsx +25 -18
- package/src/features/auth/components/LoginPreferencesControls.tsx +124 -0
- package/src/features/auth/components/LoginView.tsx +131 -49
- package/src/features/config/types.ts +64 -82
- package/src/features/drawer/DrawerContext.tsx +55 -19
- package/src/features/layouts/AppLayout.tsx +3 -3
- package/src/features/layouts/OverlayShell.tsx +376 -77
- package/src/features/layouts/appbar/AppBarLayout.tsx +501 -88
- package/src/features/layouts/branding/AppBrandIcon.tsx +95 -0
- package/src/features/layouts/branding/resolveThemeAsset.spec.ts +33 -0
- package/src/features/layouts/branding/resolveThemeAsset.ts +33 -0
- package/src/features/layouts/chrome/CollapsedDesktopTitlebar.tsx +49 -0
- package/src/features/layouts/chrome/ContentDragOverlay.tsx +19 -0
- package/src/features/layouts/chrome/DesktopBackButton.tsx +71 -0
- package/src/features/layouts/chrome/DesktopChrome.tsx +28 -0
- package/src/features/layouts/chrome/DesktopForwardButton.tsx +59 -0
- package/src/features/layouts/chrome/DesktopHistoryButtons.tsx +16 -0
- package/src/features/layouts/chrome/constants.ts +11 -0
- package/src/features/layouts/chrome/goDesktopBack.spec.ts +218 -0
- package/src/features/layouts/chrome/goDesktopBack.ts +106 -0
- package/src/features/layouts/chrome/index.ts +26 -0
- package/src/features/layouts/chrome/runtime.ts +45 -0
- package/src/features/layouts/findMatchingNavigationItem.spec.ts +55 -0
- package/src/features/layouts/fullscreen/FullscreenLayout.tsx +17 -1
- package/src/features/layouts/isFrameForAppUrl.spec.ts +33 -0
- package/src/features/layouts/sidebar/NavigationContent.tsx +70 -34
- package/src/features/layouts/sidebar/SidebarIcons.tsx +41 -42
- package/src/features/layouts/sidebar/SidebarInner.tsx +142 -24
- package/src/features/layouts/sidebar/SidebarLayout.tsx +100 -37
- package/src/features/layouts/sidebar/sidebarUtils.ts +0 -7
- package/src/features/layouts/sidebar/types.ts +3 -3
- package/src/features/layouts/utils.ts +73 -5
- package/src/features/layouts/windows/WindowsLayout.tsx +173 -61
- package/src/features/modal/ModalContext.spec.ts +77 -0
- package/src/features/modal/ModalContext.tsx +32 -57
- package/src/features/modal/validateAndNormalizeUrl.ts +96 -0
- package/src/features/overlays/OverlayDrawerPendingBar.tsx +26 -0
- package/src/features/overlays/OverlayDynamicDemoView.tsx +108 -0
- package/src/features/overlays/OverlayPendingSpinner.tsx +18 -0
- package/src/features/overlays/ResponsiveModal.tsx +483 -0
- package/src/features/overlays/overlaySize.spec.ts +71 -0
- package/src/features/overlays/overlaySize.ts +228 -0
- package/src/features/overlays/useOverlayReportedSize.ts +130 -0
- package/src/features/settings/SettingsProvider.tsx +66 -46
- package/src/features/settings/SettingsView.tsx +42 -47
- package/src/features/settings/components/Appearance.tsx +305 -55
- package/src/features/settings/components/develop/DrawerTestButtons.tsx +18 -0
- package/src/features/settings/components/develop/ModalTestButtons.tsx +23 -0
- package/src/features/settings/utils/getResolvedAppearanceForSettings.ts +11 -5
- package/src/features/storage/StoragePickerContext.tsx +3 -3
- package/src/features/theme/applyTheme.ts +143 -0
- package/src/features/theme/color.ts +83 -0
- package/src/features/theme/curated/amber-minimal.json +86 -0
- package/src/features/theme/curated/amethyst-haze.json +86 -0
- package/src/features/theme/curated/astro-vista.json +86 -0
- package/src/features/theme/curated/bold-tech.json +86 -0
- package/src/features/theme/curated/bubblegum.json +86 -0
- package/src/features/theme/curated/caffeine.json +83 -0
- package/src/features/theme/curated/candyland.json +86 -0
- package/src/features/theme/curated/catppuccin.json +86 -0
- package/src/features/theme/curated/claude.json +86 -0
- package/src/features/theme/curated/claymorphism.json +86 -0
- package/src/features/theme/curated/clean-slate.json +86 -0
- package/src/features/theme/curated/cosmic-night.json +86 -0
- package/src/features/theme/curated/cyberpunk.json +86 -0
- package/src/features/theme/curated/darkmatter.json +86 -0
- package/src/features/theme/curated/doom-64.json +86 -0
- package/src/features/theme/curated/elegant-luxury.json +86 -0
- package/src/features/theme/curated/graphite.json +86 -0
- package/src/features/theme/curated/index.ts +260 -0
- package/src/features/theme/curated/kodama-grove.json +86 -0
- package/src/features/theme/curated/light-green.json +87 -0
- package/src/features/theme/curated/midnight-bloom.json +86 -0
- package/src/features/theme/curated/mocha-mousse.json +86 -0
- package/src/features/theme/curated/modern-minimal.json +86 -0
- package/src/features/theme/curated/mono.json +84 -0
- package/src/features/theme/curated/nature.json +86 -0
- package/src/features/theme/curated/neo-brutalism.json +86 -0
- package/src/features/theme/curated/northern-lights.json +86 -0
- package/src/features/theme/curated/notebook.json +87 -0
- package/src/features/theme/curated/ocean-breeze.json +86 -0
- package/src/features/theme/curated/pastel-dreams.json +86 -0
- package/src/features/theme/curated/perpetuity.json +86 -0
- package/src/features/theme/curated/quantum-rose.json +86 -0
- package/src/features/theme/curated/retro-arcade.json +86 -0
- package/src/features/theme/curated/sage-garden.json +86 -0
- package/src/features/theme/curated/shadcn.json +83 -0
- package/src/features/theme/curated/shellui.json +82 -0
- package/src/features/theme/curated/soft-pop.json +86 -0
- package/src/features/theme/curated/solar-dusk.json +86 -0
- package/src/features/theme/curated/starry-night.json +86 -0
- package/src/features/theme/curated/sunset-horizon.json +86 -0
- package/src/features/theme/curated/supabase.json +85 -0
- package/src/features/theme/curated/t3-chat.json +83 -0
- package/src/features/theme/curated/tangerine.json +86 -0
- package/src/features/theme/curated/twitter.json +86 -0
- package/src/features/theme/curated/vercel.json +86 -0
- package/src/features/theme/curated/vintage-paper.json +86 -0
- package/src/features/theme/curated/violet-bloom.json +87 -0
- package/src/features/theme/curated/zen-inspired.json +87 -0
- package/src/features/theme/index.ts +76 -0
- package/src/features/theme/normalize.ts +159 -0
- package/src/features/theme/registry.ts +50 -0
- package/src/features/theme/resolveConfig.ts +182 -0
- package/src/features/theme/safeApplyTheme.ts +147 -0
- package/src/features/theme/themes.spec.ts +276 -0
- package/src/features/theme/themes.ts +82 -558
- package/src/features/theme/tokenKeys.ts +60 -0
- package/src/features/theme/types.ts +170 -0
- package/src/features/theme/useTheme.tsx +48 -50
- package/src/hooks/use-mobile.tsx +19 -0
- package/src/i18n/translations/en/common.json +41 -0
- package/src/i18n/translations/en/settings.json +10 -2
- package/src/i18n/translations/fr/common.json +41 -0
- package/src/i18n/translations/fr/settings.json +10 -2
- package/src/index.css +372 -128
- package/src/index.ts +71 -0
- package/src/lib/z-index.ts +4 -1
- package/src/routes/components/IndexRoute.tsx +12 -2
- package/src/routes/components/NavigationItemRoute.tsx +1 -10
- package/src/routes/hooks/useNavigationItems.ts +29 -44
- package/src/routes/routes.tsx +58 -27
- package/tailwind.config.js +27 -27
- package/src/features/layouts/sidebar/BottomNavItem.tsx +0 -88
- package/src/features/layouts/sidebar/MobileBottomNav.tsx +0 -168
package/src/index.ts
CHANGED
|
@@ -10,11 +10,17 @@ import './index.css';
|
|
|
10
10
|
export { default as App } from './app.js';
|
|
11
11
|
export type {
|
|
12
12
|
ShellUIConfig,
|
|
13
|
+
ThemeAsset,
|
|
13
14
|
NavigationItem,
|
|
14
15
|
NavigationGroup,
|
|
15
16
|
LocalizedString,
|
|
16
17
|
ThemeDefinition,
|
|
17
18
|
ThemeColors,
|
|
19
|
+
ThemeColorsMode,
|
|
20
|
+
ThemeFonts,
|
|
21
|
+
ThemeInput,
|
|
22
|
+
ThemeRef,
|
|
23
|
+
ThemesConfig,
|
|
18
24
|
DrawerPosition,
|
|
19
25
|
LayoutType,
|
|
20
26
|
BackendType,
|
|
@@ -26,6 +32,71 @@ export type {
|
|
|
26
32
|
CookieConsentConfig,
|
|
27
33
|
LegalDocumentsConfig,
|
|
28
34
|
} from './features/config/types.js';
|
|
35
|
+
export {
|
|
36
|
+
defaultTheme,
|
|
37
|
+
themes,
|
|
38
|
+
themeNames,
|
|
39
|
+
recommendedThemeNames,
|
|
40
|
+
curatedThemes,
|
|
41
|
+
shelluiTheme,
|
|
42
|
+
claudeTheme,
|
|
43
|
+
lightGreenTheme,
|
|
44
|
+
zenInspiredTheme,
|
|
45
|
+
astroVistaTheme,
|
|
46
|
+
shadcnTheme,
|
|
47
|
+
amberMinimalTheme,
|
|
48
|
+
amethystHazeTheme,
|
|
49
|
+
boldTechTheme,
|
|
50
|
+
bubblegumTheme,
|
|
51
|
+
caffeineTheme,
|
|
52
|
+
candylandTheme,
|
|
53
|
+
catppuccinTheme,
|
|
54
|
+
claymorphismTheme,
|
|
55
|
+
cleanSlateTheme,
|
|
56
|
+
cosmicNightTheme,
|
|
57
|
+
cyberpunkTheme,
|
|
58
|
+
darkmatterTheme,
|
|
59
|
+
doom64Theme,
|
|
60
|
+
elegantLuxuryTheme,
|
|
61
|
+
graphiteTheme,
|
|
62
|
+
kodamaGroveTheme,
|
|
63
|
+
midnightBloomTheme,
|
|
64
|
+
mochaMousseTheme,
|
|
65
|
+
modernMinimalTheme,
|
|
66
|
+
monoTheme,
|
|
67
|
+
natureTheme,
|
|
68
|
+
neoBrutalismTheme,
|
|
69
|
+
northernLightsTheme,
|
|
70
|
+
notebookTheme,
|
|
71
|
+
oceanBreezeTheme,
|
|
72
|
+
pastelDreamsTheme,
|
|
73
|
+
perpetuityTheme,
|
|
74
|
+
quantumRoseTheme,
|
|
75
|
+
retroArcadeTheme,
|
|
76
|
+
sageGardenTheme,
|
|
77
|
+
softPopTheme,
|
|
78
|
+
solarDuskTheme,
|
|
79
|
+
starryNightTheme,
|
|
80
|
+
sunsetHorizonTheme,
|
|
81
|
+
supabaseTheme,
|
|
82
|
+
t3ChatTheme,
|
|
83
|
+
tangerineTheme,
|
|
84
|
+
twitterTheme,
|
|
85
|
+
vercelTheme,
|
|
86
|
+
vintagePaperTheme,
|
|
87
|
+
violetBloomTheme,
|
|
88
|
+
THEME_SCHEMA_VERSION,
|
|
89
|
+
normalizeTheme,
|
|
90
|
+
toThemeJson,
|
|
91
|
+
resolveThemeConfig,
|
|
92
|
+
hexToHsl,
|
|
93
|
+
toCssVarValue,
|
|
94
|
+
applyTheme,
|
|
95
|
+
getTheme,
|
|
96
|
+
getAllThemes,
|
|
97
|
+
registerTheme,
|
|
98
|
+
setAvailableThemes,
|
|
99
|
+
} from './features/theme/themes.js';
|
|
29
100
|
export { useConfig } from './features/config/useConfig.js';
|
|
30
101
|
export { useAuth } from './features/auth/hooks/useAuth.js';
|
|
31
102
|
export { AuthProvider } from './features/auth/AuthProvider.js';
|
package/src/lib/z-index.ts
CHANGED
|
@@ -4,8 +4,11 @@
|
|
|
4
4
|
* Use these constants everywhere so stacking stays consistent.
|
|
5
5
|
*/
|
|
6
6
|
export const Z_INDEX = {
|
|
7
|
+
/** Mobile sidebar sheet overlay / content (above main content, below modals) */
|
|
8
|
+
SIDEBAR_SHEET_OVERLAY: 9990,
|
|
9
|
+
SIDEBAR_SHEET_CONTENT: 9991,
|
|
7
10
|
/** Sidebar trigger (above main content, below modals) */
|
|
8
|
-
SIDEBAR_TRIGGER:
|
|
11
|
+
SIDEBAR_TRIGGER: 9992,
|
|
9
12
|
/** Modal overlay and content (settings panel, etc.) */
|
|
10
13
|
MODAL_OVERLAY: 10000,
|
|
11
14
|
MODAL_CONTENT: 10001,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Navigate } from 'react-router';
|
|
1
|
+
import { Navigate, useLocation } from 'react-router';
|
|
2
2
|
import { useConfig } from '../../features/config/useConfig';
|
|
3
3
|
import { flattenNavigationItems } from '../../features/layouts/utils';
|
|
4
4
|
import { HomeView } from './HomeView';
|
|
@@ -9,12 +9,17 @@ import { NavigationItemRoute } from './NavigationItemRoute';
|
|
|
9
9
|
* - If start_url is set in config, redirects to start_url.
|
|
10
10
|
* - Else if a navigation item has path "" or "/", shows that item's content.
|
|
11
11
|
* - Otherwise shows the default HomeView.
|
|
12
|
+
*
|
|
13
|
+
* When a root nav item exists, this is also the parent for deep paths (e.g. /layout)
|
|
14
|
+
* so ContentView stays mounted across / ↔ /layout (same as /home/*).
|
|
12
15
|
*/
|
|
13
16
|
export const IndexRoute = () => {
|
|
14
17
|
const { config } = useConfig();
|
|
18
|
+
const location = useLocation();
|
|
15
19
|
|
|
16
20
|
const startUrl = config?.start_url?.trim();
|
|
17
|
-
|
|
21
|
+
// Only redirect from exact / — deep links under root must keep working
|
|
22
|
+
if (startUrl && (location.pathname === '/' || location.pathname === '')) {
|
|
18
23
|
const to = startUrl.startsWith('/') ? startUrl : `/${startUrl}`;
|
|
19
24
|
return (
|
|
20
25
|
<Navigate
|
|
@@ -33,5 +38,10 @@ export const IndexRoute = () => {
|
|
|
33
38
|
}
|
|
34
39
|
}
|
|
35
40
|
|
|
41
|
+
// No root nav item: only the index path should show HomeView; deep unknowns 404 via sibling routes
|
|
42
|
+
if (location.pathname !== '/' && location.pathname !== '') {
|
|
43
|
+
return <NavigationItemRoute />;
|
|
44
|
+
}
|
|
45
|
+
|
|
36
46
|
return <HomeView />;
|
|
37
47
|
};
|
|
@@ -10,16 +10,7 @@ import { RouteFallback } from './RouteFallback';
|
|
|
10
10
|
export const NavigationItemRoute = () => {
|
|
11
11
|
const location = useLocation();
|
|
12
12
|
const { isAuthenticated, isLoading } = useAuth();
|
|
13
|
-
const { url, currentItem
|
|
14
|
-
|
|
15
|
-
if (isRootFallback) {
|
|
16
|
-
return (
|
|
17
|
-
<Navigate
|
|
18
|
-
to="/"
|
|
19
|
-
replace
|
|
20
|
-
/>
|
|
21
|
-
);
|
|
22
|
-
}
|
|
13
|
+
const { url, currentItem } = useNavigationItems();
|
|
23
14
|
|
|
24
15
|
if (!currentItem) {
|
|
25
16
|
return <NotFoundView />;
|
|
@@ -4,6 +4,7 @@ import { useAuth } from '../../features/auth/hooks/useAuth';
|
|
|
4
4
|
import {
|
|
5
5
|
filterNavigationForAuthState,
|
|
6
6
|
flattenNavigationItems,
|
|
7
|
+
findMatchingNavigationItem,
|
|
7
8
|
getBaseUrlWithoutHash,
|
|
8
9
|
getHashPathFromUrl,
|
|
9
10
|
getNavPathPrefix,
|
|
@@ -27,22 +28,15 @@ export function useNavigationItems() {
|
|
|
27
28
|
return flattenNavigationItems(authAndDevFilteredNavigation);
|
|
28
29
|
}, [config?.navigation, isAuthenticated, settings.developerFeatures.enabled]);
|
|
29
30
|
|
|
30
|
-
const navigationItem = useMemo(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
});
|
|
35
|
-
}, [navigationItems, location.pathname]);
|
|
31
|
+
const navigationItem = useMemo(
|
|
32
|
+
() => findMatchingNavigationItem(navigationItems, location.pathname),
|
|
33
|
+
[navigationItems, location.pathname],
|
|
34
|
+
);
|
|
36
35
|
|
|
37
|
-
// When no nav matches (e.g. /layout on refresh): use root item (path '' or '/') with pathname as hash subpath to avoid 404
|
|
38
36
|
const rootItem = useMemo(
|
|
39
37
|
() => navigationItems.find((item) => item.path === '' || item.path === '/'),
|
|
40
38
|
[navigationItems],
|
|
41
39
|
);
|
|
42
|
-
const isRootFallback = useMemo(
|
|
43
|
-
() => !navigationItem && Boolean(rootItem) && location.pathname !== '/',
|
|
44
|
-
[navigationItem, rootItem, location.pathname],
|
|
45
|
-
);
|
|
46
40
|
|
|
47
41
|
/**
|
|
48
42
|
* Constructs the final URL for the iframe based on the navigation item and the pathname.
|
|
@@ -51,49 +45,40 @@ export function useNavigationItems() {
|
|
|
51
45
|
* If the navigation item is not found, it returns an empty string.
|
|
52
46
|
*/
|
|
53
47
|
const url = useMemo(() => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const useRootFallback = isRootFallback;
|
|
57
|
-
const actualNavItem = navigationItem ?? (useRootFallback ? rootItem : null);
|
|
58
|
-
|
|
59
|
-
if (!actualNavItem) {
|
|
48
|
+
if (!navigationItem) {
|
|
60
49
|
return '';
|
|
61
50
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
: ''
|
|
51
|
+
|
|
52
|
+
const pathPrefix = getNavPathPrefix(navigationItem);
|
|
53
|
+
const subPath =
|
|
54
|
+
location.pathname.length > pathPrefix.length
|
|
55
|
+
? location.pathname.slice(pathPrefix.length).replace(/^\//, '')
|
|
68
56
|
: '';
|
|
69
57
|
|
|
70
|
-
const subPath = actualSubPath;
|
|
71
58
|
// Construct the final URL for the iframe (non-hash: base + path; hash app: preserve nav url hash path + subPath)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
const navHashPath = getHashPathFromUrl(actualNavItem.url).replace(/^\/+|\/+$/g, '');
|
|
59
|
+
if (isHashRouterNavItem(navigationItem)) {
|
|
60
|
+
const base = getBaseUrlWithoutHash(navigationItem.url).replace(/\/$/, '');
|
|
61
|
+
const navHashPath = getHashPathFromUrl(navigationItem.url).replace(/^\/+|\/+$/g, '');
|
|
76
62
|
const segments = [navHashPath, subPath].filter(Boolean);
|
|
77
63
|
const fullHashPath = `/${segments.join('/')}`;
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
64
|
+
return `${base}#${fullHashPath}`;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let finalUrl = navigationItem.url;
|
|
68
|
+
if (subPath) {
|
|
69
|
+
const baseUrl = navigationItem.url.endsWith('/')
|
|
70
|
+
? navigationItem.url
|
|
71
|
+
: `${navigationItem.url}/`;
|
|
72
|
+
finalUrl = `${baseUrl}${subPath}`;
|
|
87
73
|
}
|
|
88
74
|
return finalUrl;
|
|
89
|
-
}, [navigationItem,
|
|
75
|
+
}, [navigationItem, location.pathname]);
|
|
90
76
|
|
|
91
77
|
return {
|
|
92
|
-
url
|
|
93
|
-
rootItem
|
|
94
|
-
currentItem: navigationItem
|
|
95
|
-
navigationItem
|
|
96
|
-
navigationItems
|
|
97
|
-
isRootFallback,
|
|
78
|
+
url,
|
|
79
|
+
rootItem,
|
|
80
|
+
currentItem: navigationItem,
|
|
81
|
+
navigationItem,
|
|
82
|
+
navigationItems,
|
|
98
83
|
};
|
|
99
84
|
}
|
package/src/routes/routes.tsx
CHANGED
|
@@ -17,6 +17,11 @@ const CookiePreferencesView = lazy(() =>
|
|
|
17
17
|
default: m.CookiePreferencesView,
|
|
18
18
|
})),
|
|
19
19
|
);
|
|
20
|
+
const OverlayDynamicDemoView = lazy(() =>
|
|
21
|
+
import('../features/overlays/OverlayDynamicDemoView').then((m) => ({
|
|
22
|
+
default: m.OverlayDynamicDemoView,
|
|
23
|
+
})),
|
|
24
|
+
);
|
|
20
25
|
const LoginView = lazy(() =>
|
|
21
26
|
import('../features/auth/components/LoginView').then((m) => ({ default: m.LoginView })),
|
|
22
27
|
);
|
|
@@ -68,6 +73,15 @@ export const createRoutes = (config: ShellUIConfig): RouteObject[] => {
|
|
|
68
73
|
</Suspense>
|
|
69
74
|
),
|
|
70
75
|
},
|
|
76
|
+
{
|
|
77
|
+
// Compact overlay demo (develop → dynamicSizing)
|
|
78
|
+
path: urls.overlayDemo.replace(/^\//, ''),
|
|
79
|
+
element: (
|
|
80
|
+
<Suspense fallback={<RouteFallback />}>
|
|
81
|
+
<OverlayDynamicDemoView />
|
|
82
|
+
</Suspense>
|
|
83
|
+
),
|
|
84
|
+
},
|
|
71
85
|
{
|
|
72
86
|
// Login route
|
|
73
87
|
path: urls.login.replace(/^\//, ''),
|
|
@@ -151,43 +165,60 @@ export const createRoutes = (config: ShellUIConfig): RouteObject[] => {
|
|
|
151
165
|
navigation={config.navigation || []}
|
|
152
166
|
/>
|
|
153
167
|
),
|
|
154
|
-
children: [
|
|
155
|
-
{
|
|
156
|
-
path: '/',
|
|
157
|
-
element: (
|
|
158
|
-
<Suspense fallback={<RouteFallback />}>
|
|
159
|
-
<IndexRoute />
|
|
160
|
-
</Suspense>
|
|
161
|
-
),
|
|
162
|
-
},
|
|
163
|
-
],
|
|
168
|
+
children: [],
|
|
164
169
|
};
|
|
165
170
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
path: `/${item.path}/*`,
|
|
173
|
-
element: (
|
|
174
|
-
<Suspense fallback={<RouteFallback />}>
|
|
175
|
-
<NavigationItemRoute />
|
|
176
|
-
</Suspense>
|
|
177
|
-
),
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
// Catch-all: no nav match (e.g. /layout) → NavigationItemRoute can use root item with pathname as hash subpath to avoid 404
|
|
171
|
+
const navigationItems = flattenNavigationItems(config.navigation || []);
|
|
172
|
+
const hasRootNavItem = navigationItems.some((item) => item.path === '' || item.path === '/');
|
|
173
|
+
|
|
174
|
+
// Non-root nav items: /home/*, /docs/*, … — one route match keeps ContentView mounted
|
|
175
|
+
navigationItems.forEach((item) => {
|
|
176
|
+
if (item.path === '' || item.path === '/') return;
|
|
181
177
|
(layoutRoute.children as RouteObject[]).push({
|
|
182
|
-
path:
|
|
178
|
+
path: `/${item.path}/*`,
|
|
183
179
|
element: (
|
|
184
180
|
<Suspense fallback={<RouteFallback />}>
|
|
185
181
|
<NavigationItemRoute />
|
|
186
182
|
</Suspense>
|
|
187
183
|
),
|
|
188
184
|
});
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
// Root app (/ and /:deep): pathless parent + index/* children so ContentView does not
|
|
188
|
+
// remount when moving between / and /layout (that remount was wiping shell history).
|
|
189
|
+
// Without a root nav item, index still uses IndexRoute (HomeView / start_url).
|
|
190
|
+
if (hasRootNavItem) {
|
|
191
|
+
(layoutRoute.children as RouteObject[]).push({
|
|
192
|
+
element: (
|
|
193
|
+
<Suspense fallback={<RouteFallback />}>
|
|
194
|
+
<IndexRoute />
|
|
195
|
+
</Suspense>
|
|
196
|
+
),
|
|
197
|
+
children: [{ index: true }, { path: '*' }],
|
|
198
|
+
});
|
|
199
|
+
} else {
|
|
200
|
+
(layoutRoute.children as RouteObject[]).push({
|
|
201
|
+
index: true,
|
|
202
|
+
element: (
|
|
203
|
+
<Suspense fallback={<RouteFallback />}>
|
|
204
|
+
<IndexRoute />
|
|
205
|
+
</Suspense>
|
|
206
|
+
),
|
|
207
|
+
});
|
|
208
|
+
if (navigationItems.length > 0) {
|
|
209
|
+
(layoutRoute.children as RouteObject[]).push({
|
|
210
|
+
path: '*',
|
|
211
|
+
element: (
|
|
212
|
+
<Suspense fallback={<RouteFallback />}>
|
|
213
|
+
<NavigationItemRoute />
|
|
214
|
+
</Suspense>
|
|
215
|
+
),
|
|
216
|
+
});
|
|
217
|
+
}
|
|
189
218
|
}
|
|
190
|
-
|
|
219
|
+
|
|
220
|
+
// Layout must be before the top-level catch-all (*) so paths like /layout are handled
|
|
221
|
+
// by layout → root IndexRoute, not the global NotFoundView
|
|
191
222
|
(routes[0].children as RouteObject[]).unshift(layoutRoute);
|
|
192
223
|
|
|
193
224
|
return routes;
|
package/tailwind.config.js
CHANGED
|
@@ -10,48 +10,48 @@ module.exports = {
|
|
|
10
10
|
sm: 'calc(var(--radius) - 4px)',
|
|
11
11
|
},
|
|
12
12
|
colors: {
|
|
13
|
-
border: '
|
|
14
|
-
input: '
|
|
15
|
-
ring: '
|
|
16
|
-
background: '
|
|
17
|
-
foreground: '
|
|
13
|
+
border: 'var(--border)',
|
|
14
|
+
input: 'var(--input)',
|
|
15
|
+
ring: 'var(--ring)',
|
|
16
|
+
background: 'var(--background)',
|
|
17
|
+
foreground: 'var(--foreground)',
|
|
18
18
|
primary: {
|
|
19
|
-
DEFAULT: '
|
|
20
|
-
foreground: '
|
|
19
|
+
DEFAULT: 'var(--primary)',
|
|
20
|
+
foreground: 'var(--primary-foreground)',
|
|
21
21
|
},
|
|
22
22
|
secondary: {
|
|
23
|
-
DEFAULT: '
|
|
24
|
-
foreground: '
|
|
23
|
+
DEFAULT: 'var(--secondary)',
|
|
24
|
+
foreground: 'var(--secondary-foreground)',
|
|
25
25
|
},
|
|
26
26
|
destructive: {
|
|
27
|
-
DEFAULT: '
|
|
28
|
-
foreground: '
|
|
27
|
+
DEFAULT: 'var(--destructive)',
|
|
28
|
+
foreground: 'var(--destructive-foreground)',
|
|
29
29
|
},
|
|
30
30
|
muted: {
|
|
31
|
-
DEFAULT: '
|
|
32
|
-
foreground: '
|
|
31
|
+
DEFAULT: 'var(--muted)',
|
|
32
|
+
foreground: 'var(--muted-foreground)',
|
|
33
33
|
},
|
|
34
34
|
accent: {
|
|
35
|
-
DEFAULT: '
|
|
36
|
-
foreground: '
|
|
35
|
+
DEFAULT: 'var(--accent)',
|
|
36
|
+
foreground: 'var(--accent-foreground)',
|
|
37
37
|
},
|
|
38
38
|
popover: {
|
|
39
|
-
DEFAULT: '
|
|
40
|
-
foreground: '
|
|
39
|
+
DEFAULT: 'var(--popover)',
|
|
40
|
+
foreground: 'var(--popover-foreground)',
|
|
41
41
|
},
|
|
42
42
|
card: {
|
|
43
|
-
DEFAULT: '
|
|
44
|
-
foreground: '
|
|
43
|
+
DEFAULT: 'var(--card)',
|
|
44
|
+
foreground: 'var(--card-foreground)',
|
|
45
45
|
},
|
|
46
46
|
sidebar: {
|
|
47
|
-
DEFAULT: '
|
|
48
|
-
foreground: '
|
|
49
|
-
primary: '
|
|
50
|
-
'primary-foreground': '
|
|
51
|
-
accent: '
|
|
52
|
-
'accent-foreground': '
|
|
53
|
-
border: '
|
|
54
|
-
ring: '
|
|
47
|
+
DEFAULT: 'var(--sidebar-background)',
|
|
48
|
+
foreground: 'var(--sidebar-foreground)',
|
|
49
|
+
primary: 'var(--sidebar-primary)',
|
|
50
|
+
'primary-foreground': 'var(--sidebar-primary-foreground)',
|
|
51
|
+
accent: 'var(--sidebar-accent)',
|
|
52
|
+
'accent-foreground': 'var(--sidebar-accent-foreground)',
|
|
53
|
+
border: 'var(--sidebar-border)',
|
|
54
|
+
ring: 'var(--sidebar-ring)',
|
|
55
55
|
},
|
|
56
56
|
},
|
|
57
57
|
},
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { Link } from 'react-router';
|
|
2
|
-
import { shellui } from '@shellui/sdk';
|
|
3
|
-
import type { NavigationItem } from '../../config/types';
|
|
4
|
-
import { cn } from '../../../lib/utils';
|
|
5
|
-
import { getNavPathPrefix } from '../utils';
|
|
6
|
-
|
|
7
|
-
export function BottomNavItem({
|
|
8
|
-
item,
|
|
9
|
-
label,
|
|
10
|
-
isActive,
|
|
11
|
-
iconSrc,
|
|
12
|
-
applyIconTheme,
|
|
13
|
-
}: {
|
|
14
|
-
item: NavigationItem;
|
|
15
|
-
label: string;
|
|
16
|
-
isActive: boolean;
|
|
17
|
-
iconSrc: string | null;
|
|
18
|
-
applyIconTheme: boolean;
|
|
19
|
-
}) {
|
|
20
|
-
const pathPrefix = getNavPathPrefix(item);
|
|
21
|
-
const content = (
|
|
22
|
-
<span className="flex flex-col items-center justify-center gap-1 w-full min-w-0 max-w-full overflow-hidden">
|
|
23
|
-
{iconSrc ? (
|
|
24
|
-
<img
|
|
25
|
-
src={iconSrc}
|
|
26
|
-
alt=""
|
|
27
|
-
className={cn(
|
|
28
|
-
'size-4 shrink-0 rounded-sm object-cover',
|
|
29
|
-
applyIconTheme && 'opacity-90 dark:opacity-100 dark:invert',
|
|
30
|
-
)}
|
|
31
|
-
/>
|
|
32
|
-
) : (
|
|
33
|
-
<span className="size-4 shrink-0 rounded-sm bg-muted" />
|
|
34
|
-
)}
|
|
35
|
-
<span className="text-[11px] leading-tight truncate w-full min-w-0 text-center block">
|
|
36
|
-
{label}
|
|
37
|
-
</span>
|
|
38
|
-
</span>
|
|
39
|
-
);
|
|
40
|
-
const baseClass = cn(
|
|
41
|
-
'flex flex-col items-center justify-center rounded-md py-1.5 px-2 min-w-0 max-w-full transition-colors cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
|
|
42
|
-
isActive
|
|
43
|
-
? 'bg-accent text-accent-foreground [&_span]:text-accent-foreground'
|
|
44
|
-
: 'text-muted-foreground hover:bg-accent/50 hover:text-accent-foreground [&_span]:inherit',
|
|
45
|
-
);
|
|
46
|
-
if (item.openIn === 'modal') {
|
|
47
|
-
return (
|
|
48
|
-
<button
|
|
49
|
-
type="button"
|
|
50
|
-
onClick={() => shellui.openModal(item.url)}
|
|
51
|
-
className={baseClass}
|
|
52
|
-
>
|
|
53
|
-
{content}
|
|
54
|
-
</button>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
if (item.openIn === 'drawer') {
|
|
58
|
-
return (
|
|
59
|
-
<button
|
|
60
|
-
type="button"
|
|
61
|
-
onClick={() => shellui.openDrawer({ url: item.url, position: item.drawerPosition })}
|
|
62
|
-
className={baseClass}
|
|
63
|
-
>
|
|
64
|
-
{content}
|
|
65
|
-
</button>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
if (item.openIn === 'external') {
|
|
69
|
-
return (
|
|
70
|
-
<a
|
|
71
|
-
href={item.url}
|
|
72
|
-
target="_blank"
|
|
73
|
-
rel="noopener noreferrer"
|
|
74
|
-
className={baseClass}
|
|
75
|
-
>
|
|
76
|
-
{content}
|
|
77
|
-
</a>
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
return (
|
|
81
|
-
<Link
|
|
82
|
-
to={pathPrefix}
|
|
83
|
-
className={baseClass}
|
|
84
|
-
>
|
|
85
|
-
{content}
|
|
86
|
-
</Link>
|
|
87
|
-
);
|
|
88
|
-
}
|