A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.
feat: add title to dynamic section (#2614)
Jack Weller1dd7b1a6b97f
diff --git a/apps/nextjs/src/components/board/items/actions/test/mocks/dynamic-section-mock.ts b/apps/nextjs/src/components/board/items/actions/test/mocks/dynamic-section-mock.tsindex 7de8db63c..553deda9e 100644--- a/apps/nextjs/src/components/board/items/actions/test/mocks/dynamic-section-mock.ts+++ b/apps/nextjs/src/components/board/items/actions/test/mocks/dynamic-section-mock.ts@@ -10,6 +10,7 @@ export class DynamicSectionMockBuilder {id: createId(),kind: "dynamic",options: {+ title: "",borderColor: "",},layouts: [],diff --git a/apps/nextjs/src/components/board/sections/dynamic-section.tsx b/apps/nextjs/src/components/board/sections/dynamic-section.tsxindex 90525715a..3b5493366 100644--- a/apps/nextjs/src/components/board/sections/dynamic-section.tsx+++ b/apps/nextjs/src/components/board/sections/dynamic-section.tsx@@ -1,4 +1,4 @@-import { Box, Card } from "@mantine/core";+import { Badge, Box, Card } from "@mantine/core";import { useCurrentLayout, useRequiredBoard } from "@homarr/boards/context";@@ -17,7 +17,12 @@ export const BoardDynamicSection = ({ section }: Props) => {const options = section.options;return (- <Box className="grid-stack-item-content">+ <Box+ className="grid-stack-item-content"+ style={{+ overflow: "visible",+ }}+ ><CardclassName={classes.itemCard}w="100%"@@ -25,14 +30,28 @@ export const BoardDynamicSection = ({ section }: Props) => {withBorderstyles={{root: {+ overflow: "visible","--opacity": board.opacity / 100,- overflow: "hidden",- "--border-color": options.borderColor !== "" ? options.borderColor : undefined,+ "--border-color": options.borderColor || undefined,},}}radius={board.itemRadius}p={0}>+ {options.title && (+ <Badge+ pos="absolute"+ top={-15}+ left={10}+ size="md"+ radius={board.itemRadius}+ color="var(--background-color)"+ c="var(--mantine-color-text)"+ bd="1px solid var(--border-color)"+ >+ {options.title}+ </Badge>+ )}{/* Use unique key by layout to reinitialize gridstack */}<GridStack key={`${currentLayoutId}-${section.id}`} section={section} className="min-row" /></Card>diff --git a/apps/nextjs/src/components/board/sections/dynamic/actions/add-dynamic-section.ts b/apps/nextjs/src/components/board/sections/dynamic/actions/add-dynamic-section.tsindex 415d80572..c33507a73 100644--- a/apps/nextjs/src/components/board/sections/dynamic/actions/add-dynamic-section.ts+++ b/apps/nextjs/src/components/board/sections/dynamic/actions/add-dynamic-section.ts@@ -17,6 +17,7 @@ export const addDynamicSectionCallback = () => (board: Board) => {id: createId(),kind: "dynamic",options: {+ title: "",borderColor: "",},layouts: createDynamicSectionLayouts(board, firstSection),diff --git a/apps/nextjs/src/components/board/sections/dynamic/dynamic-edit-modal.tsx b/apps/nextjs/src/components/board/sections/dynamic/dynamic-edit-modal.tsxindex 001af145a..85ffc7e79 100644--- a/apps/nextjs/src/components/board/sections/dynamic/dynamic-edit-modal.tsx+++ b/apps/nextjs/src/components/board/sections/dynamic/dynamic-edit-modal.tsx@@ -1,6 +1,6 @@"use client";-import { Button, CloseButton, ColorInput, Group, Stack, useMantineTheme } from "@mantine/core";+import { Button, CloseButton, ColorInput, Group, Stack, TextInput, useMantineTheme } from "@mantine/core";import type { z } from "zod";import { useZodForm } from "@homarr/form";@@ -30,6 +30,7 @@ export const DynamicSectionEditModal = createModal<ModalProps>(({ actions, inner})}><Stack>+ <TextInput label={t("section.dynamic.option.title.label")} {...form.getInputProps("title")} /><ColorInputlabel={t("section.dynamic.option.borderColor.label")}format="hex"diff --git a/packages/translation/src/lang/en.json b/packages/translation/src/lang/en.jsonindex 54307c005..966700f5e 100644--- a/packages/translation/src/lang/en.json+++ b/packages/translation/src/lang/en.json@@ -980,6 +980,9 @@"remove": "Remove dynamic section"},"option": {+ "title": {+ "label": "Title"+ },"borderColor": {"label": "Border color"}diff --git a/packages/validation/src/shared.ts b/packages/validation/src/shared.tsindex 733d3edef..ddf7c30ea 100644--- a/packages/validation/src/shared.ts+++ b/packages/validation/src/shared.ts@@ -60,6 +60,7 @@ const emptySectionSchema = z.object({});export const dynamicSectionOptionsSchema = z.object({+ title: z.string().max(20).default(""),borderColor: z.string().default(""),});