From 01646c9ca241f03b9086e9df1e00990af0891a08 Mon Sep 17 00:00:00 2001 From: Pat Needham Date: Tue, 28 May 2024 16:39:50 -0400 Subject: [PATCH 01/21] tooltip hydration fallback and text --- .../api.v1+/artwork-version.update.starred.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/routes/resources+/api.v1+/artwork-version.update.starred.tsx b/app/routes/resources+/api.v1+/artwork-version.update.starred.tsx index f0b90a39..172f6683 100644 --- a/app/routes/resources+/api.v1+/artwork-version.update.starred.tsx +++ b/app/routes/resources+/api.v1+/artwork-version.update.starred.tsx @@ -79,6 +79,9 @@ export const ArtworkVersionToggleStarred = ({ const isStarred = version.starred const icon = isStarred ? 'star-filled' : 'star' const iconText = isStarred ? 'Unstar version' : 'Star version' + const tooltipText = isStarred + ? 'Remove from starred versions' + : 'Add to starred versions' const fetcher = useFetcher() const lastSubmission = fetcher.data?.submission @@ -89,7 +92,6 @@ export const ArtworkVersionToggleStarred = ({ constraint: getFieldsetConstraint(schema), lastSubmission, }) - return ( @@ -108,10 +110,17 @@ export const ArtworkVersionToggleStarred = ({ disabled={isPending} /> - {iconText} + {tooltipText} - ) : null} + ) : ( + + )} ) } From 0feae7b5cdeb9863296f8d300f98bf77a992393a Mon Sep 17 00:00:00 2001 From: Pat Needham Date: Tue, 28 May 2024 17:04:25 -0400 Subject: [PATCH 02/21] tooltip hydration fallback and text; dialog factory components created --- app/components/layout/dialog/dialog-form.tsx | 15 ++++++ app/components/layout/dialog/index.ts | 1 + .../api.v1+/artwork-branch.create.tsx | 54 ++++++++++++------- .../header.artwork.button-group.tsx | 1 - 4 files changed, 50 insertions(+), 21 deletions(-) create mode 100644 app/components/layout/dialog/dialog-form.tsx create mode 100644 app/components/layout/dialog/index.ts diff --git a/app/components/layout/dialog/dialog-form.tsx b/app/components/layout/dialog/dialog-form.tsx new file mode 100644 index 00000000..050f9c81 --- /dev/null +++ b/app/components/layout/dialog/dialog-form.tsx @@ -0,0 +1,15 @@ +import { createContainerComponent } from '../utils' + +const DialogContentGrid = createContainerComponent({ + defaultTagName: 'div', + defaultClassName: 'grid gap-4 py-4', + displayName: 'DialogContentGrid', +}) + +const DialogFormsContainer = createContainerComponent({ + defaultTagName: 'div', + defaultClassName: 'grid gap-2', + displayName: 'DialogFormsContainer', +}) + +export { DialogContentGrid, DialogFormsContainer } diff --git a/app/components/layout/dialog/index.ts b/app/components/layout/dialog/index.ts new file mode 100644 index 00000000..245b0bc7 --- /dev/null +++ b/app/components/layout/dialog/index.ts @@ -0,0 +1 @@ +export * from './dialog-form' diff --git a/app/routes/resources+/api.v1+/artwork-branch.create.tsx b/app/routes/resources+/api.v1+/artwork-branch.create.tsx index c834426e..9418db64 100644 --- a/app/routes/resources+/api.v1+/artwork-branch.create.tsx +++ b/app/routes/resources+/api.v1+/artwork-branch.create.tsx @@ -11,6 +11,10 @@ import { AuthenticityTokenInput } from 'remix-utils/csrf/react' import { redirectBack } from 'remix-utils/redirect-back' import { useHydrated } from 'remix-utils/use-hydrated' import { Field, TextareaField } from '#app/components/forms' +import { + DialogContentGrid, + DialogFormsContainer, +} from '#app/components/layout/dialog' import { Dialog, DialogContent, @@ -22,6 +26,12 @@ import { } from '#app/components/ui/dialog' import { PanelIconButton } from '#app/components/ui/panel-icon-button' import { StatusButton } from '#app/components/ui/status-button' +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, +} from '#app/components/ui/tooltip' import { type IArtwork } from '#app/models/artwork/artwork.server' import { validateNewArtworkBranchSubmission } from '#app/models/artwork-branch/artwork-branch.create.server' import { type IArtworkBranch } from '#app/models/artwork-branch/artwork-branch.server' @@ -82,22 +92,20 @@ export const ArtworkBranchCreate = ({ branchId, artworkId, versionId, - formId, }: { branchId: IArtworkBranch['id'] artworkId: IArtwork['id'] versionId: IArtworkVersion['id'] - formId: string }) => { const [open, setOpen] = useState(false) const fetcher = useFetcher() const isPending = useIsPending() const navigate = useNavigate() - let isHydrated = useHydrated() + const [form, fields] = useForm({ - id: `${formId}-${artworkId}-${branchId}-${versionId}`, + id: `artwork-branch-create-${artworkId}-${branchId}-${versionId}`, constraint: getFieldsetConstraint(schema), lastSubmission: fetcher.data?.submission, onValidate: ({ formData }) => { @@ -120,25 +128,31 @@ export const ArtworkBranchCreate = ({ return ( - {/* Warning: Expected server HTML to contain a matching