From 44ed1f3e4f8972db139788bd0c679cba234e3995 Mon Sep 17 00:00:00 2001 From: Tagaishi Date: Tue, 25 Jul 2023 15:49:52 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20Added=20titles=20to=20widget=20a?= =?UTF-8?q?nd=20improved=20division?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/locales/en/modules/bookmark.json | 6 + src/widgets/bookmark/BookmarkWidgetTile.tsx | 134 ++++++++++++-------- 2 files changed, 85 insertions(+), 55 deletions(-) diff --git a/public/locales/en/modules/bookmark.json b/public/locales/en/modules/bookmark.json index 377e4bf9d..d8052dfba 100644 --- a/public/locales/en/modules/bookmark.json +++ b/public/locales/en/modules/bookmark.json @@ -4,6 +4,12 @@ "description": "Displays a static list of strings or links", "settings": { "title": "Bookmark settings", + "name": { + "label": "Widget Title", + "placeholder": { + "label" : "Leave empty to keep the title hidden" + } + }, "items": { "label": "Items" }, diff --git a/src/widgets/bookmark/BookmarkWidgetTile.tsx b/src/widgets/bookmark/BookmarkWidgetTile.tsx index 8f1673b7d..cc062e0d1 100644 --- a/src/widgets/bookmark/BookmarkWidgetTile.tsx +++ b/src/widgets/bookmark/BookmarkWidgetTile.tsx @@ -7,6 +7,7 @@ import { Group, Image, ScrollArea, + Divider, Stack, Switch, Text, @@ -14,6 +15,7 @@ import { Title, createStyles, useMantineTheme, + InputProps, } from '@mantine/core'; import { useForm } from '@mantine/form'; import { @@ -28,6 +30,7 @@ import { useTranslation } from 'next-i18next'; import { useEffect } from 'react'; import { v4 } from 'uuid'; import { z } from 'zod'; +import React from 'react'; import { useEditModeStore } from '../../components/Dashboard/Views/useEditModeStore'; import { IconSelector } from '../../components/IconSelector/IconSelector'; @@ -47,6 +50,10 @@ const definition = defineWidget({ id: 'bookmark', icon: IconBookmark, options: { + name: { + type: 'text', + defaultValue: '', + }, items: { type: 'draggable-editable-list', defaultValue: [], @@ -215,75 +222,92 @@ function BookmarkWidgetTile({ widget }: BookmarkWidgetTileProps) { switch (widget.properties.layout) { case 'autoGrid': return ( - - {widget.properties.items.map((item: BookmarkItem, index) => ( - - - - ))} - - ); - case 'horizontal': - case 'vertical': - return ( - - + {widget.properties.name} + {widget.properties.items.map((item: BookmarkItem, index) => ( - + ))} - - + + + ); + case 'horizontal': + case 'vertical': + return ( + + + {widget.properties.name} + + + + {widget.properties.items.map((item: BookmarkItem, index) => ( + <> + + + ); default: return null;