Skip to content

Commit

Permalink
chore: reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-phan committed Jul 11, 2024
1 parent 8ef06b2 commit 4b35084
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 42 deletions.
7 changes: 3 additions & 4 deletions packages/hydrogen/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,10 @@ export function resizeShopifyImage(imageURL: string, size: string): string {
try {
if (size === 'original') {
return imageURL
} else {
let matches = imageURL.match(/(.*\/[\w-_.]+)\.(\w{2,4})/)
// @ts-ignore
return matches[1] + '_' + size + '.' + matches[2]
}
let matches = imageURL.match(/(.*\/[\w-_.]+)\.(\w{2,4})/)
// @ts-ignore
return `${matches[1]}_${size}.${matches[2]}`
} catch (e) {
return imageURL
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export interface WeaverseElementProps extends Partial<ReactElement> {
css?: ElementCSS
children?: ReactElement | ReactElement[] | ReactNode | ReactNode[]
className?: string
['data-wv-id']?: string
'data-wv-id'?: string
}

export type WeaverseRootPropsType = { context: Weaverse }
Expand Down
12 changes: 6 additions & 6 deletions packages/shopify/src/components/icons/phosphor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -436,23 +436,23 @@ export let HandBag = (props: HTMLAttributes<SVGElement>) => {
viewBox="0 0 256 256"
{...props}
>
<rect width="256" height="256" fill="none"></rect>
<rect width="256" height="256" fill="none" />
<path
d="M208.8,72H47.2a8.1,8.1,0,0,0-8,7.1L25,207.1a8,8,0,0,0,7.9,8.9H223.1a8,8,0,0,0,7.9-8.9l-14.2-128A8.1,8.1,0,0,0,208.8,72Z"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="16"
></path>
/>
<path
d="M88,104V72a40,40,0,0,1,80,0v32"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="16"
></path>
/>
</svg>
)
}
Expand All @@ -467,16 +467,16 @@ export let Tag = (props: HTMLAttributes<SVGElement>) => {
viewBox="0 0 256 256"
{...props}
>
<rect width="256" height="256" fill="none"></rect>
<rect width="256" height="256" fill="none" />
<path
d="M122.7,25.9,42,42,25.9,122.7a8,8,0,0,0,2.2,7.2L132.5,234.3a7.9,7.9,0,0,0,11.3,0l90.5-90.5a7.9,7.9,0,0,0,0-11.3L129.9,28.1A8,8,0,0,0,122.7,25.9Z"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="16"
></path>
<circle cx="84" cy="84" r="12"></circle>
/>
<circle cx="84" cy="84" r="12" />
</svg>
)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/shopify/src/elements/instagram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ let Instagram = forwardRef<HTMLDivElement, InstagramElementProps>(

let style = {
'--wv-ig-images-per-row': imagesPerRow,
'--wv-ig-images-gap': gap + 'px',
'--wv-ig-images-gap': `${gap}px`,
} as React.CSSProperties

return (
Expand Down
8 changes: 4 additions & 4 deletions packages/shopify/src/elements/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ let Layout = forwardRef<HTMLDivElement, LayoutElementProps>((props, ref) => {
} = props
let style = {
'--layout-content-width': '100vw',
'--content-size': contentSize + 'px',
'--grid-size': gridSize + 'px',
'--content-size': `${contentSize}px`,
'--grid-size': `${gridSize}px`,
'--rows': rows,
'--columns': columns,
'--gap': gap + 'px',
'--row-size': rowSize + 'px',
'--gap': `${gap}px`,
'--row-size': `${rowSize}px`,
'--col-size':
'calc((var(--grid-size) - calc(var(--columns) - 1) * var(--gap)) / var(--columns))',
} as React.CSSProperties
Expand Down
2 changes: 1 addition & 1 deletion packages/shopify/src/elements/product-list/use-products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function useProducts(input: UseProductHookInput) {
})
})
.catch((err) => {
console.log(`❌ Error fetching recommended products`, err)
console.log('❌ Error fetching recommended products', err)
})
}
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
24 changes: 12 additions & 12 deletions packages/shopify/src/elements/product/product-details/skeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function ProductSkeleton() {
</div>
</div>
<div className="wv-info">
<div className="wv-info-vendor"></div>
<div className="wv-info-vendor" />
<div className="wv-info-title">
<div className="wv-item" />
<div className="wv-item" />
Expand All @@ -49,24 +49,24 @@ export function ProductSkeleton() {
<Icon name="ShoppingCart" />
</div>
<div className="wv-info-description">
<div className="wv-line-1"></div>
<div className="wv-line-2"></div>
<div className="wv-line-3"></div>
<div className="wv-line-4"></div>
<div className="wv-line-5"></div>
<div className="wv-line-1" />
<div className="wv-line-2" />
<div className="wv-line-3" />
<div className="wv-line-4" />
<div className="wv-line-5" />
</div>
<div className="wv-info-meta">
<div className="wv-item-1">
<div className="wv-label"></div>
<div className="wv-value"></div>
<div className="wv-label" />
<div className="wv-value" />
</div>
<div className="wv-item-2">
<div className="wv-label"></div>
<div className="wv-value"></div>
<div className="wv-label" />
<div className="wv-value" />
</div>
<div className="wv-item-3">
<div className="wv-label"></div>
<div className="wv-value"></div>
<div className="wv-label" />
<div className="wv-value" />
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function useProduct(

let product: ShopifyProduct = weaverseShopifyProducts[productId]
if (useDefaultProduct && !isDesignMode) {
let defaultProduct = weaverseShopifyProducts['default']
let defaultProduct = weaverseShopifyProducts.default
if (defaultProduct?.id) {
product = defaultProduct
}
Expand Down
3 changes: 1 addition & 2 deletions packages/shopify/src/utils/cart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ export function addProductToCart(
.then((data) => {
if (data.status === 422) {
throw new Error(data.description)
} else {
window?.weaverseCartHelpers?.notify('on_item_added', data)
}
window?.weaverseCartHelpers?.notify('on_item_added', data)
})
.catch((err) =>
console.error(`Error adding product to cart: ${err.message}`),
Expand Down
7 changes: 3 additions & 4 deletions packages/shopify/src/utils/fetch-project-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ export async function fetchProjectData({
let paramString = params.toString()

data = await fetch(
weaverseHost +
`/api/public/section?id=${sectionId}${
paramString ? '&' + paramString : ''
}`,
`${weaverseHost}/api/public/section?id=${sectionId}${
paramString ? `&${paramString}` : ''
}`,
)
.then((res: Response) => res.json())
.catch((err: Error) => console.log('Error fetching project data:', err))
Expand Down
7 changes: 3 additions & 4 deletions packages/shopify/src/utils/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ export function resizeImage(imageURL: string, size: string): string {
try {
if (size === 'original') {
return imageURL
} else {
let matches = imageURL.match(/(.*\/[\w\-_.]+)\.(\w{2,4})/)
// @ts-ignore
return matches[1] + '_' + size + '.' + matches[2]
}
let matches = imageURL.match(/(.*\/[\w\-_.]+)\.(\w{2,4})/)
// @ts-ignore
return `${matches[1]}_${size}.${matches[2]}`
} catch (e) {
return imageURL
}
Expand Down
2 changes: 1 addition & 1 deletion packages/shopify/src/utils/money.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function formatMoney(cents: string | number, format: string): string {
thousands = ',',
decimal = '.',
): string | 0 {
if (isNaN(number) || number == null) {
if (Number.isNaN(number) || number == null) {
return 0
}

Expand Down
2 changes: 1 addition & 1 deletion packages/shopify/src/utils/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function getOptionsGroupConfigs(option: ShopifyProductOption) {
optionDesign = type
if (type !== 'dropdown') {
style = {
'--size': optionSizeMap[type]![size],
'--size': optionSizeMap[type]?.[size],
'--radius': optionRadiusSizeMap[shape],
}
}
Expand Down

0 comments on commit 4b35084

Please sign in to comment.