mirror of
https://github.com/vercel/commerce.git
synced 2025-05-15 05:56:59 +00:00
Dynamic imports
This commit is contained in:
parent
4721cdf365
commit
e566c1f451
@ -153,11 +153,11 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.glider-prev {
|
.glider-prev {
|
||||||
@apply !-top-10 !left-auto !right-12 text-high-contrast !transition-transform !duration-100 hover:scale-110 hover:!text-high-contrast lg:!-top-10 lg:!right-16 2xl:!-top-12 2xl:!right-[100px];
|
@apply !-top-10 !left-auto !right-12 text-high-contrast !transition-transform !duration-100 hover:scale-110 hover:!text-high-contrast lg:!-top-12 lg:!right-16 2xl:!right-[100px];
|
||||||
}
|
}
|
||||||
|
|
||||||
.glider-next {
|
.glider-next {
|
||||||
@apply !-top-10 !right-4 text-high-contrast !transition-transform !duration-100 hover:scale-110 hover:!text-high-contrast lg:!-top-10 lg:!right-8 2xl:!-top-12 2xl:!right-16;
|
@apply !-top-10 !right-4 text-high-contrast !transition-transform !duration-100 hover:scale-110 hover:!text-high-contrast lg:!-top-12 lg:!right-8 2xl:!right-16;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pdp .glider-prev {
|
.pdp .glider-prev {
|
||||||
|
@ -1,14 +1,24 @@
|
|||||||
import DynamicContentManager from 'components/layout/dynamic-content-manager/dynamic-content-manager';
|
import DynamicContentManager from 'components/layout/dynamic-content-manager/dynamic-content-manager';
|
||||||
import { homePageQuery } from 'lib/sanity/queries';
|
import { homePageQuery } from 'lib/sanity/queries';
|
||||||
import { clientFetch } from 'lib/sanity/sanity.client';
|
import { clientFetch } from 'lib/sanity/sanity.client';
|
||||||
|
import { Metadata } from 'next';
|
||||||
|
import { notFound } from 'next/navigation';
|
||||||
export const runtime = 'edge';
|
export const runtime = 'edge';
|
||||||
|
|
||||||
export const metadata = {
|
export async function generateMetadata({
|
||||||
description: 'High-performance ecommerce store built with Next.js, Vercel, Sanity and Storm.',
|
params
|
||||||
openGraph: {
|
}: {
|
||||||
type: 'website'
|
params: { slug: string; locale: string };
|
||||||
}
|
}): Promise<Metadata> {
|
||||||
};
|
const homePage = await clientFetch(homePageQuery, params);
|
||||||
|
|
||||||
|
if (!homePage) return notFound();
|
||||||
|
|
||||||
|
return {
|
||||||
|
title: homePage.seo.title || homePage.title,
|
||||||
|
description: homePage.seo.description || homePage.description
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
interface HomePageParams {
|
interface HomePageParams {
|
||||||
params: {
|
params: {
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { InfoCircledIcon } from '@radix-ui/react-icons';
|
|
||||||
|
|
||||||
import BlurbSection from '@/components/modules/blurb-section/blurb-section';
|
import BlurbSection from '@/components/modules/blurb-section/blurb-section';
|
||||||
import FilteredProductList from '@/components/modules/filtered-product-list/filtered-product-list';
|
import FilteredProductList from '@/components/modules/filtered-product-list/filtered-product-list';
|
||||||
import Hero from '@/components/modules/hero';
|
import Hero from '@/components/modules/hero';
|
||||||
import ReusableSection from '@/components/modules/reusable-section/reusable-section';
|
import ReusableSection from '@/components/modules/reusable-section/reusable-section';
|
||||||
import Slider from '@/components/modules/slider/slider';
|
import Slider from '@/components/modules/slider/slider';
|
||||||
import USPSection from '@/components/modules/usp-section/usp-section';
|
import USPSection from '@/components/modules/usp-section/usp-section';
|
||||||
|
import { InfoCircledIcon } from '@radix-ui/react-icons';
|
||||||
interface getContentComponentProps {
|
interface getContentComponentProps {
|
||||||
_type: string;
|
_type: string;
|
||||||
_key: number;
|
_key: number;
|
||||||
@ -19,13 +18,25 @@ const getContentComponent = ({ _type, _key, disabled, ...rest }: getContentCompo
|
|||||||
|
|
||||||
switch (_type) {
|
switch (_type) {
|
||||||
case 'hero':
|
case 'hero':
|
||||||
Component = Hero;
|
if (disabled !== true) {
|
||||||
|
Component = Hero;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'slider':
|
case 'slider':
|
||||||
Component = Slider;
|
if (disabled !== true) {
|
||||||
|
Component = Slider;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'filteredProductList':
|
case 'filteredProductList':
|
||||||
Component = FilteredProductList;
|
if (disabled !== true) {
|
||||||
|
Component = FilteredProductList;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'blurbSection':
|
case 'blurbSection':
|
||||||
if (disabled !== true) {
|
if (disabled !== true) {
|
||||||
|
@ -21,7 +21,7 @@ export default async function Footer({ locale }: FooterProps) {
|
|||||||
<footer className="border-t border-ui-border bg-app">
|
<footer className="border-t border-ui-border bg-app">
|
||||||
<div className="mx-auto flex w-full flex-col">
|
<div className="mx-auto flex w-full flex-col">
|
||||||
<div className="flex w-full items-center justify-between p-4 transition-colors duration-150 md:space-y-0 lg:px-8 lg:py-6 2xl:px-16 2xl:py-8">
|
<div className="flex w-full items-center justify-between p-4 transition-colors duration-150 md:space-y-0 lg:px-8 lg:py-6 2xl:px-16 2xl:py-8">
|
||||||
<Link className="flex flex-initial items-center font-bold md:mr-24" href="/">
|
<Link href={`/${locale}`} className="flex flex-initial items-center font-bold md:mr-24">
|
||||||
<Logo />
|
<Logo />
|
||||||
</Link>
|
</Link>
|
||||||
<LocaleSwitcher />
|
<LocaleSwitcher />
|
||||||
|
@ -22,7 +22,7 @@ const Header = ({ locale }: HeaderProps) => {
|
|||||||
|
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<Link
|
<Link
|
||||||
href={`/`}
|
href={`/${locale}`}
|
||||||
className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 transform cursor-pointer duration-100 ease-in-out md:relative md:left-0 md:top-0 md:translate-x-0 md:translate-y-0"
|
className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 transform cursor-pointer duration-100 ease-in-out md:relative md:left-0 md:top-0 md:translate-x-0 md:translate-y-0"
|
||||||
aria-label="Logo"
|
aria-label="Logo"
|
||||||
>
|
>
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
import dynamic from 'next/dynamic';
|
import { Carousel, CarouselItem } from '@/components/modules/carousel/carousel';
|
||||||
|
import Card from '@/components/ui/card/card';
|
||||||
import { Carousel, CarouselItem } from 'components/modules/carousel/carousel';
|
|
||||||
const Card = dynamic(() => import('components/ui/card'));
|
|
||||||
|
|
||||||
import Text from 'components/ui/text';
|
import Text from 'components/ui/text';
|
||||||
|
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
'use client'
|
'use client';
|
||||||
|
|
||||||
import Text from 'components/ui/text'
|
import ProductCard from '@/components/ui/product-card/product-card';
|
||||||
import dynamic from 'next/dynamic'
|
import Text from 'components/ui/text';
|
||||||
|
|
||||||
const ProductCard = dynamic(() => import('components/ui/product-card'))
|
|
||||||
|
|
||||||
interface SliderProps {
|
interface SliderProps {
|
||||||
products: any
|
products: any;
|
||||||
title: string
|
title: string;
|
||||||
itemsToShow: number
|
itemsToShow: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FilteredProductList = ({ title, products, itemsToShow }: SliderProps) => {
|
const FilteredProductList = ({ title, products, itemsToShow }: SliderProps) => {
|
||||||
@ -19,17 +17,17 @@ const FilteredProductList = ({ title, products, itemsToShow }: SliderProps) => {
|
|||||||
{title}
|
{title}
|
||||||
</Text>
|
</Text>
|
||||||
) : (
|
) : (
|
||||||
<Text className="italic mb-4 lg:mb-6 2xl:mb-8" variant="sectionHeading">
|
<Text className="mb-4 italic lg:mb-6 2xl:mb-8" variant="sectionHeading">
|
||||||
No title provided yet
|
No title provided yet
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
|
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
||||||
{products.slice(0, itemsToShow).map((product: any, index: number) => (
|
{products.slice(0, itemsToShow).map((product: any, index: number) => (
|
||||||
<ProductCard key={`${product.id}-${index}`} product={product} />
|
<ProductCard key={`${product.id}-${index}`} product={product} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default FilteredProductList
|
export default FilteredProductList;
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
import dynamic from 'next/dynamic';
|
import SanityImage from '@/components/ui/sanity-image/sanity-image';
|
||||||
|
|
||||||
import Link from 'components/ui/link/link';
|
import Link from 'components/ui/link/link';
|
||||||
import Text from 'components/ui/text/text';
|
import Text from 'components/ui/text/text';
|
||||||
const SanityImage = dynamic(() => import('components/ui/sanity-image'));
|
|
||||||
|
|
||||||
interface HeroProps {
|
interface HeroProps {
|
||||||
variant: string;
|
variant: string;
|
||||||
|
@ -1,39 +1,36 @@
|
|||||||
import Text from 'components/ui/text'
|
'use client';
|
||||||
import dynamic from 'next/dynamic'
|
|
||||||
import { useEffect, useState } from 'react'
|
|
||||||
|
|
||||||
import { Carousel, CarouselItem } from 'components/modules/carousel/carousel'
|
import Text from 'components/ui/text';
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
|
||||||
const ProductCard = dynamic(() => import('components/ui/product-card'))
|
import CategoryCard from '@/components/ui/category-card/category-card';
|
||||||
const CategoryCard = dynamic(() => import('components/ui/category-card'))
|
import ProductCard from '@/components/ui/product-card/product-card';
|
||||||
|
import { Carousel, CarouselItem } from 'components/modules/carousel/carousel';
|
||||||
|
|
||||||
interface SliderProps {
|
interface SliderProps {
|
||||||
products: [] | any
|
products: [] | any;
|
||||||
title: string
|
title: string;
|
||||||
categories: [] | any
|
categories: [] | any;
|
||||||
sliderType: String
|
sliderType: String;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Slider = ({ products, categories, title, sliderType }: SliderProps) => {
|
const Slider = ({ products, categories, title, sliderType }: SliderProps) => {
|
||||||
const [items, setItems] = useState([])
|
const [items, setItems] = useState([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (sliderType === 'products') setItems(products)
|
if (sliderType === 'products') setItems(products);
|
||||||
else if (sliderType === 'categories') setItems(categories)
|
else if (sliderType === 'categories') setItems(categories);
|
||||||
}, [])
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
{title ? (
|
{title ? (
|
||||||
<Text
|
<Text className="mb-4 px-4 lg:mb-6 lg:px-8 2xl:mb-8 2xl:px-16" variant="sectionHeading">
|
||||||
className="mb-4 px-4 lg:px-8 lg:mb-6 2xl:px-16 2xl:mb-8"
|
|
||||||
variant="sectionHeading"
|
|
||||||
>
|
|
||||||
{title}
|
{title}
|
||||||
</Text>
|
</Text>
|
||||||
) : (
|
) : (
|
||||||
<Text
|
<Text
|
||||||
className="italic mb-4 px-4 lg:px-8 lg:mb-6 2xl:px-16 2xl:mb-8"
|
className="mb-4 px-4 italic lg:mb-6 lg:px-8 2xl:mb-8 2xl:px-16"
|
||||||
variant="sectionHeading"
|
variant="sectionHeading"
|
||||||
>
|
>
|
||||||
No title provided yet
|
No title provided yet
|
||||||
@ -48,7 +45,7 @@ const Slider = ({ products, categories, title, sliderType }: SliderProps) => {
|
|||||||
breakpoint: 1024,
|
breakpoint: 1024,
|
||||||
settings: {
|
settings: {
|
||||||
slidesToShow: 4.5
|
slidesToShow: 4.5
|
||||||
},
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{items.map((item: any, index: number) => (
|
{items.map((item: any, index: number) => (
|
||||||
@ -60,7 +57,7 @@ const Slider = ({ products, categories, title, sliderType }: SliderProps) => {
|
|||||||
</Carousel>
|
</Carousel>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default Slider
|
export default Slider;
|
||||||
|
@ -6,9 +6,9 @@ import Text from 'components/ui/text/text';
|
|||||||
import { Product } from 'lib/storm/types/product';
|
import { Product } from 'lib/storm/types/product';
|
||||||
import { cn } from 'lib/utils';
|
import { cn } from 'lib/utils';
|
||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
import dynamic from 'next/dynamic';
|
import { Suspense } from 'react';
|
||||||
|
import ProductCard from '../ui/product-card/product-card';
|
||||||
import Price from './price';
|
import Price from './price';
|
||||||
const ProductCard = dynamic(() => import('components/ui/product-card'));
|
|
||||||
interface ProductViewProps {
|
interface ProductViewProps {
|
||||||
product: Product;
|
product: Product;
|
||||||
relatedProducts: Product[];
|
relatedProducts: Product[];
|
||||||
@ -81,31 +81,33 @@ export default function ProductView({ product, relatedProducts }: ProductViewPro
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{relatedProducts.length > 0 && (
|
{relatedProducts.length > 0 && (
|
||||||
<section className="my-16 flex flex-col lg:my-24">
|
<Suspense>
|
||||||
<Text className="px-4 lg:px-8 2xl:px-16" variant="sectionHeading">
|
<section className="my-16 flex flex-col lg:my-24">
|
||||||
{t('related')}
|
<Text className="px-4 lg:px-8 2xl:px-16" variant="sectionHeading">
|
||||||
</Text>
|
{t('related')}
|
||||||
|
</Text>
|
||||||
|
|
||||||
<Carousel
|
<Carousel
|
||||||
gliderClasses={'px-4 lg:px-8 2xl:px-16'}
|
gliderClasses={'px-4 lg:px-8 2xl:px-16'}
|
||||||
hasArrows={true}
|
hasArrows={true}
|
||||||
hasDots={true}
|
hasDots={true}
|
||||||
slidesToShow={2.2}
|
slidesToShow={2.2}
|
||||||
slidesToScroll={1}
|
slidesToScroll={1}
|
||||||
responsive={{
|
responsive={{
|
||||||
breakpoint: 1024,
|
breakpoint: 1024,
|
||||||
settings: {
|
settings: {
|
||||||
slidesToShow: 4.5
|
slidesToShow: 4.5
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{relatedProducts.map((p) => (
|
{relatedProducts.map((p) => (
|
||||||
<CarouselItem key={`product-${p.path}`}>
|
<CarouselItem key={`product-${p.path}`}>
|
||||||
<ProductCard product={p} />
|
<ProductCard product={p} />
|
||||||
</CarouselItem>
|
</CarouselItem>
|
||||||
))}
|
))}
|
||||||
</Carousel>
|
</Carousel>
|
||||||
</section>
|
</section>
|
||||||
|
</Suspense>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
|
import SanityImage from '@/components/ui/sanity-image/sanity-image';
|
||||||
import Price from 'components/product/price';
|
import Price from 'components/product/price';
|
||||||
import Text from 'components/ui/text';
|
import Text from 'components/ui/text';
|
||||||
import type { Product } from 'lib/storm/types/product';
|
import type { Product } from 'lib/storm/types/product';
|
||||||
import { cn } from 'lib/utils';
|
import { cn } from 'lib/utils';
|
||||||
import dynamic from 'next/dynamic';
|
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { FC } from 'react';
|
import { FC } from 'react';
|
||||||
|
|
||||||
const SanityImage = dynamic(() => import('components/ui/sanity-image'));
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className?: string;
|
className?: string;
|
||||||
product: Product;
|
product: Product;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user