4
0
forked from crowetic/commerce

Fix: color option

This commit is contained in:
cond0r 2021-02-04 17:44:17 +02:00
parent 029a8372a2
commit 553a1fd9d3
3 changed files with 15 additions and 10 deletions

View File

@ -25,8 +25,8 @@ const ProductCard: FC<Props> = ({
<a className={cn(s.root, { [s.simple]: variant === 'simple' }, className)}> <a className={cn(s.root, { [s.simple]: variant === 'simple' }, className)}>
{variant === 'slim' ? ( {variant === 'slim' ? (
<div className="relative overflow-hidden box-border"> <div className="relative overflow-hidden box-border">
<div className="absolute inset-0 flex items-center justify-end mr-8 z-20"> <div className="absolute inset-0 flex items-start justify-end m-1 z-20">
<span className="bg-black text-white inline-block p-3 font-bold text-xl break-words"> <span className="text-black inline-block p-3 font-bold text-xl break-words">
{product.name} {product.name}
</span> </span>
</div> </div>

View File

@ -22,14 +22,17 @@ const normalizeProductOption = ({
name: displayName, name: displayName,
values, values,
...rest ...rest
}: ProductOption) => ({ }: ProductOption) => {
__typename: 'MultipleChoiceOption', return {
displayName, __typename: 'MultipleChoiceOption',
values: values.map((value) => ({ displayName,
label: value, values: values.map((value) => ({
})), label: value,
...rest, hexColors: displayName === 'Color' ? [value] : null,
}) })),
...rest,
}
}
const normalizeProductImages = ({ edges }: ImageConnection) => const normalizeProductImages = ({ edges }: ImageConnection) =>
edges?.map(({ node: { originalSrc: url, ...rest } }) => ({ edges?.map(({ node: { originalSrc: url, ...rest } }) => ({

View File

@ -29,6 +29,8 @@ const getProduct = async (options: {
const product = data?.productByHandle const product = data?.productByHandle
console.info(normalizeProduct(product))
return { return {
product: product ? normalizeProduct(product) : null, product: product ? normalizeProduct(product) : null,
} }