From afc2874e2a0d675242a2120a879eb9a72c6ec4fb Mon Sep 17 00:00:00 2001 From: Henrik Larsson Date: Mon, 14 Aug 2023 12:09:19 +0200 Subject: [PATCH] Removed redundant strings --- .../components/hotspots/ProductTooltip.tsx | 38 ------------------- .../components/inputs/PlaceholderString.tsx | 20 ---------- lib/sanity/components/inputs/ProxyString.tsx | 32 ---------------- package.json | 1 - sanity.config.ts | 2 - 5 files changed, 93 deletions(-) delete mode 100644 lib/sanity/components/hotspots/ProductTooltip.tsx delete mode 100644 lib/sanity/components/inputs/PlaceholderString.tsx delete mode 100644 lib/sanity/components/inputs/ProxyString.tsx diff --git a/lib/sanity/components/hotspots/ProductTooltip.tsx b/lib/sanity/components/hotspots/ProductTooltip.tsx deleted file mode 100644 index 4b39100c8..000000000 --- a/lib/sanity/components/hotspots/ProductTooltip.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import styled from 'styled-components' -import {PreviewLayoutKey, SchemaType, useSchema} from 'sanity' -import {Box} from '@sanity/ui' -import {HotspotTooltipProps} from 'sanity-plugin-hotspot-array' -import {useMemo} from 'react' - -interface HotspotFields { - productWithVariant?: { - product: { - _ref: string - } - } -} - -const StyledBox = styled(Box)` - width: 200px; -` - -export default function ProductPreview(props: HotspotTooltipProps) { - const {value, renderPreview} = props - const productSchemaType = useSchema().get('product') - const hasProduct = value?.productWithVariant?.product?._ref && productSchemaType - - const previewProps = useMemo( - () => ({ - value: value?.productWithVariant?.product, - schemaType: productSchemaType as SchemaType, - layout: 'default' as PreviewLayoutKey, - }), - [productSchemaType, value?.productWithVariant?.product] - ) - - return ( - - {hasProduct && previewProps ? renderPreview(previewProps) : `No product selected`} - - ) -} diff --git a/lib/sanity/components/inputs/PlaceholderString.tsx b/lib/sanity/components/inputs/PlaceholderString.tsx deleted file mode 100644 index 22e96526d..000000000 --- a/lib/sanity/components/inputs/PlaceholderString.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import {StringInputProps, useFormValue, SanityDocument, StringSchemaType} from 'sanity' -import get from 'lodash.get' - -type Props = StringInputProps - -const PlaceholderStringInput = (props: Props) => { - const {schemaType} = props - - const path = schemaType?.options?.field - const doc = useFormValue([]) as SanityDocument - - const proxyValue = path ? (get(doc, path) as string) : '' - - return props.renderDefault({ - ...props, - elementProps: {placeholder: proxyValue, ...props.elementProps}, - }) -} - -export default PlaceholderStringInput diff --git a/lib/sanity/components/inputs/ProxyString.tsx b/lib/sanity/components/inputs/ProxyString.tsx deleted file mode 100644 index 3129370c7..000000000 --- a/lib/sanity/components/inputs/ProxyString.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import {LockIcon} from '@sanity/icons' -import {Box, Text, TextInput, Tooltip} from '@sanity/ui' -import {StringInputProps, useFormValue, SanityDocument, StringSchemaType} from 'sanity' -import get from 'lodash.get' - -type Props = StringInputProps - -const ProxyString = (props: Props) => { - const {schemaType} = props - - const path = schemaType?.options?.field - const doc = useFormValue([]) as SanityDocument - - const proxyValue = path ? (get(doc, path) as string) : '' - - return ( - - - This value is set in Shopify ({path}) - - - } - portal - > - - - ) -} - -export default ProxyString diff --git a/package.json b/package.json index c78568af8..9f7cb845a 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,6 @@ "@sanity/types": "^3.11.1", "@sanity/ui": "^1.3.3", "@sanity/webhook": "^2.0.0", - "@sanity/color-input": "^3.0.2", "@sanity/document-internationalization": "^2.0.1", "@sanity/vision": "^3.0.0", "@types/styled-components": "^5.1.26", diff --git a/sanity.config.ts b/sanity.config.ts index 8709e903d..97ef134b2 100644 --- a/sanity.config.ts +++ b/sanity.config.ts @@ -1,7 +1,6 @@ import {defineConfig, isDev} from 'sanity' import {deskTool} from 'sanity/desk' import {visionTool} from '@sanity/vision' -import { colorInput } from "@sanity/color-input"; import {media} from 'sanity-plugin-media' import {schemaTypes} from '@/lib/sanity/schemas' import {structure} from '@/lib/sanity/desk' @@ -51,7 +50,6 @@ export default defineConfig({ // Optional, requires access to the Publishing API // bulkPublish: true // defaults to false }), - colorInput(), ], schema: { types: schemaTypes,