From 4a2bbab52f9a829b86ddb3ce82f31ea6ab415311 Mon Sep 17 00:00:00 2001 From: Pedro Carreno <34664891+Pkcarreno@users.noreply.github.com> Date: Sun, 29 Dec 2024 01:01:06 -0400 Subject: [PATCH] feat: improve script details section --- .../editor/components/header/index.tsx | 3 +- .../editor/components/header/info/index.tsx | 57 ++++++++++++------- .../components/header/info/info-form.tsx | 36 ++++++++++++ 3 files changed, 72 insertions(+), 24 deletions(-) diff --git a/src/features/editor/components/header/index.tsx b/src/features/editor/components/header/index.tsx index ac5c82a..f62b602 100644 --- a/src/features/editor/components/header/index.tsx +++ b/src/features/editor/components/header/index.tsx @@ -3,7 +3,7 @@ import { useMemo } from 'react'; import { ActionButtons } from './action-buttons'; import { AutorunToggler } from './autorun-toggler'; -import { InfoEdit, InfoTitle } from './info'; +import { InfoTitle } from './info'; import { LayoutDirectionToggler } from './layout-direction-toggler'; import { MainMenu } from './main-menu'; import { OpenInSite } from './open-in-site'; @@ -22,7 +22,6 @@ export const Header = () => {
-
diff --git a/src/features/editor/components/header/info/index.tsx b/src/features/editor/components/header/info/index.tsx index 9d4bb23..bfc1447 100644 --- a/src/features/editor/components/header/info/index.tsx +++ b/src/features/editor/components/header/info/index.tsx @@ -1,5 +1,4 @@ -import { InfoCircledIcon } from '@radix-ui/react-icons'; -import { useCallback, useMemo, useState } from 'react'; +import { useMemo } from 'react'; import { Button } from '@/components/ui/button'; import { @@ -11,7 +10,7 @@ import { } from '@/components/ui/dialog'; import { useCodeStore } from '@/features/editor/stores/editor'; -import { InfoForm } from './info-form'; +import { InfoFormDialog } from './info-form'; interface InfoDialogProps { children: React.ReactNode; @@ -22,45 +21,59 @@ export const InfoDialog: React.FC = ({ children, asChild, }) => { - const [open, setOpen] = useState(false); - - const closeDialog = useCallback(() => { - setOpen(false); - }, []); - return ( - + {children} Script details - + ); }; -export const InfoTitle = () => { - const { title } = useCodeStore(); +const InfoDetails = () => { + const { title, description } = useCodeStore(); const titleTag = useMemo(() => (title ? title : 'No Title'), [title]); + const descriptionTag = useMemo( + () => (description ? description : 'No Description'), + [description], + ); return ( - - - {titleTag} - - +
+
+ + {titleTag} +
+
+ + {descriptionTag} +
+ + + +
); }; -export const InfoEdit = () => { +export const InfoTitle = () => { + const { title } = useCodeStore(); + + const titleTag = useMemo(() => (title ? title : 'No Title'), [title]); + return ( - ); diff --git a/src/features/editor/components/header/info/info-form.tsx b/src/features/editor/components/header/info/info-form.tsx index 242acd9..86567e3 100644 --- a/src/features/editor/components/header/info/info-form.tsx +++ b/src/features/editor/components/header/info/info-form.tsx @@ -1,9 +1,17 @@ import { zodResolver } from '@hookform/resolvers/zod'; +import { useCallback, useState } from 'react'; import { useForm } from 'react-hook-form'; import { toast } from 'sonner'; import { z } from 'zod'; import { Button } from '@/components/ui/button'; +import { + Dialog, + DialogContent, + DialogHeader, + DialogTitle, + DialogTrigger, +} from '@/components/ui/dialog'; import { Form, FormControl, @@ -83,3 +91,31 @@ export const InfoForm: React.FC = ({ closeDialog }) => { ); }; + +interface InfoFormDialogProps { + children: React.ReactNode; + asChild?: boolean; +} + +export const InfoFormDialog: React.FC = ({ + children, + asChild, +}) => { + const [open, setOpen] = useState(false); + + const closeDialog = useCallback(() => { + setOpen(false); + }, []); + + return ( + + {children} + + + Edit script details + + + + + ); +};