forked from crowetic/commerce
Ran prettier fix
This commit is contained in:
parent
bccef99c35
commit
8784e05183
@ -1,4 +1,4 @@
|
|||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
- Select Variants Working
|
- Select Variants Working
|
||||||
- Click on cart item title, closes the sidebar
|
- Click on cart item title, closes the sidebar
|
||||||
|
@ -43,7 +43,7 @@ const I18nWidget: FC = () => {
|
|||||||
const currentLocale = locale || defaultLocale
|
const currentLocale = locale || defaultLocale
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ClickOutside active={display} onClick={() => setDisplay(false)} >
|
<ClickOutside active={display} onClick={() => setDisplay(false)}>
|
||||||
<nav className={s.root}>
|
<nav className={s.root}>
|
||||||
<div
|
<div
|
||||||
className="flex items-center relative"
|
className="flex items-center relative"
|
||||||
|
@ -1,15 +1,39 @@
|
|||||||
const Vercel = ({ ...props }) => {
|
const Vercel = ({ ...props }) => {
|
||||||
return (
|
return (
|
||||||
<svg width="89" height="20" viewBox="0 0 89 20" fill="none" xmlns="http://www.w3.org/2000/svg" { ...props }>
|
<svg
|
||||||
<path d="M11.5625 0L23.125 20H0L11.5625 0Z" fill="currentColor"/>
|
width="89"
|
||||||
<path d="M49.875 10.625C49.875 7.40625 47.5 5.15625 44.0937 5.15625C40.6875 5.15625 38.3125 7.40625 38.3125 10.625C38.3125 13.7812 40.875 16.0937 44.4062 16.0937C46.3438 16.0937 48.0938 15.375 49.2188 14.0625L47.0938 12.8437C46.4375 13.5 45.4688 13.9062 44.4062 13.9062C42.8438 13.9062 41.5 13.0625 41.0312 11.7812L40.9375 11.5625H49.7812C49.8438 11.25 49.875 10.9375 49.875 10.625ZM40.9062 9.6875L40.9688 9.5C41.375 8.15625 42.5625 7.34375 44.0625 7.34375C45.5938 7.34375 46.75 8.15625 47.1562 9.5L47.2188 9.6875H40.9062Z" fill="currentColor"/>
|
height="20"
|
||||||
<path d="M83.5313 10.625C83.5313 7.40625 81.1563 5.15625 77.75 5.15625C74.3438 5.15625 71.9688 7.40625 71.9688 10.625C71.9688 13.7812 74.5313 16.0937 78.0625 16.0937C80 16.0937 81.75 15.375 82.875 14.0625L80.75 12.8437C80.0938 13.5 79.125 13.9062 78.0625 13.9062C76.5 13.9062 75.1563 13.0625 74.6875 11.7812L74.5938 11.5625H83.4375C83.5 11.25 83.5313 10.9375 83.5313 10.625ZM74.5625 9.6875L74.625 9.5C75.0313 8.15625 76.2188 7.34375 77.7188 7.34375C79.25 7.34375 80.4063 8.15625 80.8125 9.5L80.875 9.6875H74.5625Z" fill="currentColor"/>
|
viewBox="0 0 89 20"
|
||||||
<path d="M68.5313 8.84374L70.6563 7.62499C69.6563 6.06249 67.875 5.18749 65.7188 5.18749C62.3125 5.18749 59.9375 7.43749 59.9375 10.6562C59.9375 13.875 62.3125 16.125 65.7188 16.125C67.875 16.125 69.6563 15.25 70.6563 13.6875L68.5313 12.4687C67.9688 13.4062 66.9688 13.9375 65.7188 13.9375C63.75 13.9375 62.4375 12.625 62.4375 10.6562C62.4375 8.68749 63.75 7.37499 65.7188 7.37499C66.9375 7.37499 67.9688 7.90624 68.5313 8.84374Z" fill="currentColor"/>
|
fill="none"
|
||||||
<path d="M88.2188 1.75H85.7188V15.8125H88.2188V1.75Z" fill="currentColor"/>
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
<path d="M40.1563 1.75H37.2813L31.7813 11.25L26.2813 1.75H23.375L31.7813 16.25L40.1563 1.75Z" fill="currentColor"/>
|
{...props}
|
||||||
<path d="M57.8438 8.0625C58.125 8.0625 58.4062 8.09375 58.6875 8.15625V5.5C56.5625 5.5625 54.5625 6.75 54.5625 8.21875V5.5H52.0625V15.8125H54.5625V11.3437C54.5625 9.40625 55.9062 8.0625 57.8438 8.0625Z" fill="currentColor"/>
|
>
|
||||||
</svg>
|
<path d="M11.5625 0L23.125 20H0L11.5625 0Z" fill="currentColor" />
|
||||||
|
<path
|
||||||
|
d="M49.875 10.625C49.875 7.40625 47.5 5.15625 44.0937 5.15625C40.6875 5.15625 38.3125 7.40625 38.3125 10.625C38.3125 13.7812 40.875 16.0937 44.4062 16.0937C46.3438 16.0937 48.0938 15.375 49.2188 14.0625L47.0938 12.8437C46.4375 13.5 45.4688 13.9062 44.4062 13.9062C42.8438 13.9062 41.5 13.0625 41.0312 11.7812L40.9375 11.5625H49.7812C49.8438 11.25 49.875 10.9375 49.875 10.625ZM40.9062 9.6875L40.9688 9.5C41.375 8.15625 42.5625 7.34375 44.0625 7.34375C45.5938 7.34375 46.75 8.15625 47.1562 9.5L47.2188 9.6875H40.9062Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M83.5313 10.625C83.5313 7.40625 81.1563 5.15625 77.75 5.15625C74.3438 5.15625 71.9688 7.40625 71.9688 10.625C71.9688 13.7812 74.5313 16.0937 78.0625 16.0937C80 16.0937 81.75 15.375 82.875 14.0625L80.75 12.8437C80.0938 13.5 79.125 13.9062 78.0625 13.9062C76.5 13.9062 75.1563 13.0625 74.6875 11.7812L74.5938 11.5625H83.4375C83.5 11.25 83.5313 10.9375 83.5313 10.625ZM74.5625 9.6875L74.625 9.5C75.0313 8.15625 76.2188 7.34375 77.7188 7.34375C79.25 7.34375 80.4063 8.15625 80.8125 9.5L80.875 9.6875H74.5625Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M68.5313 8.84374L70.6563 7.62499C69.6563 6.06249 67.875 5.18749 65.7188 5.18749C62.3125 5.18749 59.9375 7.43749 59.9375 10.6562C59.9375 13.875 62.3125 16.125 65.7188 16.125C67.875 16.125 69.6563 15.25 70.6563 13.6875L68.5313 12.4687C67.9688 13.4062 66.9688 13.9375 65.7188 13.9375C63.75 13.9375 62.4375 12.625 62.4375 10.6562C62.4375 8.68749 63.75 7.37499 65.7188 7.37499C66.9375 7.37499 67.9688 7.90624 68.5313 8.84374Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M88.2188 1.75H85.7188V15.8125H88.2188V1.75Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M40.1563 1.75H37.2813L31.7813 11.25L26.2813 1.75H23.375L31.7813 16.25L40.1563 1.75Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M57.8438 8.0625C58.125 8.0625 58.4062 8.09375 58.6875 8.15625V5.5C56.5625 5.5625 54.5625 6.75 54.5625 8.21875V5.5H52.0625V15.8125H54.5625V11.3437C54.5625 9.40625 55.9062 8.0625 57.8438 8.0625Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
import { useKeenSlider } from 'keen-slider/react'
|
import { useKeenSlider } from 'keen-slider/react'
|
||||||
import React, { Children, FC, isValidElement, useState, useRef, useEffect } from 'react'
|
import React, {
|
||||||
|
Children,
|
||||||
|
FC,
|
||||||
|
isValidElement,
|
||||||
|
useState,
|
||||||
|
useRef,
|
||||||
|
useEffect,
|
||||||
|
} from 'react'
|
||||||
import cn from 'classnames'
|
import cn from 'classnames'
|
||||||
|
|
||||||
import s from './ProductSlider.module.css'
|
import s from './ProductSlider.module.css'
|
||||||
@ -25,7 +32,7 @@ const ProductSlider: FC = ({ children }) => {
|
|||||||
const touchXPosition = event.touches[0].pageX
|
const touchXPosition = event.touches[0].pageX
|
||||||
// Size of the touch area
|
// Size of the touch area
|
||||||
const touchXRadius = event.touches[0].radiusX || 0
|
const touchXRadius = event.touches[0].radiusX || 0
|
||||||
|
|
||||||
// We set a threshold (10px) on both sizes of the screen,
|
// We set a threshold (10px) on both sizes of the screen,
|
||||||
// if the touch area overlaps with the screen edges
|
// if the touch area overlaps with the screen edges
|
||||||
// it's likely to trigger the navigation. We prevent the
|
// it's likely to trigger the navigation. We prevent the
|
||||||
@ -33,15 +40,20 @@ const ProductSlider: FC = ({ children }) => {
|
|||||||
if (
|
if (
|
||||||
touchXPosition - touchXRadius < 10 ||
|
touchXPosition - touchXRadius < 10 ||
|
||||||
touchXPosition + touchXRadius > window.innerWidth - 10
|
touchXPosition + touchXRadius > window.innerWidth - 10
|
||||||
) event.preventDefault()
|
)
|
||||||
|
event.preventDefault()
|
||||||
}
|
}
|
||||||
|
|
||||||
sliderContainerRef.current!
|
sliderContainerRef.current!.addEventListener(
|
||||||
.addEventListener('touchstart', preventNavigation)
|
'touchstart',
|
||||||
|
preventNavigation
|
||||||
|
)
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
sliderContainerRef.current!
|
sliderContainerRef.current!.removeEventListener(
|
||||||
.removeEventListener('touchstart', preventNavigation)
|
'touchstart',
|
||||||
|
preventNavigation
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
@ -13,9 +13,9 @@ const Container: FC<Props> = ({ children, className, el = 'div', clean }) => {
|
|||||||
'mx-auto max-w-8xl px-6': !clean,
|
'mx-auto max-w-8xl px-6': !clean,
|
||||||
})
|
})
|
||||||
|
|
||||||
let Component: React.ComponentType<React.HTMLAttributes<
|
let Component: React.ComponentType<
|
||||||
HTMLDivElement
|
React.HTMLAttributes<HTMLDivElement>
|
||||||
>> = el as any
|
> = el as any
|
||||||
|
|
||||||
return <Component className={rootClassName}>{children}</Component>
|
return <Component className={rootClassName}>{children}</Component>
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,25 @@
|
|||||||
|
# Table of Contents
|
||||||
|
|
||||||
Table of Contents
|
- [BigCommerce Storefront Data Hooks](#bigcommerce-storefront-data-hooks)
|
||||||
=================
|
- [Installation](#installation)
|
||||||
|
- [General Usage](#general-usage)
|
||||||
* [BigCommerce Storefront Data Hooks](#bigcommerce-storefront-data-hooks)
|
- [CommerceProvider](#commerceprovider)
|
||||||
* [Installation](#installation)
|
- [useLogin hook](#uselogin-hook)
|
||||||
* [General Usage](#general-usage)
|
- [useLogout](#uselogout)
|
||||||
* [CommerceProvider](#commerceprovider)
|
- [useCustomer](#usecustomer)
|
||||||
* [useLogin hook](#uselogin-hook)
|
- [useSignup](#usesignup)
|
||||||
* [useLogout](#uselogout)
|
- [usePrice](#useprice)
|
||||||
* [useCustomer](#usecustomer)
|
- [Cart Hooks](#cart-hooks)
|
||||||
* [useSignup](#usesignup)
|
- [useCart](#usecart)
|
||||||
* [usePrice](#useprice)
|
- [useAddItem](#useadditem)
|
||||||
* [Cart Hooks](#cart-hooks)
|
- [useUpdateItem](#useupdateitem)
|
||||||
* [useCart](#usecart)
|
- [useRemoveItem](#useremoveitem)
|
||||||
* [useAddItem](#useadditem)
|
- [Wishlist Hooks](#wishlist-hooks)
|
||||||
* [useUpdateItem](#useupdateitem)
|
- [Product Hooks and API](#product-hooks-and-api)
|
||||||
* [useRemoveItem](#useremoveitem)
|
- [useSearch](#usesearch)
|
||||||
* [Wishlist Hooks](#wishlist-hooks)
|
- [getAllProducts](#getallproducts)
|
||||||
* [Product Hooks and API](#product-hooks-and-api)
|
- [getProduct](#getproduct)
|
||||||
* [useSearch](#usesearch)
|
- [More](#more)
|
||||||
* [getAllProducts](#getallproducts)
|
|
||||||
* [getProduct](#getproduct)
|
|
||||||
* [More](#more)
|
|
||||||
|
|
||||||
# BigCommerce Storefront Data Hooks
|
# BigCommerce Storefront Data Hooks
|
||||||
|
|
||||||
@ -235,7 +233,7 @@ import useUpdateItem from '@bigcommerce/storefront-data-hooks/cart/use-update-it
|
|||||||
const CartItem = ({ item }) => {
|
const CartItem = ({ item }) => {
|
||||||
const [quantity, setQuantity] = useState(item.quantity)
|
const [quantity, setQuantity] = useState(item.quantity)
|
||||||
const updateItem = useUpdateItem(item)
|
const updateItem = useUpdateItem(item)
|
||||||
|
|
||||||
const updateQuantity = async (e) => {
|
const updateQuantity = async (e) => {
|
||||||
const val = e.target.value
|
const val = e.target.value
|
||||||
await updateItem({ quantity: val })
|
await updateItem({ quantity: val })
|
||||||
@ -264,7 +262,7 @@ import useRemoveItem from '@bigcommerce/storefront-data-hooks/cart/use-remove-it
|
|||||||
|
|
||||||
const RemoveButton = ({ item }) => {
|
const RemoveButton = ({ item }) => {
|
||||||
const removeItem = useRemoveItem()
|
const removeItem = useRemoveItem()
|
||||||
|
|
||||||
const handleRemove = async () => {
|
const handleRemove = async () => {
|
||||||
await removeItem({ id: item.id })
|
await removeItem({ id: item.id })
|
||||||
}
|
}
|
||||||
|
@ -10,15 +10,15 @@ import updateItem from './handlers/update-item'
|
|||||||
import removeItem from './handlers/remove-item'
|
import removeItem from './handlers/remove-item'
|
||||||
|
|
||||||
type OptionSelections = {
|
type OptionSelections = {
|
||||||
option_id: Number
|
option_id: Number
|
||||||
option_value: Number|String
|
option_value: Number | String
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ItemBody = {
|
export type ItemBody = {
|
||||||
productId: number
|
productId: number
|
||||||
variantId: number
|
variantId: number
|
||||||
quantity?: number
|
quantity?: number
|
||||||
optionSelections?: OptionSelections
|
optionSelections?: OptionSelections
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AddItemBody = { item: ItemBody }
|
export type AddItemBody = { item: ItemBody }
|
||||||
|
@ -10,5 +10,5 @@ export const parseCartItem = (item: ItemBody) => ({
|
|||||||
quantity: item.quantity,
|
quantity: item.quantity,
|
||||||
product_id: item.productId,
|
product_id: item.productId,
|
||||||
variant_id: item.variantId,
|
variant_id: item.variantId,
|
||||||
option_selections: item.optionSelections
|
option_selections: item.optionSelections,
|
||||||
})
|
})
|
||||||
|
@ -54,7 +54,7 @@ async function login({
|
|||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
cookie = cookie.replace('; Secure', '')
|
cookie = cookie.replace('; Secure', '')
|
||||||
// SameSite=none can't be set unless the cookie is Secure
|
// SameSite=none can't be set unless the cookie is Secure
|
||||||
// bc seems to sometimes send back SameSite=None rather than none so make
|
// bc seems to sometimes send back SameSite=None rather than none so make
|
||||||
// this case insensitive
|
// this case insensitive
|
||||||
cookie = cookie.replace(/; SameSite=none/gi, '; SameSite=lax')
|
cookie = cookie.replace(/; SameSite=none/gi, '; SameSite=lax')
|
||||||
}
|
}
|
||||||
|
@ -38,9 +38,9 @@ async function getPage({
|
|||||||
config = getConfig(config)
|
config = getConfig(config)
|
||||||
// RecursivePartial forces the method to check for every prop in the data, which is
|
// RecursivePartial forces the method to check for every prop in the data, which is
|
||||||
// required in case there's a custom `url`
|
// required in case there's a custom `url`
|
||||||
const { data } = await config.storeApiFetch<RecursivePartial<{ data: Page[] }>>(
|
const { data } = await config.storeApiFetch<
|
||||||
url || `/v3/content/pages?id=${variables.id}&include=body`
|
RecursivePartial<{ data: Page[] }>
|
||||||
)
|
>(url || `/v3/content/pages?id=${variables.id}&include=body`)
|
||||||
const firstPage = data?.[0]
|
const firstPage = data?.[0]
|
||||||
const page = firstPage as RecursiveRequired<typeof firstPage>
|
const page = firstPage as RecursiveRequired<typeof firstPage>
|
||||||
|
|
||||||
|
@ -1,18 +1,13 @@
|
|||||||
|
import update, { Context } from 'immutability-helper'
|
||||||
|
|
||||||
import update, { Context } from 'immutability-helper';
|
const c = new Context()
|
||||||
|
|
||||||
const c = new Context();
|
c.extend('$auto', function (value, object) {
|
||||||
|
return object ? c.update(object, value) : c.update({}, value)
|
||||||
|
})
|
||||||
|
|
||||||
c.extend('$auto', function(value, object) {
|
c.extend('$autoArray', function (value, object) {
|
||||||
return object ?
|
return object ? c.update(object, value) : c.update([], value)
|
||||||
c.update(object, value):
|
})
|
||||||
c.update({}, value);
|
|
||||||
});
|
|
||||||
|
|
||||||
c.extend('$autoArray', function(value, object) {
|
export default c.update
|
||||||
return object ?
|
|
||||||
c.update(object, value):
|
|
||||||
c.update([], value);
|
|
||||||
});
|
|
||||||
|
|
||||||
export default c.update
|
|
||||||
|
@ -7,32 +7,36 @@ interface ClickOutsideProps {
|
|||||||
children: any
|
children: any
|
||||||
}
|
}
|
||||||
|
|
||||||
const ClickOutside = ({ active = true, onClick, children }: ClickOutsideProps) => {
|
const ClickOutside = ({
|
||||||
const innerRef = useRef()
|
active = true,
|
||||||
|
onClick,
|
||||||
|
children,
|
||||||
|
}: ClickOutsideProps) => {
|
||||||
|
const innerRef = useRef()
|
||||||
|
|
||||||
const handleClick = (event: any) => {
|
const handleClick = (event: any) => {
|
||||||
if (!hasParent(event.target, innerRef?.current)) {
|
if (!hasParent(event.target, innerRef?.current)) {
|
||||||
if (typeof onClick === 'function') {
|
if (typeof onClick === 'function') {
|
||||||
onClick(event)
|
onClick(event)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (active) {
|
|
||||||
document.addEventListener('mousedown', handleClick)
|
|
||||||
document.addEventListener('touchstart', handleClick)
|
|
||||||
}
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
if (active) {
|
|
||||||
document.removeEventListener('mousedown', handleClick)
|
|
||||||
document.removeEventListener('touchstart', handleClick)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return React.cloneElement(children, { ref: innerRef })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (active) {
|
||||||
|
document.addEventListener('mousedown', handleClick)
|
||||||
|
document.addEventListener('touchstart', handleClick)
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (active) {
|
||||||
|
document.removeEventListener('mousedown', handleClick)
|
||||||
|
document.removeEventListener('touchstart', handleClick)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return React.cloneElement(children, { ref: innerRef })
|
||||||
|
}
|
||||||
|
|
||||||
export default ClickOutside
|
export default ClickOutside
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"analyze": "BUNDLE_ANALYZE=both yarn build",
|
"analyze": "BUNDLE_ANALYZE=both yarn build",
|
||||||
|
"prettier-fix": "prettier --write .",
|
||||||
"find:unused": "next-unused",
|
"find:unused": "next-unused",
|
||||||
"generate": "graphql-codegen",
|
"generate": "graphql-codegen",
|
||||||
"generate:definitions": "node framework/bigcommerce/scripts/generate-definitions.js"
|
"generate:definitions": "node framework/bigcommerce/scripts/generate-definitions.js"
|
||||||
@ -86,7 +87,6 @@
|
|||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"**/*.{js,jsx,ts,tsx}": [
|
"**/*.{js,jsx,ts,tsx}": [
|
||||||
"eslint",
|
|
||||||
"prettier --write",
|
"prettier --write",
|
||||||
"git add"
|
"git add"
|
||||||
],
|
],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user