From 3ce539effe2b26f2cf1112ea4622fe8ad7927605 Mon Sep 17 00:00:00 2001 From: Pat Needham Date: Thu, 15 Aug 2024 13:29:44 -0400 Subject: [PATCH] large rewrite; lint, type fixes; artwork branch clone complete --- .husky/pre-commit | 6 +- .prettierrc.js | 31 -- app/components/logo.tsx | 2 +- app/components/progress-bar.tsx | 2 +- .../templates/canvas/artwork-canvas.tsx | 4 +- .../templates/canvas/canvas-share.tsx | 4 +- .../templates/combobox/nav-combobox.tsx | 6 +- app/components/templates/form/fetcher-hex.tsx | 8 +- .../templates/form/fetcher-icon-dialog.tsx | 10 + .../templates/form/fetcher-image-select.tsx | 2 +- .../templates/form/fetcher-image-upload.tsx | 24 +- .../templates/form/fetcher-number.tsx | 8 +- .../templates/form/fetcher-select.tsx | 10 +- .../templates/form/fetcher-text.tsx | 8 +- app/components/templates/navbar/combobox.tsx | 6 +- ...rd-entity-panel.actions.update.visible.tsx | 10 +- .../templates/sidebar/sidebar-tabs.tsx | 4 +- app/components/ui/input-hidden.tsx | 15 +- app/entry.client.tsx | 2 +- app/entry.server.tsx | 4 +- .../linked-list.node.update.server.ts | 31 +- app/models/__shared/linked-list.utils.ts | 8 +- app/models/artwork-branch/_._schema.ts | 13 +- .../artwork-branch/_.clone.definitions.ts | 4 +- .../artwork-branch/_.create.db.server.ts | 18 - app/models/artwork-branch/_.create.schema.ts | 6 + app/models/artwork-branch/_.get.server.ts | 22 +- .../artwork-version.clone.service.ts | 17 +- .../artwork-versions.clone.definitions.ts | 9 + .../artwork-versions.clone.service.ts | 127 +++++ app/models/artwork-version/_._utils.ts | 18 + .../artwork-version/_.clone.definitions.ts | 5 +- .../artwork-version.create.server.ts | 2 +- .../artwork-version.get.server.ts | 64 ++- .../layer/__components.panel.create.tsx | 2 +- .../artwork-version/layer/clone.service.ts | 42 +- .../artwork-version/layer/create.service.ts | 2 +- .../layer/definitions.clone.ts | 1 - .../layer/update.reorder.move-down.service.ts | 2 +- app/models/artwork/artwork-branch._schema.ts | 10 +- .../artwork-branch.clone.definitions.ts | 2 - .../artwork/artwork-branch.clone.form.tsx | 59 +-- .../artwork/artwork-branch.clone.service.ts | 44 +- .../artwork-branch.clone.submission.ts | 7 +- app/models/artwork/artwork.get.server.ts | 17 +- app/models/asset/asset.get.server.ts | 13 +- app/models/asset/image/image.get.server.ts | 19 +- .../design-layer.update.server.ts | 21 - app/models/design/design.get.server.ts | 34 +- .../fill/update.attribute.style.submission.ts | 9 +- app/models/design/layout/layout.get.server.ts | 17 +- app/models/design/line/line.get.server.ts | 17 +- .../design/palette/palette.get.server.ts | 17 +- app/models/design/rotate/rotate.get.server.ts | 17 +- app/models/design/size/size.get.server.ts | 17 +- app/models/design/stroke/stroke.get.server.ts | 17 +- .../design/template/template.get.server.ts | 17 +- app/models/design/utils.ts | 17 +- app/models/layer/definitions.ts | 1 - .../design.__components.panel.visible.tsx | 45 ++ app/models/layer/layer.create.server.ts | 3 - app/models/layer/layer.get.server.ts | 27 +- .../layer/layer.update.linked-list.server.ts | 1 - app/models/project/project.get.server.ts | 17 +- app/models/user/user.get.server.ts | 13 +- .../_auth+/auth.$provider.callback.test.ts | 490 +++++++++--------- app/routes/_auth+/auth.$provider.callback.ts | 3 +- app/routes/_auth+/onboarding_.$provider.tsx | 5 +- app/routes/_marketing+/index.tsx | 12 +- app/routes/editor+/index.tsx | 2 +- .../header.artwork.button-group.tsx | 11 +- .../header.artwork.comboboxes.tsx | 3 - .../__components/header.artwork.tsx | 2 +- .../api.v1+/artwork-branch.create.tsx | 182 ------- .../asset.image.artwork-version.clone.tsx | 2 +- .../resources+/api.v1+/asset.update.name.tsx | 4 +- .../api.v1+/entity.create.dialog.tsx | 1 + .../api.v1+/entity.toggle.attribute.tsx | 2 +- .../api.v1+/layer.design.update.visible.tsx | 110 ---- .../api.v1+/layer.update.description.tsx | 4 +- .../resources+/api.v1+/layer.update.name.tsx | 4 +- .../artworks+/$artworkId/_index/route.tsx | 6 +- app/services/artwork/branch/create.service.ts | 108 ---- .../artwork/version/layer/delete.service.ts | 1 - .../artwork/version/layer/move-up.service.ts | 1 - ...et.image.artwork-version.delete.service.ts | 1 - .../asset.image.artwork.delete.service.ts | 1 - .../asset.image.layer.delete.service.ts | 1 - .../build/build-layer-draw-fill.service.ts | 2 +- ...build-layer-draw-position.pixel.service.ts | 9 +- .../build/build-layer-draw-stroke.service.ts | 2 +- .../layer/draw/draw-layers.asset.service.ts | 4 +- .../canvas/layer/draw/draw-layers.service.ts | 4 +- .../design-type/update-layout.service.ts | 4 - .../design-type/update-line.service.ts | 3 - .../design-type/update-palette.service.ts | 1 - .../design-type/update-rotate.service.ts | 2 - .../design-type/update-size.service.ts | 3 - .../design-type/update-stroke.service.ts | 3 - app/utils/array.utils.ts | 6 +- app/utils/conform-utils.ts | 4 +- app/utils/db.server.ts | 4 +- app/utils/providers/github.server.ts | 10 +- app/utils/typescript-helpers.ts | 2 +- dev/model-file-structure/entity._._utils.ts | 16 + .../entity._.get.db.server.ts | 72 ++- .../entity.child.clone.form.tsx | 2 +- .../entity.children.clone.service.ts | 109 ++-- package-lock.json | 192 +++---- package.json | 5 +- prisma/seed.ts | 22 +- tests/e2e/onboarding.test.ts | 2 +- 112 files changed, 1102 insertions(+), 1374 deletions(-) create mode 100644 app/models/artwork-branch/_.create.schema.ts create mode 100644 app/models/artwork-branch/artwork-versions.clone.definitions.ts create mode 100644 app/models/artwork-branch/artwork-versions.clone.service.ts create mode 100644 app/models/artwork-version/_._utils.ts delete mode 100644 app/models/design-layer/design-layer.update.server.ts create mode 100644 app/models/layer/design.__components.panel.visible.tsx delete mode 100644 app/routes/resources+/api.v1+/artwork-branch.create.tsx delete mode 100644 app/routes/resources+/api.v1+/layer.design.update.visible.tsx delete mode 100644 app/services/artwork/branch/create.service.ts create mode 100644 dev/model-file-structure/entity._._utils.ts diff --git a/.husky/pre-commit b/.husky/pre-commit index 87a0002d..cd03e92f 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,6 +1,6 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" -# npm run build -# npm run lint -# npm run typecheck +npm run build +npm run lint +npm run typecheck diff --git a/.prettierrc.js b/.prettierrc.js index 6e7ef2ce..c2d1fdcc 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -5,34 +5,3 @@ export default { ...defaultConfig, // .. your overrides here... } - -// /** @type {import("prettier").Options} */ -// export default { -// arrowParens: 'avoid', -// bracketSameLine: false, -// bracketSpacing: true, -// embeddedLanguageFormatting: 'auto', -// endOfLine: 'lf', -// htmlWhitespaceSensitivity: 'css', -// insertPragma: false, -// jsxSingleQuote: false, -// printWidth: 80, -// proseWrap: 'always', -// quoteProps: 'as-needed', -// requirePragma: false, -// semi: false, -// singleAttributePerLine: false, -// singleQuote: true, -// tabWidth: 2, -// trailingComma: 'all', -// useTabs: true, -// overrides: [ -// { -// files: ['**/*.json'], -// options: { -// useTabs: false, -// }, -// }, -// ], -// plugins: ['prettier-plugin-tailwindcss'], -// } diff --git a/app/components/logo.tsx b/app/components/logo.tsx index 40f6241f..879833a0 100644 --- a/app/components/logo.tsx +++ b/app/components/logo.tsx @@ -21,7 +21,7 @@ const Logo = () => {
{/* It first renders the Character component for the first character of the string */} - +
{/* Then it maps over the rest of the string and for each character, it renders a Character component */} {str diff --git a/app/components/progress-bar.tsx b/app/components/progress-bar.tsx index f7f9b495..00737aea 100644 --- a/app/components/progress-bar.tsx +++ b/app/components/progress-bar.tsx @@ -22,7 +22,7 @@ function EpicProgress() { .getAnimations() .map(({ finished }) => finished) - Promise.allSettled(animationPromises).then(() => { + void Promise.allSettled(animationPromises).then(() => { if (!delayedPending) setAnimationComplete(true) }) }, [delayedPending]) diff --git a/app/components/templates/canvas/artwork-canvas.tsx b/app/components/templates/canvas/artwork-canvas.tsx index 364ee8a8..f3780bc5 100644 --- a/app/components/templates/canvas/artwork-canvas.tsx +++ b/app/components/templates/canvas/artwork-canvas.tsx @@ -20,13 +20,13 @@ export const ArtworkCanvas = memo( useEffect(() => { const canvas = canvasRef.current if (canvas) { - canvasDrawService({ canvas, generator }) + void canvasDrawService({ canvas, generator }) } }, [canvasRef, generator, refresh]) const canvasFooter = useCallback(() => { const handleRefresh = () => { - setRefresh(prev => prev + 1) + setRefresh((prev) => prev + 1) } return ( { + canvas.toBlob((blob) => { if (!blob) return const file = new File([blob], downloadImageFileName(), { type: 'image/png', @@ -63,7 +63,7 @@ export const ShareCanvas = memo( const shareData = { files: filesArray, } - navigator.share(shareData as any).then(() => { + void navigator.share(shareData as any).then(() => { console.log('Shared successfully') }) } diff --git a/app/components/templates/combobox/nav-combobox.tsx b/app/components/templates/combobox/nav-combobox.tsx index 609a24d0..6dcb3bcc 100644 --- a/app/components/templates/combobox/nav-combobox.tsx +++ b/app/components/templates/combobox/nav-combobox.tsx @@ -21,7 +21,6 @@ import { capitalize } from '#app/utils/string-formatting' interface EntitySelectorProps extends PopoverProps { entities: IEntityWithSlug[] - entitySingular?: string entityPlural?: string placeholder?: string slugParam?: string @@ -30,7 +29,6 @@ interface EntitySelectorProps extends PopoverProps { export function ComboboxNav({ entities, - entitySingular = 'entity', entityPlural = 'entities', placeholder = 'Select...', slugParam, @@ -40,7 +38,7 @@ export function ComboboxNav({ const [open, setOpen] = useState(false) const params = useParams() const paramsSlug = slugParam ? params[slugParam] : params.slug - const currentEntity = entities.find(entity => entity.slug === paramsSlug) + const currentEntity = entities.find((entity) => entity.slug === paramsSlug) return ( @@ -64,7 +62,7 @@ export function ComboboxNav({ No {entityPlural} found. - {entities.map(entity => ( + {entities.map((entity) => ( setOpen(false)}> {entity.name} diff --git a/app/components/templates/form/fetcher-hex.tsx b/app/components/templates/form/fetcher-hex.tsx index 04adeb30..0ef92092 100644 --- a/app/components/templates/form/fetcher-hex.tsx +++ b/app/components/templates/form/fetcher-hex.tsx @@ -68,7 +68,7 @@ export const FetcherHex = ({ // hack to submit select form on change // through conform-to and fetcher const submitRef = useRef(null) - const handleChangeSubmit = useDebounce((f: HTMLFormElement) => { + const handleChangeSubmit = useDebounce(() => { submitRef.current?.click() }, 400) @@ -82,7 +82,7 @@ export const FetcherHex = ({ handleChangeSubmit(e.currentTarget)} + onChange={handleChangeSubmit} {...form.props} className="flex-1" > @@ -95,10 +95,10 @@ export const FetcherHex = ({ handleInput(e.currentTarget)} + onInput={(e) => handleInput(e.currentTarget)} placeholder={placeholder} disabled={isPending} - {...conform.input(fields[fieldName], { + {...conform.input(fields[fieldName]!, { ariaAttributes: true, })} /> diff --git a/app/components/templates/form/fetcher-icon-dialog.tsx b/app/components/templates/form/fetcher-icon-dialog.tsx index 65844530..89710a4f 100644 --- a/app/components/templates/form/fetcher-icon-dialog.tsx +++ b/app/components/templates/form/fetcher-icon-dialog.tsx @@ -5,6 +5,7 @@ import { useEffect, useState } from 'react' import { AuthenticityTokenInput } from 'remix-utils/csrf/react' import { type z } from 'zod' import { DialogContentGrid } from '#app/components/layout/dialog' +import { quickToast } from '#app/components/toaster.js' import { Dialog, DialogContent, @@ -73,6 +74,15 @@ export const FetcherIconDialog = ({ // parent component may want to do something // such as navigate to a new page onSuccessfulSubmission(fetcher.data) + } else if ( + fetcher.state === 'loading' && + fetcher.data?.status === 'error' + ) { + quickToast({ + type: 'error', + title: 'Error', + description: fetcher.data.message, + }) } }, [fetcher, onSuccessfulSubmission]) diff --git a/app/components/templates/form/fetcher-image-select.tsx b/app/components/templates/form/fetcher-image-select.tsx index b17890ff..5d4351d1 100644 --- a/app/components/templates/form/fetcher-image-select.tsx +++ b/app/components/templates/form/fetcher-image-select.tsx @@ -129,7 +129,7 @@ export const FetcherImageSelect = ({
{conform - .collection(assetImageId, { + .collection(assetImageId!, { type: 'radio', options: images.map(image => image.id), }) diff --git a/app/components/templates/form/fetcher-image-upload.tsx b/app/components/templates/form/fetcher-image-upload.tsx index 600d321b..8d93d114 100644 --- a/app/components/templates/form/fetcher-image-upload.tsx +++ b/app/components/templates/form/fetcher-image-upload.tsx @@ -124,7 +124,7 @@ export const FetcherImageUpload = ({ {previewImage ? ( @@ -159,7 +159,7 @@ export const FetcherImageUpload = ({ } }} accept="image/*" - {...conform.input(fields.file, { + {...conform.input(fields.file!, { type: 'file', ariaAttributes: true, })} @@ -168,8 +168,8 @@ export const FetcherImageUpload = ({
@@ -177,29 +177,29 @@ export const FetcherImageUpload = ({ labelProps={{ children: 'Name' }} inputProps={{ autoFocus: true, - ...conform.input(fields.name, { ariaAttributes: true }), - onChange: e => setName(e.currentTarget.value), + ...conform.input(fields.name!, { ariaAttributes: true }), + onChange: (e) => setName(e.currentTarget.value), }} - errors={fields.name.errors} + errors={fields.name!.errors} /> setAltText(e.currentTarget.value), + onChange: (e) => setAltText(e.currentTarget.value), }} - errors={fields.altText.errors} + errors={fields.altText!.errors} />
diff --git a/app/components/templates/form/fetcher-number.tsx b/app/components/templates/form/fetcher-number.tsx index f6a81d83..35dbd229 100644 --- a/app/components/templates/form/fetcher-number.tsx +++ b/app/components/templates/form/fetcher-number.tsx @@ -67,7 +67,7 @@ export const FetcherNumber = ({ // hack to submit select form on change // through conform-to and fetcher const submitRef = useRef(null) - const handleChangeSubmit = useDebounce((f: HTMLFormElement) => { + const handleChangeSubmit = useDebounce(() => { submitRef.current?.click() }, 400) @@ -75,7 +75,7 @@ export const FetcherNumber = ({ handleChangeSubmit(e.currentTarget)} + onChange={handleChangeSubmit} {...form.props} className="flex-1" > @@ -88,7 +88,7 @@ export const FetcherNumber = ({
{/* icon might be for artwork height, width */} {icon && ( -