forked from crowetic/commerce
Latest Perf, Changes
This commit is contained in:
parent
d74ffb1401
commit
2c40f61dc9
@ -1,5 +1,7 @@
|
|||||||
.root {
|
.root {
|
||||||
@apply relative max-h-full w-full box-border overflow-hidden bg-no-repeat bg-center bg-cover transition-transform ease-linear cursor-pointer;
|
@apply relative max-h-full w-full box-border overflow-hidden
|
||||||
|
bg-no-repeat bg-center bg-cover transition-transform
|
||||||
|
ease-linear cursor-pointer;
|
||||||
height: 100% !important;
|
height: 100% !important;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
@ -77,8 +79,8 @@
|
|||||||
|
|
||||||
.squareBg:before {
|
.squareBg:before {
|
||||||
@apply transition ease-in-out duration-500 bg-repeat-space w-full h-full block;
|
@apply transition ease-in-out duration-500 bg-repeat-space w-full h-full block;
|
||||||
content: '';
|
|
||||||
background-image: url('/bg-products.svg');
|
background-image: url('/bg-products.svg');
|
||||||
|
content: '';
|
||||||
}
|
}
|
||||||
|
|
||||||
.simple {
|
.simple {
|
||||||
@ -125,8 +127,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.imageContainer {
|
.imageContainer {
|
||||||
overflow: hidden;
|
|
||||||
@apply flex items-center justify-center;
|
@apply flex items-center justify-center;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
& > div {
|
||||||
|
min-width: 100%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.image {
|
.image {
|
||||||
|
@ -13,8 +13,10 @@ interface Props {
|
|||||||
variant?: 'slim' | 'simple'
|
variant?: 'slim' | 'simple'
|
||||||
imgWidth: number | string
|
imgWidth: number | string
|
||||||
imgHeight: number | string
|
imgHeight: number | string
|
||||||
priority?: boolean
|
|
||||||
imgLayout?: 'fixed' | 'intrinsic' | 'responsive' | undefined
|
imgLayout?: 'fixed' | 'intrinsic' | 'responsive' | undefined
|
||||||
|
imgPriority?: boolean
|
||||||
|
imgLoading?: 'eager' | 'lazy'
|
||||||
|
imgSizes?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const ProductCard: FC<Props> = ({
|
const ProductCard: FC<Props> = ({
|
||||||
@ -23,8 +25,10 @@ const ProductCard: FC<Props> = ({
|
|||||||
variant,
|
variant,
|
||||||
imgWidth,
|
imgWidth,
|
||||||
imgHeight,
|
imgHeight,
|
||||||
|
imgPriority,
|
||||||
|
imgLoading,
|
||||||
|
imgSizes,
|
||||||
imgLayout = 'responsive',
|
imgLayout = 'responsive',
|
||||||
priority,
|
|
||||||
}) => {
|
}) => {
|
||||||
const src = p.images.edges?.[0]?.node?.urlOriginal!
|
const src = p.images.edges?.[0]?.node?.urlOriginal!
|
||||||
const { price } = usePrice({
|
const { price } = usePrice({
|
||||||
@ -46,13 +50,15 @@ const ProductCard: FC<Props> = ({
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<Image
|
<Image
|
||||||
|
quality="85"
|
||||||
|
width={imgWidth}
|
||||||
|
sizes={imgSizes}
|
||||||
|
height={imgHeight}
|
||||||
|
layout={imgLayout}
|
||||||
|
loading={imgLoading}
|
||||||
|
priority={imgPriority}
|
||||||
src={p.images.edges?.[0]?.node.urlOriginal!}
|
src={p.images.edges?.[0]?.node.urlOriginal!}
|
||||||
alt={p.images.edges?.[0]?.node.altText || 'Product Image'}
|
alt={p.images.edges?.[0]?.node.altText || 'Product Image'}
|
||||||
width={imgWidth}
|
|
||||||
height={imgHeight}
|
|
||||||
priority={priority}
|
|
||||||
layout={imgLayout}
|
|
||||||
quality="85"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
@ -73,13 +79,16 @@ const ProductCard: FC<Props> = ({
|
|||||||
</div>
|
</div>
|
||||||
<div className={s.imageContainer}>
|
<div className={s.imageContainer}>
|
||||||
<Image
|
<Image
|
||||||
className={s.image}
|
|
||||||
alt={p.name}
|
|
||||||
src={src}
|
|
||||||
width={imgWidth}
|
|
||||||
height={imgHeight}
|
|
||||||
priority={priority}
|
|
||||||
quality="85"
|
quality="85"
|
||||||
|
src={src}
|
||||||
|
alt={p.name}
|
||||||
|
className={s.image}
|
||||||
|
width={imgWidth}
|
||||||
|
sizes={imgSizes}
|
||||||
|
height={imgHeight}
|
||||||
|
layout={imgLayout}
|
||||||
|
loading={imgLoading}
|
||||||
|
priority={imgPriority}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
.root {
|
.root {
|
||||||
--row-height: calc(100vh - 80px - 56px);
|
--row-height: calc(100vh - 88px);
|
||||||
@apply grid grid-cols-1 gap-0;
|
@apply grid grid-cols-1 gap-0;
|
||||||
|
min-height: var(--row-height);
|
||||||
|
|
||||||
@screen lg {
|
@screen lg {
|
||||||
@apply grid-cols-3 grid-rows-2;
|
@apply grid-cols-3 grid-rows-2;
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
import * as Bowser from 'bowser'
|
|
||||||
|
|
||||||
export function isDesktop(): boolean {
|
|
||||||
const browser = Bowser.getParser(window.navigator.userAgent)
|
|
||||||
return browser.getPlatform().type === 'desktop'
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isMobile(): boolean {
|
|
||||||
const browser = Bowser.getParser(window.navigator.userAgent)
|
|
||||||
return browser.getPlatform().type === 'mobile'
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isTablet(): boolean {
|
|
||||||
const browser = Bowser.getParser(window.navigator.userAgent)
|
|
||||||
return browser.getPlatform().type === 'tablet'
|
|
||||||
}
|
|
@ -1,6 +1,5 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
images: {
|
images: {
|
||||||
imagesSizes: [320, 480, 820, 1280],
|
|
||||||
domains: ['cdn11.bigcommerce.com'],
|
domains: ['cdn11.bigcommerce.com'],
|
||||||
},
|
},
|
||||||
i18n: {
|
i18n: {
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
import { useMemo } from 'react'
|
|
||||||
import type { GetStaticPropsContext, InferGetStaticPropsType } from 'next'
|
|
||||||
import rangeMap from '@lib/range-map'
|
import rangeMap from '@lib/range-map'
|
||||||
import { Layout } from '@components/common'
|
import { Layout } from '@components/common'
|
||||||
import { Grid, Marquee, Hero } from '@components/ui'
|
|
||||||
import { ProductCard } from '@components/product'
|
import { ProductCard } from '@components/product'
|
||||||
|
import { Grid, Marquee, Hero } from '@components/ui'
|
||||||
import HomeAllProductsGrid from '@components/common/HomeAllProductsGrid'
|
import HomeAllProductsGrid from '@components/common/HomeAllProductsGrid'
|
||||||
|
import type { GetStaticPropsContext, InferGetStaticPropsType } from 'next'
|
||||||
|
|
||||||
import { getConfig } from '@bigcommerce/storefront-data-hooks/api'
|
import { getConfig } from '@bigcommerce/storefront-data-hooks/api'
|
||||||
import getAllProducts from '@bigcommerce/storefront-data-hooks/api/operations/get-all-products'
|
import getAllProducts from '@bigcommerce/storefront-data-hooks/api/operations/get-all-products'
|
||||||
@ -90,10 +89,10 @@ export default function Home({
|
|||||||
<ProductCard
|
<ProductCard
|
||||||
key={node.path}
|
key={node.path}
|
||||||
product={node}
|
product={node}
|
||||||
// The first image is the largest one in the grid
|
|
||||||
imgWidth={i === 0 ? 1080 : 540}
|
imgWidth={i === 0 ? 1080 : 540}
|
||||||
imgHeight={i === 0 ? 1080 : 540}
|
imgHeight={i === 0 ? 1080 : 540}
|
||||||
priority
|
imgPriority
|
||||||
|
imgLoading="eager"
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</Grid>
|
</Grid>
|
||||||
@ -124,7 +123,6 @@ export default function Home({
|
|||||||
<ProductCard
|
<ProductCard
|
||||||
key={node.path}
|
key={node.path}
|
||||||
product={node}
|
product={node}
|
||||||
// The second image is the largest one in the grid
|
|
||||||
imgWidth={i === 1 ? 1080 : 540}
|
imgWidth={i === 1 ? 1080 : 540}
|
||||||
imgHeight={i === 1 ? 1080 : 540}
|
imgHeight={i === 1 ? 1080 : 540}
|
||||||
/>
|
/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user