mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-19 01:01:30 +02:00
feat(command-bar): match priority highlight colors to UI
Priority keywords now show their actual UI colors: - Dringend (urgent): red #ef4444 - Wichtig (high): orange #f97316 - Normal (medium): yellow #eab308 - Später (low): green #22c55e 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
d9626a9d8f
commit
aa117c51cd
12 changed files with 551 additions and 92 deletions
|
|
@ -15,6 +15,8 @@ export interface AppRoute {
|
|||
labelKey: string;
|
||||
/** Optional icon name */
|
||||
icon?: string;
|
||||
/** If true, this route cannot be hidden (e.g., Settings, Home) */
|
||||
alwaysVisible?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -199,3 +201,46 @@ export function getAvailableRoutes(appId: string): AppRoute[] {
|
|||
export function getDefaultRoute(appId: string): string {
|
||||
return APP_ROUTES[appId]?.defaultRoute ?? '/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter hidden navigation items from a list of nav items
|
||||
* @param appId The app identifier
|
||||
* @param items Array of nav items with href property
|
||||
* @param hiddenNavItems Hidden items config (appId -> hidden paths)
|
||||
* @returns Filtered array with hidden items removed
|
||||
*/
|
||||
export function filterHiddenNavItems<T extends { href: string }>(
|
||||
appId: string,
|
||||
items: T[],
|
||||
hiddenNavItems: Record<string, string[]> = {}
|
||||
): T[] {
|
||||
const hidden = hiddenNavItems[appId] || [];
|
||||
return items.filter((item) => !hidden.includes(item.href));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get routes that can be hidden for a specific app
|
||||
* (excludes routes marked as alwaysVisible)
|
||||
* @param appId The app identifier
|
||||
* @returns Array of routes that can be hidden
|
||||
*/
|
||||
export function getHideableRoutes(appId: string): AppRoute[] {
|
||||
const config = APP_ROUTES[appId];
|
||||
return config?.availableRoutes.filter((r) => !r.alwaysVisible) || [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a route is hidden for a specific app
|
||||
* @param appId The app identifier
|
||||
* @param path The route path
|
||||
* @param hiddenNavItems Hidden items config
|
||||
* @returns True if the route is hidden
|
||||
*/
|
||||
export function isRouteHidden(
|
||||
appId: string,
|
||||
path: string,
|
||||
hiddenNavItems: Record<string, string[]> = {}
|
||||
): boolean {
|
||||
const hidden = hiddenNavItems[appId] || [];
|
||||
return hidden.includes(path);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,4 +117,12 @@ export {
|
|||
|
||||
// App Routes
|
||||
export type { AppRoute, AppRouteConfig } from './app-routes';
|
||||
export { APP_ROUTES, getStartPage, getAvailableRoutes, getDefaultRoute } from './app-routes';
|
||||
export {
|
||||
APP_ROUTES,
|
||||
getStartPage,
|
||||
getAvailableRoutes,
|
||||
getDefaultRoute,
|
||||
filterHiddenNavItems,
|
||||
getHideableRoutes,
|
||||
isRouteHidden,
|
||||
} from './app-routes';
|
||||
|
|
|
|||
|
|
@ -240,6 +240,8 @@ export interface NavSettings {
|
|||
desktopPosition: NavPosition;
|
||||
/** Whether sidebar is collapsed */
|
||||
sidebarCollapsed: boolean;
|
||||
/** Hidden navigation items per app (appId -> list of hidden paths) */
|
||||
hiddenNavItems?: Record<string, string[]>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -323,7 +325,7 @@ export const DEFAULT_GENERAL_SETTINGS: GeneralSettings = {
|
|||
* Default global settings
|
||||
*/
|
||||
export const DEFAULT_GLOBAL_SETTINGS: GlobalSettings = {
|
||||
nav: { desktopPosition: 'top', sidebarCollapsed: false },
|
||||
nav: { desktopPosition: 'top', sidebarCollapsed: false, hiddenNavItems: {} },
|
||||
theme: { mode: 'system', colorScheme: 'ocean', pinnedThemes: [] },
|
||||
locale: 'de',
|
||||
general: DEFAULT_GENERAL_SETTINGS,
|
||||
|
|
@ -364,6 +366,12 @@ export interface UserSettingsStore {
|
|||
setStartPage: (appId: string, path: string) => Promise<void>;
|
||||
/** Update general settings */
|
||||
updateGeneral: (settings: Partial<GeneralSettings>) => Promise<void>;
|
||||
/** Get hidden nav items for a specific app */
|
||||
getHiddenNavItemsForApp: (appId: string) => string[];
|
||||
/** Toggle visibility of a navigation item */
|
||||
toggleNavItemVisibility: (appId: string, href: string) => Promise<void>;
|
||||
/** Set hidden nav items for an app */
|
||||
setHiddenNavItems: (appId: string, hiddenHrefs: string[]) => Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -314,6 +314,46 @@ export function createUserSettingsStore(config: UserSettingsStoreConfig): UserSe
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hidden nav items for a specific app
|
||||
*/
|
||||
function getHiddenNavItemsForApp(targetAppId: string): string[] {
|
||||
return globalSettings.nav.hiddenNavItems?.[targetAppId] || [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle visibility of a navigation item for an app
|
||||
*/
|
||||
async function toggleNavItemVisibility(targetAppId: string, href: string): Promise<void> {
|
||||
const currentHidden = getHiddenNavItemsForApp(targetAppId);
|
||||
const isHidden = currentHidden.includes(href);
|
||||
|
||||
const newHidden = isHidden ? currentHidden.filter((h) => h !== href) : [...currentHidden, href];
|
||||
|
||||
await setHiddenNavItems(targetAppId, newHidden);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hidden nav items for an app
|
||||
*/
|
||||
async function setHiddenNavItems(targetAppId: string, hiddenHrefs: string[]): Promise<void> {
|
||||
const newHiddenNavItems = {
|
||||
...globalSettings.nav.hiddenNavItems,
|
||||
[targetAppId]: hiddenHrefs,
|
||||
};
|
||||
|
||||
// Remove empty arrays
|
||||
if (hiddenHrefs.length === 0) {
|
||||
delete newHiddenNavItems[targetAppId];
|
||||
}
|
||||
|
||||
await updateGlobal({
|
||||
nav: {
|
||||
hiddenNavItems: newHiddenNavItems,
|
||||
},
|
||||
} as Partial<GlobalSettings>);
|
||||
}
|
||||
|
||||
return {
|
||||
get nav() {
|
||||
return nav;
|
||||
|
|
@ -349,5 +389,8 @@ export function createUserSettingsStore(config: UserSettingsStoreConfig): UserSe
|
|||
removeAppOverride,
|
||||
setStartPage,
|
||||
updateGeneral,
|
||||
getHiddenNavItemsForApp,
|
||||
toggleNavItemVisibility,
|
||||
setHiddenNavItems,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue