mirror of
https://github.com/vercel/commerce.git
synced 2025-05-17 23:16:59 +00:00
Fix errors & styles
This commit is contained in:
parent
3f49d0aef9
commit
41f8a651f7
@ -51,7 +51,6 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vercel/commerce": "^0.0.1",
|
"@vercel/commerce": "^0.0.1",
|
||||||
"@vercel/fetch": "^6.1.1",
|
"@vercel/fetch": "^6.1.1",
|
||||||
"humanize-string": "^3.0.0",
|
|
||||||
"lodash.debounce": "^4.0.8"
|
"lodash.debounce": "^4.0.8"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
@ -6,7 +6,8 @@ export const SHOPIFY_CART_URL_COOKIE = 'shopify_cartUrl'
|
|||||||
|
|
||||||
export const SHOPIFY_CUSTOMER_TOKEN_COOKIE = 'shopify_customerToken'
|
export const SHOPIFY_CUSTOMER_TOKEN_COOKIE = 'shopify_customerToken'
|
||||||
|
|
||||||
export const STORE_DOMAIN = process.env.NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN
|
export const STORE_DOMAIN =
|
||||||
|
process.env.NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN?.replace(/(^\w+:|^)\/\//, '')
|
||||||
|
|
||||||
export const SHOPIFY_COOKIE_EXPIRE = 30
|
export const SHOPIFY_COOKIE_EXPIRE = 30
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ export const getMetafieldValue = (
|
|||||||
) => {
|
) => {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
return value === 'true' ? '✓' : 'No'
|
return value === 'true' ? '✓' : '✕'
|
||||||
case 'number_integer':
|
case 'number_integer':
|
||||||
return parseInt(value).toLocaleString(locale)
|
return parseInt(value).toLocaleString(locale)
|
||||||
case 'number_decimal':
|
case 'number_decimal':
|
||||||
@ -88,3 +88,15 @@ export const getMetafieldValue = (
|
|||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const humanizeString = (string: string) => {
|
||||||
|
string = string
|
||||||
|
.toLowerCase()
|
||||||
|
.replace(/[_-]+/g, ' ')
|
||||||
|
.replace(/\s{2,}/g, ' ')
|
||||||
|
.trim()
|
||||||
|
|
||||||
|
string = string.charAt(0).toUpperCase() + string.slice(1)
|
||||||
|
|
||||||
|
return string
|
||||||
|
}
|
||||||
|
@ -16,11 +16,10 @@ import type {
|
|||||||
CartDetailsFragment,
|
CartDetailsFragment,
|
||||||
} from '../../schema'
|
} from '../../schema'
|
||||||
|
|
||||||
import humanizeString from 'humanize-string'
|
|
||||||
import { CommerceError } from '@vercel/commerce/utils/errors'
|
import { CommerceError } from '@vercel/commerce/utils/errors'
|
||||||
|
|
||||||
import { colorMap } from './colors'
|
import { colorMap } from './colors'
|
||||||
import { getMetafieldValue, parseJson } from './metafields'
|
import { getMetafieldValue, parseJson, humanizeString } from './metafields'
|
||||||
|
|
||||||
type MoneyProps = MoneyV2 & { retailPrice?: string | number }
|
type MoneyProps = MoneyV2 & { retailPrice?: string | number }
|
||||||
|
|
||||||
|
@ -13,7 +13,10 @@ const Head: VFC = () => {
|
|||||||
{process.env.COMMERCE_PROVIDER === '@vercel/commerce-shopify' && (
|
{process.env.COMMERCE_PROVIDER === '@vercel/commerce-shopify' && (
|
||||||
<link
|
<link
|
||||||
rel="preconnect"
|
rel="preconnect"
|
||||||
href={`https://${process.env.NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN}`}
|
href={`https://${process.env.NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN?.replace(
|
||||||
|
/(^\w+:|^)\/\//,
|
||||||
|
''
|
||||||
|
)}`}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</SEO>
|
</SEO>
|
||||||
|
@ -2,10 +2,10 @@ import type { ProductCustomField } from '@commerce/types/product'
|
|||||||
|
|
||||||
const ProductCustomFields = ({ fields }: { fields: ProductCustomField[] }) => {
|
const ProductCustomFields = ({ fields }: { fields: ProductCustomField[] }) => {
|
||||||
return (
|
return (
|
||||||
<ul className="flex flex-col space-y-2 divide-y divide-dashed">
|
<ul className="flex flex-col space-y-2.5 divide-y divide-accent-2 divide-dashed">
|
||||||
{fields.map((m) => (
|
{fields.map((m) => (
|
||||||
<li
|
<li
|
||||||
className="flex space-x-2 justify-start items-start text-sm pt-2"
|
className="flex space-x-2 justify-start items-start pt-2.5 text-sm"
|
||||||
key={m.key}
|
key={m.key}
|
||||||
>
|
>
|
||||||
<span className="font-bold capitalize whitespace-nowrap">
|
<span className="font-bold capitalize whitespace-nowrap">
|
||||||
|
@ -5,8 +5,9 @@
|
|||||||
|
|
||||||
.main {
|
.main {
|
||||||
@apply relative px-0 pb-0 box-border flex flex-col col-span-1;
|
@apply relative px-0 pb-0 box-border flex flex-col col-span-1;
|
||||||
min-height: 500px;
|
min-height: 728px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar {
|
.sidebar {
|
||||||
@apply flex flex-col col-span-1 mx-auto max-w-8xl px-6 py-6 w-full h-full;
|
@apply flex flex-col col-span-1 mx-auto max-w-8xl px-6 py-6 w-full h-full;
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,13 @@ const ProductView: FC<ProductViewProps> = ({ product, relatedProducts }) => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Container className="max-w-none w-full" clean>
|
<Container className="max-w-none w-full" clean>
|
||||||
<hr className="mt-7 border-accent-2" />
|
|
||||||
<section className="py-12 px-6 mb-10">
|
|
||||||
<ProductProvider product={product}>
|
<ProductProvider product={product}>
|
||||||
<ProductDetails />
|
<ProductDetails />
|
||||||
</ProductProvider>
|
</ProductProvider>
|
||||||
|
|
||||||
|
<hr className="mt-7 border-accent-2" />
|
||||||
|
|
||||||
|
<section className="py-12 px-6 mb-10">
|
||||||
<Text variant="sectionHeading">Related Products</Text>
|
<Text variant="sectionHeading">Related Products</Text>
|
||||||
<div className={s.relatedProductsGrid}>
|
<div className={s.relatedProductsGrid}>
|
||||||
{relatedProducts.map((p) => (
|
{relatedProducts.map((p) => (
|
||||||
|
12
yarn.lock
12
yarn.lock
@ -2853,11 +2853,6 @@ decamelize@^1.2.0:
|
|||||||
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
|
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
|
||||||
integrity sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==
|
integrity sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==
|
||||||
|
|
||||||
decamelize@^6.0.0:
|
|
||||||
version "6.0.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-6.0.0.tgz#8cad4d916fde5c41a264a43d0ecc56fe3d31749e"
|
|
||||||
integrity sha512-Fv96DCsdOgB6mdGl67MT5JaTNKRzrzill5OH5s8bjYJXVlcXyPYGyPsUkWyGV5p1TXI5esYIYMMeDJL0hEIwaA==
|
|
||||||
|
|
||||||
decode-uri-component@^0.2.0:
|
decode-uri-component@^0.2.0:
|
||||||
version "0.2.0"
|
version "0.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545"
|
resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545"
|
||||||
@ -3991,13 +3986,6 @@ humanize-ms@^1.2.1:
|
|||||||
dependencies:
|
dependencies:
|
||||||
ms "^2.0.0"
|
ms "^2.0.0"
|
||||||
|
|
||||||
humanize-string@^3.0.0:
|
|
||||||
version "3.0.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/humanize-string/-/humanize-string-3.0.0.tgz#4ea0ef1daf1d23fd8d8c7864adf0117f74939455"
|
|
||||||
integrity sha512-jhWD2GAZRMELz0IEIfqpEdi0M4CMQF1GpJpBYIopFN6wT+78STiujfQTKcKqZzOJgUkIgJSo2xFeHdsg922JZQ==
|
|
||||||
dependencies:
|
|
||||||
decamelize "^6.0.0"
|
|
||||||
|
|
||||||
husky@^7.0.4:
|
husky@^7.0.4:
|
||||||
version "7.0.4"
|
version "7.0.4"
|
||||||
resolved "https://registry.yarnpkg.com/husky/-/husky-7.0.4.tgz#242048245dc49c8fb1bf0cc7cfb98dd722531535"
|
resolved "https://registry.yarnpkg.com/husky/-/husky-7.0.4.tgz#242048245dc49c8fb1bf0cc7cfb98dd722531535"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user