fix: layer mobile widget details above header
This commit is contained in:
1 parent
251a4c8ae8
commit
35b7c4fc2d
6 files changed
+36
-2
No files matched your search
@@ -2,12 +2,13 @@
|
|||||||
|
|
||||||
import type { PropsWithChildren } from "react";
|
import type { PropsWithChildren } from "react";
|
||||||
import { createContext, useCallback, useContext, useEffect, useReducer, useRef, useState } from "react";
|
import { createContext, useCallback, useContext, useEffect, useReducer, useRef, useState } from "react";
|
||||||
import { getDefaultZIndex, Modal } from "@mantine/core";
|
import { Modal } from "@mantine/core";
|
||||||
import { randomId } from "@mantine/hooks";
|
import { randomId } from "@mantine/hooks";
|
||||||
|
|
||||||
import type { stringOrTranslation } from "@homarr/translation";
|
import type { stringOrTranslation } from "@homarr/translation";
|
||||||
import { translateIfNecessary } from "@homarr/translation";
|
import { translateIfNecessary } from "@homarr/translation";
|
||||||
import { useI18n } from "@homarr/translation/client";
|
import { useI18n } from "@homarr/translation/client";
|
||||||
|
import { managedModalZIndex } from "@homarr/ui";
|
||||||
|
|
||||||
import type { ConfirmModalProps } from "./confirm-modal";
|
import type { ConfirmModalProps } from "./confirm-modal";
|
||||||
import { ConfirmModal } from "./confirm-modal";
|
import { ConfirmModal } from "./confirm-modal";
|
||||||
@@ -99,7 +100,7 @@ const ActiveModal = ({ modal, state, handleCloseModal }: ActiveModalProps) => {
|
|||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
key={modal.id}
|
key={modal.id}
|
||||||
zIndex={getDefaultZIndex("modal") + 1}
|
zIndex={managedModalZIndex}
|
||||||
style={{
|
style={{
|
||||||
userSelect: modal.id === state.current?.id ? undefined : "none",
|
userSelect: modal.id === state.current?.id ? undefined : "none",
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import type { MantineProviderProps } from "@mantine/core";
|
|||||||
import { theme } from "./theme";
|
import { theme } from "./theme";
|
||||||
|
|
||||||
export { theme } from "./theme";
|
export { theme } from "./theme";
|
||||||
|
export { appShellHeaderZIndex, managedModalZIndex, modalZIndex } from "./theme/layers";
|
||||||
export { modalSizeForm, modalSizeSelect } from "./theme/modal";
|
export { modalSizeForm, modalSizeSelect } from "./theme/modal";
|
||||||
export * from "./components";
|
export * from "./components";
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { createTheme, rem } from "@mantine/core";
|
import { createTheme, rem } from "@mantine/core";
|
||||||
|
|
||||||
|
import { modalZIndex } from "./theme/layers";
|
||||||
import { modalComponent } from "./theme/modal";
|
import { modalComponent } from "./theme/modal";
|
||||||
|
|
||||||
export const theme = createTheme({
|
export const theme = createTheme({
|
||||||
@@ -101,6 +102,11 @@ export const theme = createTheme({
|
|||||||
overlayProps: { radius: "sm", blur: 2 },
|
overlayProps: { radius: "sm", blur: 2 },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Drawer: {
|
||||||
|
defaultProps: {
|
||||||
|
zIndex: modalZIndex,
|
||||||
|
},
|
||||||
|
},
|
||||||
Modal: modalComponent,
|
Modal: modalComponent,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import { getDefaultZIndex } from "@mantine/core";
|
||||||
|
|
||||||
|
export const appShellHeaderZIndex = getDefaultZIndex("modal") + 1;
|
||||||
|
export const modalZIndex = appShellHeaderZIndex + 1;
|
||||||
|
export const managedModalZIndex = modalZIndex + 1;
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { getDefaultZIndex } from "@mantine/core";
|
||||||
|
import { describe, expect, test } from "vitest";
|
||||||
|
|
||||||
|
import { theme } from "../theme";
|
||||||
|
import { appShellHeaderZIndex, managedModalZIndex, modalZIndex } from "./layers";
|
||||||
|
import { modalComponent } from "./modal";
|
||||||
|
|
||||||
|
describe("application layers", () => {
|
||||||
|
test("keeps dialogs above the fixed header and managed dialogs above regular dialogs", () => {
|
||||||
|
expect(appShellHeaderZIndex).toBe(getDefaultZIndex("modal") + 1);
|
||||||
|
expect(modalZIndex).toBe(appShellHeaderZIndex + 1);
|
||||||
|
expect(managedModalZIndex).toBe(modalZIndex + 1);
|
||||||
|
expect(modalComponent.defaultProps).toMatchObject({ zIndex: modalZIndex });
|
||||||
|
expect(theme.components?.Drawer?.defaultProps).toMatchObject({ zIndex: modalZIndex });
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
import type { MantineTheme, MantineThemeComponent, ModalProps } from "@mantine/core";
|
import type { MantineTheme, MantineThemeComponent, ModalProps } from "@mantine/core";
|
||||||
|
|
||||||
|
import { modalZIndex } from "./layers";
|
||||||
|
|
||||||
export const modalSizeSelect = "xxl";
|
export const modalSizeSelect = "xxl";
|
||||||
export const modalSizeForm = "lg";
|
export const modalSizeForm = "lg";
|
||||||
|
|
||||||
@@ -8,6 +10,9 @@ const fixedModalSizes = new Set([modalSizeSelect, modalSizeForm]);
|
|||||||
const modalWidth = "min(var(--modal-size), calc(100vw - 2 * var(--mantine-spacing-md)))";
|
const modalWidth = "min(var(--modal-size), calc(100vw - 2 * var(--mantine-spacing-md)))";
|
||||||
|
|
||||||
export const modalComponent: MantineThemeComponent = {
|
export const modalComponent: MantineThemeComponent = {
|
||||||
|
defaultProps: {
|
||||||
|
zIndex: modalZIndex,
|
||||||
|
},
|
||||||
vars: (_theme: MantineTheme, props: Partial<ModalProps>) => {
|
vars: (_theme: MantineTheme, props: Partial<ModalProps>) => {
|
||||||
if (props.size === modalSizeSelect) {
|
if (props.size === modalSizeSelect) {
|
||||||
return { root: { "--modal-size": "75rem" } };
|
return { root: { "--modal-size": "75rem" } };
|
||||||
|
|||||||
Reference in new issue
Block a user