feat(dynamic-sections): add custom css classes option (#4256)
This commit is contained in:
@@ -12,6 +12,7 @@ export class DynamicSectionMockBuilder {
|
|||||||
options: {
|
options: {
|
||||||
title: "",
|
title: "",
|
||||||
borderColor: "",
|
borderColor: "",
|
||||||
|
customCssClasses: [],
|
||||||
},
|
},
|
||||||
layouts: [],
|
layouts: [],
|
||||||
...section,
|
...section,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Badge, Box, Card } from "@mantine/core";
|
import { Badge, Box, Card } from "@mantine/core";
|
||||||
|
import combineClasses from "clsx";
|
||||||
|
|
||||||
import { useCurrentLayout, useRequiredBoard } from "@homarr/boards/context";
|
import { useCurrentLayout, useRequiredBoard } from "@homarr/boards/context";
|
||||||
|
|
||||||
@@ -24,7 +25,7 @@ export const BoardDynamicSection = ({ section }: Props) => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Card
|
<Card
|
||||||
className={classes.itemCard}
|
className={combineClasses(classes.itemCard, section.options.customCssClasses.join(" "))}
|
||||||
w="100%"
|
w="100%"
|
||||||
h="100%"
|
h="100%"
|
||||||
withBorder
|
withBorder
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export const addDynamicSectionCallback = () => (board: Board) => {
|
|||||||
options: {
|
options: {
|
||||||
title: "",
|
title: "",
|
||||||
borderColor: "",
|
borderColor: "",
|
||||||
|
customCssClasses: [],
|
||||||
},
|
},
|
||||||
layouts: createDynamicSectionLayouts(board, firstSection),
|
layouts: createDynamicSectionLayouts(board, firstSection),
|
||||||
} satisfies DynamicSection;
|
} satisfies DynamicSection;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import type { z } from "zod/v4";
|
|||||||
import { useZodForm } from "@homarr/form";
|
import { useZodForm } from "@homarr/form";
|
||||||
import { createModal } from "@homarr/modals";
|
import { createModal } from "@homarr/modals";
|
||||||
import { useI18n } from "@homarr/translation/client";
|
import { useI18n } from "@homarr/translation/client";
|
||||||
|
import { TextMultiSelect } from "@homarr/ui";
|
||||||
import { dynamicSectionOptionsSchema } from "@homarr/validation/shared";
|
import { dynamicSectionOptionsSchema } from "@homarr/validation/shared";
|
||||||
|
|
||||||
interface ModalProps {
|
interface ModalProps {
|
||||||
@@ -31,6 +32,10 @@ export const DynamicSectionEditModal = createModal<ModalProps>(({ actions, inner
|
|||||||
>
|
>
|
||||||
<Stack>
|
<Stack>
|
||||||
<TextInput label={t("section.dynamic.option.title.label")} {...form.getInputProps("title")} />
|
<TextInput label={t("section.dynamic.option.title.label")} {...form.getInputProps("title")} />
|
||||||
|
<TextMultiSelect
|
||||||
|
label={t("section.dynamic.option.customCssClasses.label")}
|
||||||
|
{...form.getInputProps("customCssClasses")}
|
||||||
|
/>
|
||||||
<ColorInput
|
<ColorInput
|
||||||
label={t("section.dynamic.option.borderColor.label")}
|
label={t("section.dynamic.option.borderColor.label")}
|
||||||
format="hex"
|
format="hex"
|
||||||
|
|||||||
@@ -1163,6 +1163,9 @@
|
|||||||
"title": {
|
"title": {
|
||||||
"label": "Title"
|
"label": "Title"
|
||||||
},
|
},
|
||||||
|
"customCssClasses": {
|
||||||
|
"label": "Custom css classes"
|
||||||
|
},
|
||||||
"borderColor": {
|
"borderColor": {
|
||||||
"label": "Border color"
|
"label": "Border color"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ const emptySectionSchema = z.object({
|
|||||||
|
|
||||||
export const dynamicSectionOptionsSchema = z.object({
|
export const dynamicSectionOptionsSchema = z.object({
|
||||||
title: z.string().max(20).default(""),
|
title: z.string().max(20).default(""),
|
||||||
|
customCssClasses: z.array(z.string()).default([]),
|
||||||
borderColor: z.string().default(""),
|
borderColor: z.string().default(""),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user