feat(dynamic-sections): add custom css classes option (#4256)

This commit is contained in:
Meier Lukas
2025-10-10 19:59:41 +02:00
committed by GitHub
parent 3b708c5ebd
commit 4c2e352aca
6 changed files with 13 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ export class DynamicSectionMockBuilder {
options: { options: {
title: "", title: "",
borderColor: "", borderColor: "",
customCssClasses: [],
}, },
layouts: [], layouts: [],
...section, ...section,

View File

@@ -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

View File

@@ -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;

View File

@@ -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"

View File

@@ -1163,6 +1163,9 @@
"title": { "title": {
"label": "Title" "label": "Title"
}, },
"customCssClasses": {
"label": "Custom css classes"
},
"borderColor": { "borderColor": {
"label": "Border color" "label": "Border color"
} }

View File

@@ -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(""),
}); });