This commit is contained in:
cond0r 2021-05-29 10:17:53 +03:00
parent 55fa2fdd81
commit a06fd09258
14 changed files with 31 additions and 38 deletions

View File

@ -1,10 +1,8 @@
.root { .root {
composes: root from 'components/ui/Button/Button.module.css'; composes: root from 'components/ui/Button/Button.module.css';
@apply h-12 p-0 bg-primary text-primary rounded-full mr-3 inline-flex @apply h-12 w-12 bg-primary text-primary rounded-full mr-3 inline-flex
items-center justify-center cursor-pointer transition duration-150 ease-in-out items-center justify-center cursor-pointer transition duration-150 ease-in-out
shadow-none border-gray-200 border box-border; p-0 shadow-none border-gray-200 border box-border;
min-width: 3em;
& > span { & > span {
@apply absolute; @apply absolute;
@ -15,10 +13,6 @@
} }
} }
.size {
@apply px-3 leading-none;
}
.color { .color {
@apply text-black transition duration-150 ease-in-out; @apply text-black transition duration-150 ease-in-out;

View File

@ -21,14 +21,14 @@ const Swatch: FC<Omit<ButtonProps, 'variant'> & Props> = ({
active, active,
...props ...props
}) => { }) => {
variant = variant?.toLowerCase()
label = label?.toLowerCase() label = label?.toLowerCase()
const isColor = color !== ''
const rootClassName = cn( const rootClassName = cn(
s.root, s.root,
{ {
[s.active]: active, [s.active]: active,
[s.size]: !isColor, [s.size]: variant === 'size',
[s.color]: color, [s.color]: color,
[s.dark]: color ? isDark(color) : false, [s.dark]: color ? isDark(color) : false,
}, },
@ -38,20 +38,18 @@ const Swatch: FC<Omit<ButtonProps, 'variant'> & Props> = ({
return ( return (
<Button <Button
className={rootClassName} className={rootClassName}
style={isColor ? { backgroundColor: color } : {}} style={color ? { backgroundColor: color } : {}}
aria-label="Variant Swatch" aria-label="Variant Swatch"
{...(isColor && { title: label })}
{...props} {...props}
> >
{isColor ? ( {variant === 'color' && active && (
<span> <span>
<Check /> <Check />
</span> </span>
) : (
label
)} )}
{variant === 'size' ? label : null}
</Button> </Button>
) )
} }
export default Swatch export default Swatch

View File

@ -25,10 +25,10 @@ const getProducts: ProductsEndpoint['handlers']['getProducts'] = async ({
if (search) url.searchParams.set('keyword', search) if (search) url.searchParams.set('keyword', search)
if (categoryId && Number.isInteger(Number(categoryId))) if (categoryId && Number.isInteger(Number(categoryId)))
url.searchParams.set('categories:in', categoryId) url.searchParams.set('categories:in', String(categoryId))
if (brandId && Number.isInteger(Number(brandId))) if (brandId && Number.isInteger(Number(brandId)))
url.searchParams.set('brand_id', brandId) url.searchParams.set('brand_id', String(brandId))
if (sort) { if (sort) {
const [_sort, direction] = sort.split('-') const [_sort, direction] = sort.split('-')

View File

@ -14,7 +14,7 @@ export type ProductPrice = {
} }
export type ProductOption = { export type ProductOption = {
__typename: 'MultipleChoiceOption' __typename?: 'MultipleChoiceOption'
id: string id: string
displayName: string displayName: string
values: ProductOptionValues[] values: ProductOptionValues[]
@ -47,8 +47,8 @@ export type Product = {
export type SearchProductsBody = { export type SearchProductsBody = {
search?: string search?: string
categoryId?: string categoryId?: string | number
brandId?: string brandId?: string | number
sort?: string sort?: string
locale?: string locale?: string
} }

View File

@ -2,7 +2,7 @@
export type Wishlist = any export type Wishlist = any
export type WishlistItemBody = { export type WishlistItemBody = {
variantId: string variantId: string | number
productId: string productId: string
} }

View File

@ -2,8 +2,8 @@ import {
SHOPIFY_CHECKOUT_ID_COOKIE, SHOPIFY_CHECKOUT_ID_COOKIE,
SHOPIFY_CHECKOUT_URL_COOKIE, SHOPIFY_CHECKOUT_URL_COOKIE,
SHOPIFY_CUSTOMER_TOKEN_COOKIE, SHOPIFY_CUSTOMER_TOKEN_COOKIE,
} from '@framework/const' } from '../../../const'
import associateCustomerWithCheckoutMutation from '@framework/utils/mutations/associate-customer-with-checkout' import associateCustomerWithCheckoutMutation from '../../../utils/mutations/associate-customer-with-checkout'
import type { CheckoutEndpoint } from '.' import type { CheckoutEndpoint } from '.'
const checkout: CheckoutEndpoint['handlers']['checkout'] = async ({ const checkout: CheckoutEndpoint['handlers']['checkout'] = async ({

View File

@ -6,8 +6,8 @@ import {
GetAllPagesQuery, GetAllPagesQuery,
GetAllPagesQueryVariables, GetAllPagesQueryVariables,
PageEdge, PageEdge,
} from '@framework/schema' } from '../../schema'
import { normalizePages } from '@framework/utils' import { normalizePages } from '../../utils'
import type { ShopifyConfig, Provider } from '..' import type { ShopifyConfig, Provider } from '..'
import type { GetAllPagesOperation, Page } from '../../types/page' import type { GetAllPagesOperation, Page } from '../../types/page'
import getAllPagesQuery from '../../utils/queries/get-all-pages-query' import getAllPagesQuery from '../../utils/queries/get-all-pages-query'

View File

@ -10,7 +10,7 @@ import {
} from '../../schema' } from '../../schema'
import type { ShopifyConfig, Provider } from '..' import type { ShopifyConfig, Provider } from '..'
import getAllProductsQuery from '../../utils/queries/get-all-products-query' import getAllProductsQuery from '../../utils/queries/get-all-products-query'
import { normalizeProduct } from '@framework/utils' import { normalizeProduct } from '../../utils'
export default function getAllProductsOperation({ export default function getAllProductsOperation({
commerce, commerce,

View File

@ -2,7 +2,7 @@ import type {
OperationContext, OperationContext,
OperationOptions, OperationOptions,
} from '@commerce/api/operations' } from '@commerce/api/operations'
import { normalizePage } from '@framework/utils' import { normalizePage } from '../../utils'
import type { ShopifyConfig, Provider } from '..' import type { ShopifyConfig, Provider } from '..'
import { import {
GetPageQuery, GetPageQuery,

View File

@ -2,7 +2,7 @@ import type {
OperationContext, OperationContext,
OperationOptions, OperationOptions,
} from '@commerce/api/operations' } from '@commerce/api/operations'
import { GetSiteInfoQuery, GetSiteInfoQueryVariables } from '@framework/schema' import { GetSiteInfoQueryVariables } from '../../schema'
import type { ShopifyConfig, Provider } from '..' import type { ShopifyConfig, Provider } from '..'
import { GetSiteInfoOperation } from '../../types/site' import { GetSiteInfoOperation } from '../../types/site'

View File

@ -5,18 +5,18 @@ import useLogin, { UseLogin } from '@commerce/auth/use-login'
import type { LoginHook } from '../types/login' import type { LoginHook } from '../types/login'
import useCustomer from '../customer/use-customer' import useCustomer from '../customer/use-customer'
import createCustomerAccessTokenMutation from '../utils/mutations/customer-access-token-create'
import { setCustomerToken, throwUserErrors } from '@framework/utils'
import { import {
Mutation, setCustomerToken,
MutationCustomerAccessTokenCreateArgs, throwUserErrors,
} from '@framework/schema' customerAccessTokenCreateMutation,
} from '../utils'
import { Mutation, MutationCustomerAccessTokenCreateArgs } from '../schema'
export default useLogin as UseLogin<typeof handler> export default useLogin as UseLogin<typeof handler>
export const handler: MutationHook<LoginHook> = { export const handler: MutationHook<LoginHook> = {
fetchOptions: { fetchOptions: {
query: createCustomerAccessTokenMutation, query: customerAccessTokenCreateMutation,
}, },
async fetcher({ input: { email, password }, options, fetch }) { async fetcher({ input: { email, password }, options, fetch }) {
if (!(email && password)) { if (!(email && password)) {

View File

@ -10,7 +10,7 @@ import {
handleAutomaticLogin, handleAutomaticLogin,
throwUserErrors, throwUserErrors,
customerCreateMutation, customerCreateMutation,
} from '@framework/utils' } from '../utils'
export default useSignup as UseSignup<typeof handler> export default useSignup as UseSignup<typeof handler>

View File

@ -1,7 +1,7 @@
import { import {
GetAllProductVendorsQuery, GetAllProductVendorsQuery,
GetAllProductVendorsQueryVariables, GetAllProductVendorsQueryVariables,
} from '@framework/schema' } from '../schema'
import { ShopifyConfig } from '../api' import { ShopifyConfig } from '../api'
import getAllProductVendors from './queries/get-all-product-vendors-query' import getAllProductVendors from './queries/get-all-product-vendors-query'

View File

@ -34,8 +34,9 @@ const SORT = Object.entries({
export async function getStaticProps({ export async function getStaticProps({
preview, preview,
locale, locale,
locales,
}: GetStaticPropsContext) { }: GetStaticPropsContext) {
const config = { locale } const config = { locale, locales }
const { pages } = await commerce.getAllPages({ config, preview }) const { pages } = await commerce.getAllPages({ config, preview })
const { categories, brands } = await commerce.getSiteInfo({ config, preview }) const { categories, brands } = await commerce.getSiteInfo({ config, preview })
return { return {