From 22aab2f657c612ccfc3abe4bf9add5584018d15b Mon Sep 17 00:00:00 2001 From: Henrik Larsson Date: Tue, 8 Aug 2023 16:20:45 +0200 Subject: [PATCH] Updates --- .env.example | 10 + app/[locale]/globals.css | 89 ++- app/[locale]/layout.tsx | 37 +- app/[locale]/product/[slug]/page.tsx | 2 - components.json | 16 + components/cart/add-to-cart.tsx | 6 +- components/cart/close-cart.tsx | 4 +- components/cart/delete-item-button.tsx | 5 +- components/cart/edit-item-quantity-button.tsx | 4 +- components/cart/modal.tsx | 261 ++++---- components/cart/open-cart.tsx | 13 +- .../dynamic-content-manager.tsx | 4 +- components/layout/footer/copyright.tsx | 2 + components/layout/footer/footer.tsx | 64 +- components/layout/header/header.tsx | 27 +- components/layout/header/mobile-modal.tsx | 26 + components/{ui => }/loading-dots.tsx | 0 components/modules/carousel/carousel.tsx | 45 +- components/preview-suspense.tsx | 4 + components/product/add-to-cart.tsx | 2 +- .../dropdown.tsx => dropdown-menu.tsx} | 123 ++-- .../ui/locale-switcher/locale-switcher.tsx | 56 +- components/ui/navigation-menu/index.ts | 2 - .../ui/navigation-menu/navigation-menu.tsx | 123 ---- components/ui/sheet.tsx | 122 ++++ components/ui/text/text.tsx | 2 +- lib/constants.ts | 30 + lib/sanity/queries.tsx | 20 + lib/shopify/index.ts | 100 +++- lib/shopify/queries/collection.ts | 8 +- lib/shopify/types.ts | 2 + lib/utils.ts | 12 +- messages/en.json | 3 +- messages/sv.json | 3 +- next.config.js | 1 + package.json | 9 +- pnpm-lock.yaml | 561 ++++++++++++++---- tailwind.config.js | 48 +- tsconfig.json | 7 +- 39 files changed, 1259 insertions(+), 594 deletions(-) create mode 100644 components.json create mode 100644 components/layout/header/mobile-modal.tsx rename components/{ui => }/loading-dots.tsx (100%) create mode 100644 components/preview-suspense.tsx rename components/ui/{dropdown/dropdown.tsx => dropdown-menu.tsx} (58%) delete mode 100644 components/ui/navigation-menu/index.ts delete mode 100644 components/ui/navigation-menu/navigation-menu.tsx create mode 100644 components/ui/sheet.tsx create mode 100644 lib/constants.ts diff --git a/.env.example b/.env.example index 9ac741a18..3f31f2612 100644 --- a/.env.example +++ b/.env.example @@ -16,6 +16,16 @@ VERCEL_GIT_COMMIT_AUTHOR_LOGIN="" VERCEL_GIT_COMMIT_AUTHOR_NAME="" VERCEL_GIT_PULL_REQUEST_ID="" +# Sanity +NEXT_PUBLIC_SANITY_PROJECT_ID="" +NEXT_PUBLIC_SANITY_DATASET="" +NEXT_PUBLIC_SANITY_API_VERSION="" + +# Preview +SANITY_API_READ_TOKEN="" +SANITY_WEBHOOK_SECRET="" + +# Site TWITTER_CREATOR="@kodamera" TWITTER_SITE="https://kodamera.se" SITE_NAME="KM Storefront" diff --git a/app/[locale]/globals.css b/app/[locale]/globals.css index d66461eab..2d7943a69 100644 --- a/app/[locale]/globals.css +++ b/app/[locale]/globals.css @@ -2,9 +2,76 @@ @tailwind components; @tailwind utilities; -@supports (font: -apple-system-body) and (-webkit-appearance: none) { - img[loading='lazy'] { - clip-path: inset(0.6px); +@layer base { + :root { + --background: 0 0% 100%; + --foreground: 0 0% 3.9%; + + --card: 0 0% 100%; + --card-foreground: 0 0% 3.9%; + + --popover: 0 0% 100%; + --popover-foreground: 0 0% 3.9%; + + --primary: 0 0% 9%; + --primary-foreground: 0 0% 98%; + + --secondary: 0 0% 96.1%; + --secondary-foreground: 0 0% 9%; + + --muted: 0 0% 96.1%; + --muted-foreground: 0 0% 45.1%; + + --accent: 0 0% 96.1%; + --accent-foreground: 0 0% 9%; + + --destructive: 0 84.2% 60.2%; + --destructive-foreground: 0 0% 98%; + + --border: 0 0% 89.8%; + --input: 0 0% 89.8%; + --ring: 0 0% 3.9%; + + --radius: 0.5rem; + } + + .dark { + --background: 0 0% 3.9%; + --foreground: 0 0% 98%; + + --card: 0 0% 3.9%; + --card-foreground: 0 0% 98%; + + --popover: 0 0% 3.9%; + --popover-foreground: 0 0% 98%; + + --primary: 0 0% 98%; + --primary-foreground: 0 0% 9%; + + --secondary: 0 0% 14.9%; + --secondary-foreground: 0 0% 98%; + + --muted: 0 0% 14.9%; + --muted-foreground: 0 0% 63.9%; + + --accent: 0 0% 14.9%; + --accent-foreground: 0 0% 98%; + + --destructive: 0 62.8% 30.6%; + --destructive-foreground: 0 0% 98%; + + --border: 0 0% 14.9%; + --input: 0 0% 14.9%; + --ring: 0 0% 83.1%; + } +} + +@layer base { + * { + @apply border-border; + } + body { + @apply bg-background text-foreground; } } @@ -28,7 +95,7 @@ html, body { - @apply font-sans h-full bg-white text-high-contrast; + @apply h-full bg-white font-sans text-high-contrast; box-sizing: border-box; touch-action: manipulation; @@ -74,11 +141,11 @@ body { } .glider-dots { - @apply flex !space-x-[2px] !mt-8; + @apply !mt-8 flex !space-x-[2px]; } .glider-dot { - @apply !m-0 !rounded-none !w-12 !h-4 !bg-transparent after:content-[''] after:block after:w-12 after:h-[3px] after:bg-ui-border 2xl:!w-16 2xl:after:w-16; + @apply !m-0 !h-4 !w-12 !rounded-none !bg-transparent after:block after:h-[3px] after:w-12 after:bg-ui-border after:content-[''] 2xl:!w-16 2xl:after:w-16; } .glider-dot.active { @@ -86,17 +153,17 @@ body { } .glider-prev { - @apply text-high-contrast !right-12 !-top-10 !left-auto lg:!right-16 lg:!-top-12 2xl:!-top-16 2xl:!right-[100px] !transition-transform !duration-100 hover:!text-high-contrast hover:scale-110; + @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]; } .glider-next { - @apply text-high-contrast !right-4 !-top-10 lg:!right-8 lg:!-top-12 2xl:!-top-16 2xl:!right-16 !transition-transform !duration-100 hover:!text-high-contrast hover:scale-110; + @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; } .pdp .glider-prev { - @apply text-high-contrast absolute !left-4 !top-1/2 !transition-transform !duration-100 hover:!text-high-contrast hover:scale-100 lg:hidden; + @apply absolute !left-4 !top-1/2 text-high-contrast !transition-transform !duration-100 hover:scale-100 hover:!text-high-contrast lg:hidden; } .pdp .glider-next { - @apply text-high-contrast absolute !right-4 !top-1/2 !transition-transform !duration-100 hover:!text-high-contrast hover:scale-100 lg:hidden; -} \ No newline at end of file + @apply absolute !right-4 !top-1/2 text-high-contrast !transition-transform !duration-100 hover:scale-100 hover:!text-high-contrast lg:hidden; +} diff --git a/app/[locale]/layout.tsx b/app/[locale]/layout.tsx index e8999055b..0546880c4 100644 --- a/app/[locale]/layout.tsx +++ b/app/[locale]/layout.tsx @@ -1,9 +1,10 @@ import Footer from 'components/layout/footer/footer'; import Header from 'components/layout/header/header'; -import { useLocale } from 'next-intl'; +import { NextIntlClientProvider } from 'next-intl'; import { Inter } from 'next/font/google'; import { notFound } from 'next/navigation'; import { ReactNode } from 'react'; +import { supportedLanguages } from '../../i18n-config'; import './globals.css'; export const metadata = { @@ -32,30 +33,34 @@ const inter = Inter({ variable: '--font-inter' }); -// export function generateStaticParams() { -// return supportedLanguages.locales.map((locale) => ({ locale: locale.id })); -// } +export function generateStaticParams() { + return supportedLanguages.locales.map((locale) => ({ locale: locale.id })); +} -export default function LocaleLayout({ - children, - params -}: { +interface LocaleLayoutProps { children: ReactNode; - params: { locale: string }; -}) { - const locale = useLocale(); + params: { + locale: string; + }; +} - // Show a 404 error if the user requests an unknown locale - if (params.locale !== locale) { +export default async function LocaleLayout({ children, params: { locale } }: LocaleLayoutProps) { + let messages; + + try { + messages = (await import(`../../messages/${locale}.json`)).default; + } catch (error) { notFound(); } return ( -
-
{children}
-