Removed redundant strings

This commit is contained in:
Henrik Larsson
2023-08-14 12:09:19 +02:00
parent d32baa7782
commit afc2874e2a
5 changed files with 0 additions and 93 deletions

View File

@@ -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>
)
}

View File

@@ -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

View File

@@ -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