mirror of
https://github.com/vercel/commerce.git
synced 2025-05-19 16:07:01 +00:00
Removed redundant strings
This commit is contained in:
parent
d32baa7782
commit
afc2874e2a
@ -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<HotspotFields>) {
|
|
||||||
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 (
|
|
||||||
<StyledBox padding={2}>
|
|
||||||
{hasProduct && previewProps ? renderPreview(previewProps) : `No product selected`}
|
|
||||||
</StyledBox>
|
|
||||||
)
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
import {StringInputProps, useFormValue, SanityDocument, StringSchemaType} from 'sanity'
|
|
||||||
import get from 'lodash.get'
|
|
||||||
|
|
||||||
type Props = StringInputProps<StringSchemaType & {options?: {field?: string}}>
|
|
||||||
|
|
||||||
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
|
|
@ -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<StringSchemaType & {options?: {field?: string}}>
|
|
||||||
|
|
||||||
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 (
|
|
||||||
<Tooltip
|
|
||||||
content={
|
|
||||||
<Box padding={2}>
|
|
||||||
<Text muted size={1}>
|
|
||||||
This value is set in Shopify (<code>{path}</code>)
|
|
||||||
</Text>
|
|
||||||
</Box>
|
|
||||||
}
|
|
||||||
portal
|
|
||||||
>
|
|
||||||
<TextInput iconRight={LockIcon} readOnly={true} value={proxyValue} />
|
|
||||||
</Tooltip>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ProxyString
|
|
@ -31,7 +31,6 @@
|
|||||||
"@sanity/types": "^3.11.1",
|
"@sanity/types": "^3.11.1",
|
||||||
"@sanity/ui": "^1.3.3",
|
"@sanity/ui": "^1.3.3",
|
||||||
"@sanity/webhook": "^2.0.0",
|
"@sanity/webhook": "^2.0.0",
|
||||||
"@sanity/color-input": "^3.0.2",
|
|
||||||
"@sanity/document-internationalization": "^2.0.1",
|
"@sanity/document-internationalization": "^2.0.1",
|
||||||
"@sanity/vision": "^3.0.0",
|
"@sanity/vision": "^3.0.0",
|
||||||
"@types/styled-components": "^5.1.26",
|
"@types/styled-components": "^5.1.26",
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import {defineConfig, isDev} from 'sanity'
|
import {defineConfig, isDev} from 'sanity'
|
||||||
import {deskTool} from 'sanity/desk'
|
import {deskTool} from 'sanity/desk'
|
||||||
import {visionTool} from '@sanity/vision'
|
import {visionTool} from '@sanity/vision'
|
||||||
import { colorInput } from "@sanity/color-input";
|
|
||||||
import {media} from 'sanity-plugin-media'
|
import {media} from 'sanity-plugin-media'
|
||||||
import {schemaTypes} from '@/lib/sanity/schemas'
|
import {schemaTypes} from '@/lib/sanity/schemas'
|
||||||
import {structure} from '@/lib/sanity/desk'
|
import {structure} from '@/lib/sanity/desk'
|
||||||
@ -51,7 +50,6 @@ export default defineConfig({
|
|||||||
// Optional, requires access to the Publishing API
|
// Optional, requires access to the Publishing API
|
||||||
// bulkPublish: true // defaults to false
|
// bulkPublish: true // defaults to false
|
||||||
}),
|
}),
|
||||||
colorInput(),
|
|
||||||
],
|
],
|
||||||
schema: {
|
schema: {
|
||||||
types: schemaTypes,
|
types: schemaTypes,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user