fix: improve mobile header and board menus
This commit is contained in:
1 parent
1b2f1bd720
commit
63e1bc7f6c
10 files changed
+322
-130
No files matched your search
@@ -13,7 +13,7 @@ import { ModalProvider } from "@homarr/modals";
|
|||||||
|
|
||||||
import { MainHeader } from "~/components/layout/header";
|
import { MainHeader } from "~/components/layout/header";
|
||||||
import { appShellLogoHeight } from "~/components/layout/constants";
|
import { appShellLogoHeight } from "~/components/layout/constants";
|
||||||
import { BoardLogo, BoardLogoWithTitle } from "~/components/layout/logo/board-logo";
|
import { BoardLogo, BoardLogoWithName, BoardLogoWithTitle } from "~/components/layout/logo/board-logo";
|
||||||
import { ClientShell } from "~/components/layout/shell";
|
import { ClientShell } from "~/components/layout/shell";
|
||||||
import { BoardTourGate } from "~/components/onboarding/board-tour-gate";
|
import { BoardTourGate } from "~/components/onboarding/board-tour-gate";
|
||||||
import { env } from "~/env";
|
import { env } from "~/env";
|
||||||
@@ -111,7 +111,8 @@ export const createBoardLayout = <TParams extends Params>({
|
|||||||
<ClientShell hasNavigation={false}>
|
<ClientShell hasNavigation={false}>
|
||||||
<MainHeader
|
<MainHeader
|
||||||
logo={<BoardLogo size={appShellLogoHeight} />}
|
logo={<BoardLogo size={appShellLogoHeight} />}
|
||||||
logoWithTitle={<BoardLogoWithTitle size="md" hideTitleOnMobile />}
|
logoWithTitle={<BoardLogoWithTitle size="md" />}
|
||||||
|
mobileLogoWithTitle={<BoardLogoWithName size="md" />}
|
||||||
actions={headerActions}
|
actions={headerActions}
|
||||||
boardEditAction={headerBoardEditAction}
|
boardEditAction={headerBoardEditAction}
|
||||||
boardSettingsAction={headerBoardSettingsAction}
|
boardSettingsAction={headerBoardSettingsAction}
|
||||||
|
|||||||
@@ -15,6 +15,10 @@
|
|||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.results {
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.searchInput {
|
.searchInput {
|
||||||
border-color: color-mix(in srgb, var(--mantine-color-default-border) 72%, transparent);
|
border-color: color-mix(in srgb, var(--mantine-color-default-border) 72%, transparent);
|
||||||
background: color-mix(in srgb, var(--mantine-color-body) 54%, transparent);
|
background: color-mix(in srgb, var(--mantine-color-body) 54%, transparent);
|
||||||
@@ -44,3 +48,19 @@
|
|||||||
border-color: var(--mantine-primary-color-filled);
|
border-color: var(--mantine-primary-color-filled);
|
||||||
box-shadow: var(--mantine-shadow-md);
|
box-shadow: var(--mantine-shadow-md);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: $mantine-breakpoint-sm) {
|
||||||
|
.modalContent {
|
||||||
|
height: calc(100dvh - var(--modal-y-offset) * 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modalBody,
|
||||||
|
.content {
|
||||||
|
min-height: 0;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.results {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -228,7 +228,13 @@ export const BoardSwitcher = ({ children }: BoardSwitcherProps) => {
|
|||||||
radius="xl"
|
radius="xl"
|
||||||
classNames={{ input: classes.searchInput }}
|
classNames={{ input: classes.searchInput }}
|
||||||
/>
|
/>
|
||||||
<ScrollArea.Autosize mah="min(80vh, 42rem)" type="never">
|
<ScrollArea.Autosize
|
||||||
|
mah="min(80vh, 42rem)"
|
||||||
|
type="never"
|
||||||
|
scrollbars="y"
|
||||||
|
overscrollBehavior="contain"
|
||||||
|
className={classes.results}
|
||||||
|
>
|
||||||
{results}
|
{results}
|
||||||
</ScrollArea.Autosize>
|
</ScrollArea.Autosize>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
.mobileDrawerContent {
|
||||||
|
height: min(80dvh, rem(640px));
|
||||||
|
max-height: 80dvh;
|
||||||
|
overscroll-behavior: contain;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobileDrawerBody {
|
||||||
|
padding-bottom: max(var(--mantine-spacing-md), env(safe-area-inset-bottom));
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobileActionList {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
import type { MutableRefObject, ReactNode, RefObject } from "react";
|
import type { MutableRefObject, ReactNode, RefObject } from "react";
|
||||||
import { useCallback, useMemo, useState } from "react";
|
import { useCallback, useMemo, useState } from "react";
|
||||||
import { Group, Loader, Menu, Text, Tooltip } from "@mantine/core";
|
import { Drawer, Group, Loader, Menu, Text, Tooltip } from "@mantine/core";
|
||||||
|
import { useMediaQuery } from "@mantine/hooks";
|
||||||
import { IconAlertTriangle, IconCircleCheck, IconMaximize, IconRefresh, IconSettings } from "@tabler/icons-react";
|
import { IconAlertTriangle, IconCircleCheck, IconMaximize, IconRefresh, IconSettings } from "@tabler/icons-react";
|
||||||
import type { QueryClient, QueryKey } from "@tanstack/react-query";
|
import type { QueryClient, QueryKey } from "@tanstack/react-query";
|
||||||
import { useIsFetching, useQueryClient } from "@tanstack/react-query";
|
import { useIsFetching, useQueryClient } from "@tanstack/react-query";
|
||||||
@@ -20,7 +21,7 @@ import { getWidgetName } from "@homarr/definitions";
|
|||||||
import { translateIfNecessary } from "@homarr/translation";
|
import { translateIfNecessary } from "@homarr/translation";
|
||||||
import type { TranslationFunction } from "@homarr/translation";
|
import type { TranslationFunction } from "@homarr/translation";
|
||||||
import { useI18n } from "@homarr/translation/client";
|
import { useI18n } from "@homarr/translation/client";
|
||||||
import type { WidgetDefinition, WidgetRuntimeRef } from "@homarr/widgets/definition";
|
import type { WidgetContextMenuAction, WidgetDefinition, WidgetRuntimeRef } from "@homarr/widgets/definition";
|
||||||
import { getWidgetQueryKeys, getWidgetRuntimeQueries, supportsAdvancedFocus } from "@homarr/widgets/definition";
|
import { getWidgetQueryKeys, getWidgetRuntimeQueries, supportsAdvancedFocus } from "@homarr/widgets/definition";
|
||||||
import { reduceWidgetOptionsWithDefinition } from "@homarr/widgets/manifest";
|
import { reduceWidgetOptionsWithDefinition } from "@homarr/widgets/manifest";
|
||||||
import { getWidgetOptionTranslationNamespace } from "@homarr/widgets/option-translation";
|
import { getWidgetOptionTranslationNamespace } from "@homarr/widgets/option-translation";
|
||||||
@@ -31,6 +32,9 @@ import { useBoardPermissions } from "../permissions/client";
|
|||||||
import { useItemActions } from "./item-actions";
|
import { useItemActions } from "./item-actions";
|
||||||
import { LazyWidgetEditModal, preloadWidgetEditModal } from "./lazy-widget-edit-modal";
|
import { LazyWidgetEditModal, preloadWidgetEditModal } from "./lazy-widget-edit-modal";
|
||||||
import { matchesWidgetItemQuery } from "./widget-query-scope";
|
import { matchesWidgetItemQuery } from "./widget-query-scope";
|
||||||
|
import classes from "./widget-context-menu.module.css";
|
||||||
|
|
||||||
|
type ToggleOption = [key: string, option: { type: string; skipContextMenu?: boolean }];
|
||||||
|
|
||||||
interface WidgetContextMenuProps {
|
interface WidgetContextMenuProps {
|
||||||
item: SectionItem;
|
item: SectionItem;
|
||||||
@@ -56,8 +60,6 @@ export const WidgetContextMenu = ({
|
|||||||
const { hasChangeAccess } = useBoardPermissions(board);
|
const { hasChangeAccess } = useBoardPermissions(board);
|
||||||
const { updateAndPersistBoard } = usePersistBoard(board);
|
const { updateAndPersistBoard } = usePersistBoard(board);
|
||||||
const t = useI18n();
|
const t = useI18n();
|
||||||
const tMenu = useI18n("item.menu.label");
|
|
||||||
const tCommon = useI18n("common.action");
|
|
||||||
const settings = useSettings();
|
const settings = useSettings();
|
||||||
const { openModal } = useModalAction(LazyWidgetEditModal);
|
const { openModal } = useModalAction(LazyWidgetEditModal);
|
||||||
const { updateItemOptions, updateItemAdvancedOptions, updateItemIntegrations } = useItemActions();
|
const { updateItemOptions, updateItemAdvancedOptions, updateItemIntegrations } = useItemActions();
|
||||||
@@ -72,6 +74,7 @@ export const WidgetContextMenu = ({
|
|||||||
const { open: openAdvancedFocus } = useAdvancedFocus();
|
const { open: openAdvancedFocus } = useAdvancedFocus();
|
||||||
const integrationsWithInteractAccess = useIntegrationsWithInteractAccess();
|
const integrationsWithInteractAccess = useIntegrationsWithInteractAccess();
|
||||||
const [menuOpened, setMenuOpened] = useState(false);
|
const [menuOpened, setMenuOpened] = useState(false);
|
||||||
|
const isMobile = useMediaQuery("(max-width: 48em)");
|
||||||
|
|
||||||
const persistBoard = useCallback(
|
const persistBoard = useCallback(
|
||||||
(updater: (previous: typeof board) => typeof board) => {
|
(updater: (previous: typeof board) => typeof board) => {
|
||||||
@@ -134,11 +137,12 @@ export const WidgetContextMenu = ({
|
|||||||
[item.id, persistBoard],
|
[item.id, persistBoard],
|
||||||
);
|
);
|
||||||
|
|
||||||
type OptionDef = { type: string; skipContextMenu?: boolean };
|
|
||||||
const toggleOptions = useMemo(() => {
|
const toggleOptions = useMemo(() => {
|
||||||
if (!canConfigureWidget) return [];
|
if (!canConfigureWidget) return [];
|
||||||
const rawOptions = definition.createOptions(settings) as unknown as Record<string, OptionDef>;
|
const rawOptions = definition.createOptions(settings) as unknown as Record<string, ToggleOption[1]>;
|
||||||
return Object.entries(rawOptions).filter(([, option]) => option.type === "switch" && !option.skipContextMenu);
|
return Object.entries(rawOptions).filter(
|
||||||
|
([, option]) => option.type === "switch" && !option.skipContextMenu,
|
||||||
|
) as ToggleOption[];
|
||||||
}, [canConfigureWidget, definition, settings]);
|
}, [canConfigureWidget, definition, settings]);
|
||||||
|
|
||||||
const widgetContextActions =
|
const widgetContextActions =
|
||||||
@@ -222,11 +226,37 @@ export const WidgetContextMenu = ({
|
|||||||
[setItemOptions],
|
[setItemOptions],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleOpenAdvancedFocus = useCallback(() => {
|
||||||
|
if (!sourceRef.current) return;
|
||||||
|
openAdvancedFocus(item.id, sourceRef.current, {
|
||||||
|
restoreFocusTarget:
|
||||||
|
sourceRef.current.querySelector<HTMLElement>("[data-advanced-focus-trigger]") ?? sourceRef.current,
|
||||||
|
});
|
||||||
|
}, [item.id, openAdvancedFocus, sourceRef]);
|
||||||
|
|
||||||
if (!session || !settings.enableRightClickOnWidgets || isEditMode || item.kind === "app") {
|
if (!session || !settings.enableRightClickOnWidgets || isEditMode || item.kind === "app") {
|
||||||
return <>{children}</>;
|
return <>{children}</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const visibleWidgetActions = widgetContextActions.filter((action) => !action.hidden);
|
const visibleWidgetActions = widgetContextActions.filter((action) => !action.hidden);
|
||||||
|
const actionContent = (
|
||||||
|
<WidgetContextActions
|
||||||
|
canOpenAdvancedFocus={canOpenAdvancedFocus}
|
||||||
|
onOpenAdvancedFocus={handleOpenAdvancedFocus}
|
||||||
|
toggleOptions={toggleOptions}
|
||||||
|
options={options}
|
||||||
|
onToggle={handleToggle}
|
||||||
|
itemKind={item.kind}
|
||||||
|
visibleWidgetActions={visibleWidgetActions}
|
||||||
|
isWidgetFetching={isWidgetFetching}
|
||||||
|
onRefetch={handleRefetch}
|
||||||
|
queryClient={queryClient}
|
||||||
|
matchesWidgetQuery={matchesWidgetQuery}
|
||||||
|
onEdit={openEditModal}
|
||||||
|
canConfigureWidget={canConfigureWidget}
|
||||||
|
isIntegrationDataPending={hasSupportedIntegrations && isPending}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Menu
|
<Menu
|
||||||
@@ -239,91 +269,137 @@ export const WidgetContextMenu = ({
|
|||||||
onChange={setMenuOpened}
|
onChange={setMenuOpened}
|
||||||
>
|
>
|
||||||
<Menu.ContextMenu>{children}</Menu.ContextMenu>
|
<Menu.ContextMenu>{children}</Menu.ContextMenu>
|
||||||
<Menu.Dropdown>
|
{isMobile ? (
|
||||||
{canOpenAdvancedFocus && (
|
<Drawer
|
||||||
<>
|
opened={menuOpened}
|
||||||
<Menu.Item
|
onClose={() => setMenuOpened(false)}
|
||||||
closeMenuOnClick
|
position="bottom"
|
||||||
leftSection={<IconMaximize size={16} />}
|
size="min(80dvh, 40rem)"
|
||||||
onClick={() => {
|
title={getWidgetName(item.kind, t)}
|
||||||
if (sourceRef.current)
|
classNames={{ content: classes.mobileDrawerContent, body: classes.mobileDrawerBody }}
|
||||||
openAdvancedFocus(item.id, sourceRef.current, {
|
|
||||||
restoreFocusTarget:
|
|
||||||
sourceRef.current.querySelector<HTMLElement>("[data-advanced-focus-trigger]") ??
|
|
||||||
sourceRef.current,
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{t("item.advancedFocus.open")}
|
|
||||||
</Menu.Item>
|
|
||||||
<Menu.Divider />
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{toggleOptions.length > 0 && (
|
|
||||||
<>
|
|
||||||
<Menu.Label>{tMenu("options")}</Menu.Label>
|
|
||||||
{toggleOptions.map(([key]) => (
|
|
||||||
<Menu.CheckboxItem key={key} checked={Boolean(options[key])} onChange={handleToggle(key)}>
|
|
||||||
{t(`${getWidgetOptionTranslationNamespace(item.kind, key)}.label` as never)}
|
|
||||||
</Menu.CheckboxItem>
|
|
||||||
))}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{visibleWidgetActions.length > 0 && (
|
|
||||||
<>
|
|
||||||
{toggleOptions.length > 0 && <Menu.Divider />}
|
|
||||||
<Menu.Label>{tMenu("actions")}</Menu.Label>
|
|
||||||
{visibleWidgetActions.map((action) => {
|
|
||||||
const Icon = action.icon;
|
|
||||||
return (
|
|
||||||
<Menu.Item
|
|
||||||
key={action.key}
|
|
||||||
closeMenuOnClick
|
|
||||||
leftSection={Icon ? <Icon size={16} /> : undefined}
|
|
||||||
onClick={action.onClick}
|
|
||||||
disabled={action.disabled}
|
|
||||||
color={action.color}
|
|
||||||
>
|
|
||||||
{translateIfNecessary(t, action.label)}
|
|
||||||
</Menu.Item>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{(toggleOptions.length > 0 || visibleWidgetActions.length > 0) && <Menu.Divider />}
|
|
||||||
<Menu.Item
|
|
||||||
leftSection={isWidgetFetching ? <Loader size={16} /> : <IconRefresh size={16} />}
|
|
||||||
onClick={handleRefetch}
|
|
||||||
disabled={isWidgetFetching}
|
|
||||||
>
|
>
|
||||||
<Group justify="space-between" wrap="nowrap" gap="sm">
|
<div className={classes.mobileActionList} role="menu" aria-orientation="vertical" data-menu-dropdown>
|
||||||
{tCommon("refresh")}
|
{actionContent}
|
||||||
<WidgetQueryStatus
|
</div>
|
||||||
queryClient={queryClient}
|
</Drawer>
|
||||||
matchesQuery={matchesWidgetQuery}
|
) : (
|
||||||
isFetching={isWidgetFetching}
|
<Menu.Dropdown>{actionContent}</Menu.Dropdown>
|
||||||
t={t}
|
)}
|
||||||
/>
|
|
||||||
</Group>
|
|
||||||
</Menu.Item>
|
|
||||||
<Menu.Item
|
|
||||||
closeMenuOnClick
|
|
||||||
leftSection={<IconSettings size={16} />}
|
|
||||||
onClick={openEditModal}
|
|
||||||
onFocus={preloadWidgetEditModal}
|
|
||||||
onPointerEnter={preloadWidgetEditModal}
|
|
||||||
disabled={!canConfigureWidget || (hasSupportedIntegrations && isPending)}
|
|
||||||
>
|
|
||||||
{tMenu("settings")}
|
|
||||||
</Menu.Item>
|
|
||||||
</Menu.Dropdown>
|
|
||||||
</Menu>
|
</Menu>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
interface WidgetContextActionsProps {
|
||||||
|
canOpenAdvancedFocus: boolean;
|
||||||
|
onOpenAdvancedFocus: () => void;
|
||||||
|
toggleOptions: ToggleOption[];
|
||||||
|
options: Record<string, unknown>;
|
||||||
|
onToggle: (key: string) => (checked: boolean) => void;
|
||||||
|
itemKind: SectionItem["kind"];
|
||||||
|
visibleWidgetActions: WidgetContextMenuAction[];
|
||||||
|
isWidgetFetching: boolean;
|
||||||
|
onRefetch: () => void;
|
||||||
|
queryClient: QueryClient;
|
||||||
|
matchesWidgetQuery: (queryKey: QueryKey) => boolean;
|
||||||
|
onEdit: () => void;
|
||||||
|
canConfigureWidget: boolean;
|
||||||
|
isIntegrationDataPending: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const WidgetContextActions = ({
|
||||||
|
canOpenAdvancedFocus,
|
||||||
|
onOpenAdvancedFocus,
|
||||||
|
toggleOptions,
|
||||||
|
options,
|
||||||
|
onToggle,
|
||||||
|
itemKind,
|
||||||
|
visibleWidgetActions,
|
||||||
|
isWidgetFetching,
|
||||||
|
onRefetch,
|
||||||
|
queryClient,
|
||||||
|
matchesWidgetQuery,
|
||||||
|
onEdit,
|
||||||
|
canConfigureWidget,
|
||||||
|
isIntegrationDataPending,
|
||||||
|
}: WidgetContextActionsProps) => {
|
||||||
|
const t = useI18n();
|
||||||
|
const tMenu = useI18n("item.menu.label");
|
||||||
|
const tCommon = useI18n("common.action");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{canOpenAdvancedFocus && (
|
||||||
|
<>
|
||||||
|
<Menu.Item closeMenuOnClick leftSection={<IconMaximize size={16} />} onClick={onOpenAdvancedFocus}>
|
||||||
|
{t("item.advancedFocus.open")}
|
||||||
|
</Menu.Item>
|
||||||
|
<Menu.Divider />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{toggleOptions.length > 0 && (
|
||||||
|
<>
|
||||||
|
<Menu.Label>{tMenu("options")}</Menu.Label>
|
||||||
|
{toggleOptions.map(([key]) => (
|
||||||
|
<Menu.CheckboxItem key={key} checked={Boolean(options[key])} onChange={onToggle(key)}>
|
||||||
|
{t(`${getWidgetOptionTranslationNamespace(itemKind, key)}.label` as never)}
|
||||||
|
</Menu.CheckboxItem>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{visibleWidgetActions.length > 0 && (
|
||||||
|
<>
|
||||||
|
{toggleOptions.length > 0 && <Menu.Divider />}
|
||||||
|
<Menu.Label>{tMenu("actions")}</Menu.Label>
|
||||||
|
{visibleWidgetActions.map((action) => {
|
||||||
|
const Icon = action.icon;
|
||||||
|
return (
|
||||||
|
<Menu.Item
|
||||||
|
key={action.key}
|
||||||
|
closeMenuOnClick
|
||||||
|
leftSection={Icon ? <Icon size={16} /> : undefined}
|
||||||
|
onClick={action.onClick}
|
||||||
|
disabled={action.disabled}
|
||||||
|
color={action.color}
|
||||||
|
>
|
||||||
|
{translateIfNecessary(t, action.label)}
|
||||||
|
</Menu.Item>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{(toggleOptions.length > 0 || visibleWidgetActions.length > 0) && <Menu.Divider />}
|
||||||
|
<Menu.Item
|
||||||
|
leftSection={isWidgetFetching ? <Loader size={16} /> : <IconRefresh size={16} />}
|
||||||
|
onClick={onRefetch}
|
||||||
|
disabled={isWidgetFetching}
|
||||||
|
>
|
||||||
|
<Group justify="space-between" wrap="nowrap" gap="sm">
|
||||||
|
{tCommon("refresh")}
|
||||||
|
<WidgetQueryStatus
|
||||||
|
queryClient={queryClient}
|
||||||
|
matchesQuery={matchesWidgetQuery}
|
||||||
|
isFetching={isWidgetFetching}
|
||||||
|
t={t}
|
||||||
|
/>
|
||||||
|
</Group>
|
||||||
|
</Menu.Item>
|
||||||
|
<Menu.Item
|
||||||
|
closeMenuOnClick
|
||||||
|
leftSection={<IconSettings size={16} />}
|
||||||
|
onClick={onEdit}
|
||||||
|
onFocus={preloadWidgetEditModal}
|
||||||
|
onPointerEnter={preloadWidgetEditModal}
|
||||||
|
disabled={!canConfigureWidget || isIntegrationDataPending}
|
||||||
|
>
|
||||||
|
{tMenu("settings")}
|
||||||
|
</Menu.Item>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
interface WidgetQueryStatusProps {
|
interface WidgetQueryStatusProps {
|
||||||
queryClient: QueryClient;
|
queryClient: QueryClient;
|
||||||
matchesQuery: (queryKey: QueryKey) => boolean;
|
matchesQuery: (queryKey: QueryKey) => boolean;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { HomarrLogo, HomarrLogoWithTitle } from "./logo/homarr-logo";
|
|||||||
interface Props {
|
interface Props {
|
||||||
logo?: ReactNode;
|
logo?: ReactNode;
|
||||||
logoWithTitle?: ReactNode;
|
logoWithTitle?: ReactNode;
|
||||||
|
mobileLogoWithTitle?: ReactNode;
|
||||||
actions?: ReactNode;
|
actions?: ReactNode;
|
||||||
boardEditAction?: ReactNode;
|
boardEditAction?: ReactNode;
|
||||||
boardSettingsAction?: ReactNode;
|
boardSettingsAction?: ReactNode;
|
||||||
@@ -19,6 +20,7 @@ interface Props {
|
|||||||
export const MainHeader = async ({
|
export const MainHeader = async ({
|
||||||
logo,
|
logo,
|
||||||
logoWithTitle,
|
logoWithTitle,
|
||||||
|
mobileLogoWithTitle,
|
||||||
actions,
|
actions,
|
||||||
boardEditAction,
|
boardEditAction,
|
||||||
boardSettingsAction,
|
boardSettingsAction,
|
||||||
@@ -27,11 +29,13 @@ export const MainHeader = async ({
|
|||||||
const session = await auth();
|
const session = await auth();
|
||||||
const isAdmin = Boolean(session?.user.permissions.includes("admin"));
|
const isAdmin = Boolean(session?.user.permissions.includes("admin"));
|
||||||
const isDockerEnabled = isAdmin && env.ENABLE_DOCKER;
|
const isDockerEnabled = isAdmin && env.ENABLE_DOCKER;
|
||||||
|
const resolvedLogoWithTitle = logoWithTitle ?? <HomarrLogoWithTitle size="md" />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ConfigurableHeader
|
<ConfigurableHeader
|
||||||
logo={logo ?? <HomarrLogo size={appShellLogoHeight} />}
|
logo={logo ?? <HomarrLogo size={appShellLogoHeight} />}
|
||||||
logoWithTitle={logoWithTitle ?? <HomarrLogoWithTitle size="md" />}
|
logoWithTitle={resolvedLogoWithTitle}
|
||||||
|
mobileLogoWithTitle={mobileLogoWithTitle ?? resolvedLogoWithTitle}
|
||||||
actions={actions}
|
actions={actions}
|
||||||
boardEditAction={boardEditAction}
|
boardEditAction={boardEditAction}
|
||||||
boardSettingsAction={boardSettingsAction}
|
boardSettingsAction={boardSettingsAction}
|
||||||
|
|||||||
@@ -2,6 +2,15 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.header[data-desktop-visible="false"] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktopContent {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
@@ -64,6 +73,41 @@
|
|||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mobileContent {
|
||||||
|
display: none;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: var(--mantine-spacing-xs);
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
padding-inline: var(--mantine-spacing-xs);
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobileIdentity,
|
||||||
|
.mobileActions {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobileIdentity {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobileIdentity > :last-child {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobileIdentity h2 {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobileActions {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
.floatingControls {
|
.floatingControls {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
z-index: var(--homarr-z-index-board-header);
|
z-index: var(--homarr-z-index-board-header);
|
||||||
@@ -111,18 +155,21 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: $mantine-breakpoint-sm) {
|
@media (max-width: $mantine-breakpoint-sm) {
|
||||||
.content {
|
.header[data-desktop-visible="false"] {
|
||||||
gap: var(--mantine-spacing-xs);
|
display: block;
|
||||||
padding-inline: var(--mantine-spacing-xs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.zone {
|
.desktopContent {
|
||||||
gap: var(--mantine-spacing-xs);
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search {
|
.mobileContent {
|
||||||
width: auto;
|
display: flex;
|
||||||
flex: 0 0 auto;
|
}
|
||||||
|
|
||||||
|
.floatingControls,
|
||||||
|
.floatingControlsCorner {
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,15 +2,7 @@
|
|||||||
|
|
||||||
import type { ReactNode } from "react";
|
import type { ReactNode } from "react";
|
||||||
import { useEffect, useMemo, useRef, useState } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import {
|
import { AppShellHeader, Avatar, Group, Indicator, Loader, Tooltip, useMantineColorScheme } from "@mantine/core";
|
||||||
AppShellHeader,
|
|
||||||
Avatar,
|
|
||||||
Group,
|
|
||||||
Indicator,
|
|
||||||
Loader,
|
|
||||||
Tooltip,
|
|
||||||
useMantineColorScheme,
|
|
||||||
} from "@mantine/core";
|
|
||||||
import {
|
import {
|
||||||
IconBrandDocker,
|
IconBrandDocker,
|
||||||
IconHome,
|
IconHome,
|
||||||
@@ -46,6 +38,7 @@ import classes from "./configurable-header.module.css";
|
|||||||
interface ConfigurableHeaderProps {
|
interface ConfigurableHeaderProps {
|
||||||
logo: ReactNode;
|
logo: ReactNode;
|
||||||
logoWithTitle: ReactNode;
|
logoWithTitle: ReactNode;
|
||||||
|
mobileLogoWithTitle: ReactNode;
|
||||||
actions?: ReactNode;
|
actions?: ReactNode;
|
||||||
boardEditAction?: ReactNode;
|
boardEditAction?: ReactNode;
|
||||||
boardSettingsAction?: ReactNode;
|
boardSettingsAction?: ReactNode;
|
||||||
@@ -64,6 +57,7 @@ const floatingControlsDismissDelayMs = 900;
|
|||||||
export const ConfigurableHeader = ({
|
export const ConfigurableHeader = ({
|
||||||
logo,
|
logo,
|
||||||
logoWithTitle,
|
logoWithTitle,
|
||||||
|
mobileLogoWithTitle,
|
||||||
actions,
|
actions,
|
||||||
boardEditAction,
|
boardEditAction,
|
||||||
boardSettingsAction,
|
boardSettingsAction,
|
||||||
@@ -116,14 +110,15 @@ export const ConfigurableHeader = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{headerPreferences.visible ? (
|
<AppShellHeader
|
||||||
<AppShellHeader
|
maw="100vw"
|
||||||
maw="100vw"
|
zIndex="var(--homarr-z-index-board-header)"
|
||||||
zIndex="var(--homarr-z-index-board-header)"
|
className={classes.header}
|
||||||
className={classes.header}
|
data-desktop-visible={headerPreferences.visible}
|
||||||
data-advanced-focus-background
|
data-advanced-focus-background
|
||||||
data-app-shell-header
|
data-app-shell-header
|
||||||
>
|
>
|
||||||
|
<div className={classes.desktopContent}>
|
||||||
<div className={classes.content}>
|
<div className={classes.content}>
|
||||||
<div className={classes.zone} data-zone="left">
|
<div className={classes.zone} data-zone="left">
|
||||||
{hasNavigation ? <ClientBurger /> : null}
|
{hasNavigation ? <ClientBurger /> : null}
|
||||||
@@ -137,8 +132,36 @@ export const ConfigurableHeader = ({
|
|||||||
{actions ? <Group className={classes.contextActions}>{actions}</Group> : null}
|
{actions ? <Group className={classes.contextActions}>{actions}</Group> : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</AppShellHeader>
|
</div>
|
||||||
) : (
|
<div className={classes.mobileContent}>
|
||||||
|
<Group className={classes.mobileIdentity} gap="xs" wrap="nowrap">
|
||||||
|
{hasNavigation ? <ClientBurger /> : null}
|
||||||
|
<HeaderLogo
|
||||||
|
display="logoAndText"
|
||||||
|
logo={logo}
|
||||||
|
logoWithTitle={mobileLogoWithTitle}
|
||||||
|
label={t("items.logo")}
|
||||||
|
/>
|
||||||
|
</Group>
|
||||||
|
<Group className={classes.mobileActions} gap="xs" wrap="nowrap">
|
||||||
|
{actions}
|
||||||
|
{boardEditAction}
|
||||||
|
{boardSettingsAction}
|
||||||
|
<TourTarget id="board-search">
|
||||||
|
<MobileSearchButton alwaysVisible />
|
||||||
|
</TourTarget>
|
||||||
|
<TourTarget id="board-user-menu">
|
||||||
|
<UserButtonClient
|
||||||
|
avatar={avatar}
|
||||||
|
isAdmin={isAdmin}
|
||||||
|
isDockerEnabled={isDockerEnabled}
|
||||||
|
boardSwitcher={boardSwitcher}
|
||||||
|
/>
|
||||||
|
</TourTarget>
|
||||||
|
</Group>
|
||||||
|
</div>
|
||||||
|
</AppShellHeader>
|
||||||
|
{!headerPreferences.visible ? (
|
||||||
<FloatingHeaderControls>
|
<FloatingHeaderControls>
|
||||||
{hasNavigation ? <ClientBurger /> : null}
|
{hasNavigation ? <ClientBurger /> : null}
|
||||||
<UserButtonClient
|
<UserButtonClient
|
||||||
@@ -148,7 +171,7 @@ export const ConfigurableHeader = ({
|
|||||||
boardSwitcher={boardSwitcher}
|
boardSwitcher={boardSwitcher}
|
||||||
/>
|
/>
|
||||||
</FloatingHeaderControls>
|
</FloatingHeaderControls>
|
||||||
)}
|
) : null}
|
||||||
<LazySpotlight />
|
<LazySpotlight />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
@@ -291,7 +314,7 @@ const HeaderItem = ({
|
|||||||
<Tooltip label={board.name}>
|
<Tooltip label={board.name}>
|
||||||
<HeaderButton href={`/boards/${encodeURIComponent(board.name)}`} aria-label={board.name}>
|
<HeaderButton href={`/boards/${encodeURIComponent(board.name)}`} aria-label={board.name}>
|
||||||
<Avatar src={board.logoImageUrl} size={22} radius="sm">
|
<Avatar src={board.logoImageUrl} size={22} radius="sm">
|
||||||
<IconLayoutDashboard size={17} stroke={1.5} />
|
{getBoardInitial(board.name)}
|
||||||
</Avatar>
|
</Avatar>
|
||||||
</HeaderButton>
|
</HeaderButton>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
@@ -299,14 +322,7 @@ const HeaderItem = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (item.id === "logo") {
|
if (item.id === "logo") {
|
||||||
return (
|
return <HeaderLogo display={logoDisplay} logo={logo} logoWithTitle={logoWithTitle} label={label("logo")} />;
|
||||||
<HeaderLogo
|
|
||||||
display={logoDisplay}
|
|
||||||
logo={logo}
|
|
||||||
logoWithTitle={logoWithTitle}
|
|
||||||
label={label("logo")}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.id === "boardEdit") return boardEditAction;
|
if (item.id === "boardEdit") return boardEditAction;
|
||||||
@@ -416,3 +432,5 @@ const HeaderItem = ({
|
|||||||
</TourTarget>
|
</TourTarget>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getBoardInitial = (name: string) => Array.from(name.trim())[0]?.toLocaleUpperCase() ?? "?";
|
||||||
@@ -44,3 +44,9 @@ export const BoardLogoWithTitle = ({ size, hideTitleOnMobile }: CommonLogoWithTi
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const BoardLogoWithName = ({ size }: Pick<CommonLogoWithTitleProps, "size">) => {
|
||||||
|
const board = useRequiredBoard();
|
||||||
|
const imageOptions = useImageOptions();
|
||||||
|
return <LogoWithTitle size={size} title={board.name} image={imageOptions} />;
|
||||||
|
};
|
||||||
@@ -22,12 +22,12 @@ export const ClientShell = ({
|
|||||||
const collapsed = useAtomValue(navigationCollapsedAtom);
|
const collapsed = useAtomValue(navigationCollapsedAtom);
|
||||||
const backgroundProps = useOptionalBackgroundProps();
|
const backgroundProps = useOptionalBackgroundProps();
|
||||||
const { headerPreferences } = useSettings();
|
const { headerPreferences } = useSettings();
|
||||||
const isHeaderVisible = hasHeader && headerPreferences.visible;
|
const headerHeight = headerPreferences.visible ? appShellHeaderHeight : { base: appShellHeaderHeight, sm: 0 };
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppShell
|
<AppShell
|
||||||
{...backgroundProps}
|
{...backgroundProps}
|
||||||
header={isHeaderVisible ? { height: appShellHeaderHeight } : undefined}
|
header={hasHeader ? { height: headerHeight } : undefined}
|
||||||
navbar={
|
navbar={
|
||||||
hasNavigation
|
hasNavigation
|
||||||
? {
|
? {
|
||||||
|
|||||||
Reference in new issue
Block a user