mirror of
https://github.com/vercel/commerce.git
synced 2025-06-19 21:51:21 +00:00
Fix category & color normalization
This commit is contained in:
parent
9f6dd278d7
commit
5aa36dfcd4
@ -44,16 +44,17 @@ const Swatch: FC<Omit<ButtonProps, 'variant'> & SwatchProps> = ({
|
|||||||
className={swatchClassName}
|
className={swatchClassName}
|
||||||
style={color ? { backgroundColor: color } : {}}
|
style={color ? { backgroundColor: color } : {}}
|
||||||
aria-label="Variant Swatch"
|
aria-label="Variant Swatch"
|
||||||
|
{...(label && color && { title: label })}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
{variant === 'color' && active && (
|
{color && active && (
|
||||||
<span>
|
<span>
|
||||||
<Check />
|
<Check />
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{variant !== 'color' ? label : null}
|
{!color ? label : null}
|
||||||
</Button>
|
</Button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Swatch
|
export default Swatch
|
||||||
|
@ -14,6 +14,7 @@ import {
|
|||||||
ProductOption,
|
ProductOption,
|
||||||
Page as ShopifyPage,
|
Page as ShopifyPage,
|
||||||
PageEdge,
|
PageEdge,
|
||||||
|
Collection,
|
||||||
} from '../schema'
|
} from '../schema'
|
||||||
import { colorMap } from '@lib/colors'
|
import { colorMap } from '@lib/colors'
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ const normalizeProductOption = ({
|
|||||||
label: value,
|
label: value,
|
||||||
}
|
}
|
||||||
if (displayName.match(/colou?r/gi)) {
|
if (displayName.match(/colou?r/gi)) {
|
||||||
const mapedColor = colorMap[value]
|
const mapedColor = colorMap[value.toLowerCase().replace(/ /g, '')]
|
||||||
if (mapedColor) {
|
if (mapedColor) {
|
||||||
output = {
|
output = {
|
||||||
...output,
|
...output,
|
||||||
@ -183,10 +184,13 @@ export const normalizePage = (
|
|||||||
export const normalizePages = (edges: PageEdge[], locale: string): Page[] =>
|
export const normalizePages = (edges: PageEdge[], locale: string): Page[] =>
|
||||||
edges?.map((edge) => normalizePage(edge.node, locale))
|
edges?.map((edge) => normalizePage(edge.node, locale))
|
||||||
|
|
||||||
export const normalizeCategory = (category: any): Category => ({
|
export const normalizeCategory = ({
|
||||||
id: category.id,
|
title: name,
|
||||||
name: category.name,
|
handle,
|
||||||
slug: category.handle,
|
id,
|
||||||
path: `/${category.handle}`,
|
}: Collection): Category => ({
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
slug: handle,
|
||||||
|
path: `/${handle}`,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
"@components/*": ["components/*"],
|
"@components/*": ["components/*"],
|
||||||
"@commerce": ["framework/commerce"],
|
"@commerce": ["framework/commerce"],
|
||||||
"@commerce/*": ["framework/commerce/*"],
|
"@commerce/*": ["framework/commerce/*"],
|
||||||
"@framework": ["framework/bigcommerce"],
|
"@framework": ["framework/shopify"],
|
||||||
"@framework/*": ["framework/bigcommerce/*"]
|
"@framework/*": ["framework/shopify/*"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": ["next-env.d.ts", "**/*.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],
|
"include": ["next-env.d.ts", "**/*.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user