From 5f36d8b12528fd2c8c3da783b266d614203ec46a Mon Sep 17 00:00:00 2001 From: Manuel <30572287+manuel-rw@users.noreply.github.com> Date: Fri, 31 Jan 2025 23:32:08 +0100 Subject: [PATCH] feat: improve consistency and design (#1867) Co-authored-by: Meier Lukas --- .../manage/_components/hero-banner.module.css | 2 +- .../src/app/[locale]/manage/apps/_form.tsx | 44 ++++++++++++--- .../manage/apps/edit/[id]/_app-edit-form.tsx | 20 +++---- .../manage/apps/new/_app-new-form.tsx | 53 +++++++++++-------- .../src/app/[locale]/manage/apps/page.tsx | 2 +- .../src/app/[locale]/manage/boards/page.tsx | 20 +++++-- .../new/_integration-new-dropdown.tsx | 1 + .../manage/integrations/page.module.css | 36 +++++++++++++ .../app/[locale]/manage/integrations/page.tsx | 13 +++-- .../nextjs/src/app/[locale]/manage/layout.tsx | 53 +++++++++++-------- .../src/app/[locale]/manage/medias/page.tsx | 2 +- apps/nextjs/src/app/[locale]/manage/page.tsx | 2 +- .../[locale]/manage/search-engines/_form.tsx | 2 +- .../[locale]/manage/search-engines/page.tsx | 2 +- .../components/icons/picker/icon-picker.tsx | 29 ++++++---- .../src/components/layout/header/search.tsx | 1 + .../src/components/layout/navigation.tsx | 18 ++++--- packages/translation/src/lang/en.json | 1 + packages/ui/index.ts | 3 +- .../ui/src/components/integration-avatar.tsx | 7 +-- packages/ui/src/components/search-input.tsx | 4 +- 21 files changed, 216 insertions(+), 99 deletions(-) create mode 100644 apps/nextjs/src/app/[locale]/manage/integrations/page.module.css diff --git a/apps/nextjs/src/app/[locale]/manage/_components/hero-banner.module.css b/apps/nextjs/src/app/[locale]/manage/_components/hero-banner.module.css index f3b4141aa..2b949c990 100644 --- a/apps/nextjs/src/app/[locale]/manage/_components/hero-banner.module.css +++ b/apps/nextjs/src/app/[locale]/manage/_components/hero-banner.module.css @@ -1,5 +1,5 @@ .bannerContainer { - border-radius: 8px; + border-radius: 16px; overflow: hidden; @mixin dark { background: linear-gradient( diff --git a/apps/nextjs/src/app/[locale]/manage/apps/_form.tsx b/apps/nextjs/src/app/[locale]/manage/apps/_form.tsx index 75d75e472..ab1121f02 100644 --- a/apps/nextjs/src/app/[locale]/manage/apps/_form.tsx +++ b/apps/nextjs/src/app/[locale]/manage/apps/_form.tsx @@ -1,11 +1,11 @@ "use client"; +import { useRef } from "react"; import Link from "next/link"; import { Button, Group, Stack, Textarea, TextInput } from "@mantine/core"; import type { z } from "zod"; import { useZodForm } from "@homarr/form"; -import type { TranslationFunction } from "@homarr/translation"; import { useI18n } from "@homarr/translation/client"; import { validation } from "@homarr/validation"; @@ -14,14 +14,21 @@ import { IconPicker } from "~/components/icons/picker/icon-picker"; type FormType = z.infer; interface AppFormProps { - submitButtonTranslation: (t: TranslationFunction) => string; + buttonLabels: { + submit: string; + submitAndCreateAnother?: string; + }; initialValues?: FormType; - handleSubmit: (values: FormType) => void; + handleSubmit: (values: FormType, redirect: boolean, afterSuccess?: () => void) => void; isPending: boolean; } -export const AppForm = (props: AppFormProps) => { - const { submitButtonTranslation, handleSubmit, initialValues, isPending } = props; +export const AppForm = ({ + buttonLabels, + handleSubmit: originalHandleSubmit, + initialValues, + isPending, +}: AppFormProps) => { const t = useI18n(); const form = useZodForm(validation.app.manage, { @@ -33,11 +40,23 @@ export const AppForm = (props: AppFormProps) => { }, }); + const shouldCreateAnother = useRef(false); + const handleSubmit = (values: FormType) => { + const redirect = !shouldCreateAnother.current; + const afterSuccess = shouldCreateAnother.current + ? () => { + form.reset(); + shouldCreateAnother.current = false; + } + : undefined; + originalHandleSubmit(values, redirect, afterSuccess); + }; + return (
- +