Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export class DynamicSectionMockBuilder {
id: createId(),
kind: "dynamic",
options: {
title: "",
borderColor: "",
},
layouts: [],
Expand Down
27 changes: 23 additions & 4 deletions apps/nextjs/src/components/board/sections/dynamic-section.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Card } from "@mantine/core";
import { Badge, Box, Card } from "@mantine/core";

import { useCurrentLayout, useRequiredBoard } from "@homarr/boards/context";

Expand All @@ -17,22 +17,41 @@ 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",
}}
>
<Card
className={classes.itemCard}
w="100%"
h="100%"
withBorder
styles={{
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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const addDynamicSectionCallback = () => (board: Board) => {
id: createId(),
kind: "dynamic",
options: {
title: "",
borderColor: "",
},
layouts: createDynamicSectionLayouts(board, firstSection),
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -30,6 +30,7 @@ export const DynamicSectionEditModal = createModal<ModalProps>(({ actions, inner
})}
>
<Stack>
<TextInput label={t("section.dynamic.option.title.label")} {...form.getInputProps("title")} />
<ColorInput
label={t("section.dynamic.option.borderColor.label")}
format="hex"
Expand Down
3 changes: 3 additions & 0 deletions packages/translation/src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,9 @@
"remove": "Remove dynamic section"
},
"option": {
"title": {
"label": "Title"
},
"borderColor": {
"label": "Border color"
}
Expand Down
1 change: 1 addition & 0 deletions packages/validation/src/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const emptySectionSchema = z.object({
});

export const dynamicSectionOptionsSchema = z.object({
title: z.string().max(20).default(""),
borderColor: z.string().default(""),
});

Expand Down
Loading