-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into update-address-forms-layout
- Loading branch information
Showing
26 changed files
with
251 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@bigcommerce/catalyst-core": patch | ||
--- | ||
|
||
Add store selector page. |
24 changes: 24 additions & 0 deletions
24
core/app/[locale]/store-selector/_components/locale-link.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Link } from '~/components/link'; | ||
import { localeLanguageRegionMap, LocaleType } from '~/i18n'; | ||
import { cn } from '~/lib/utils'; | ||
|
||
export const LocaleLink = ({ locale, selected }: { locale: LocaleType; selected: boolean }) => { | ||
return ( | ||
<Link | ||
className={cn( | ||
'border border-gray-200 px-3 py-2 text-xs hover:bg-gray-100 hover:text-black', | ||
selected && 'border-black', | ||
)} | ||
href="/" | ||
locale={locale} | ||
> | ||
<div className="flex h-full items-center gap-2"> | ||
<div className="text-2xl">{localeLanguageRegionMap[locale].flag}</div> | ||
<div className="flex flex-col gap-1"> | ||
<span className="font-bold">{localeLanguageRegionMap[locale].language}</span> | ||
<span>{localeLanguageRegionMap[locale].region}</span> | ||
</div> | ||
</div> | ||
</Link> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { getTranslations, unstable_setRequestLocale } from 'next-intl/server'; | ||
|
||
import { client } from '~/client'; | ||
import { graphql } from '~/client/graphql'; | ||
import { Link } from '~/components/link'; | ||
import { StoreLogo, StoreLogoFragment } from '~/components/store-logo'; | ||
import { NavigationMenu, NavigationMenuLink } from '~/components/ui/navigation-menu'; | ||
import { locales, LocaleType } from '~/i18n'; | ||
|
||
import { LocaleLink } from './_components/locale-link'; | ||
|
||
export const metadata = { | ||
title: 'Location selector', | ||
}; | ||
|
||
const StoreSelectorPageQuery = graphql( | ||
` | ||
query LocationSelectorPageQuery { | ||
site { | ||
settings { | ||
...StoreLogoFragment | ||
} | ||
} | ||
} | ||
`, | ||
[StoreLogoFragment], | ||
); | ||
|
||
export default async function StoreSelector({ | ||
params: { locale: selectedLocale }, | ||
}: { | ||
params: { locale: LocaleType }; | ||
}) { | ||
unstable_setRequestLocale(selectedLocale); | ||
|
||
const t = await getTranslations('StoreSelector'); | ||
|
||
const { data } = await client.fetch({ | ||
document: StoreSelectorPageQuery, | ||
}); | ||
|
||
const storeSettings = data.site.settings; | ||
|
||
return ( | ||
<> | ||
<header> | ||
<NavigationMenu> | ||
<NavigationMenuLink asChild> | ||
{storeSettings && ( | ||
<Link className="p-0" href="/"> | ||
<StoreLogo data={storeSettings} /> | ||
</Link> | ||
)} | ||
</NavigationMenuLink> | ||
</NavigationMenu> | ||
</header> | ||
|
||
<div className="flex flex-col gap-2 px-4 lg:container sm:px-10 lg:mx-auto lg:max-w-[1000px] lg:px-12"> | ||
<h1 className="text-3xl font-black lg:text-4xl">{t('heading')}</h1> | ||
|
||
<div className="grid grid-cols-1 gap-6 py-6 md:grid-cols-3 md:gap-11 lg:grid-cols-4 lg:gap-8"> | ||
{locales.map((locale) => ( | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
<LocaleLink key={locale} locale={locale} selected={selectedLocale === locale} /> | ||
))} | ||
</div> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
export function generateStaticParams() { | ||
return locales.map((locale) => ({ locale })); | ||
} | ||
|
||
export const dynamic = 'force-static'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { getLocale } from 'next-intl/server'; | ||
|
||
import { localeLanguageRegionMap, locales, LocaleType } from '~/i18n'; | ||
|
||
import { Link } from '../link'; | ||
|
||
export const Locale = async () => { | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
const locale = (await getLocale()) as LocaleType; | ||
|
||
return ( | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
locales.length > 1 && ( | ||
<Link className="flex gap-2" href="/store-selector"> | ||
<span>{localeLanguageRegionMap[locale].flag}</span> | ||
<span>{localeLanguageRegionMap[locale].region}</span> | ||
</Link> | ||
) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.