Skip to content

Commit c8e0ca6

Browse files
committed
docs: michael changes
1 parent 0bb7ecc commit c8e0ca6

File tree

1 file changed

+116
-19
lines changed
  • docs/content/guides/7.multistore/3.patterns/5.subpath

1 file changed

+116
-19
lines changed

Diff for: docs/content/guides/7.multistore/3.patterns/5.subpath/1.subpath.md

+116-19
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ This section provides a brief overview of setting up Config Switcher. For comple
5252

5353
| **File-Based Inheritance** | **Config Switcher** |
5454
| --------------------------------------- | ---------------------------------------------------------------- |
55-
| Works **between different stores** | Works **within a single store** |
5655
| Creates separate deployable instances | Uses a single deployable instance |
5756
| Full codebase customization | Only middleware configuration changes, Storefront code is shared |
5857
| Requires separate builds for each store | Single build supports multiple configurations |
@@ -340,9 +339,13 @@ Make sure that all your internal links and navigation components preserve the st
340339

341340
Without this, users might unexpectedly switch between stores while browsing your site.
342341

343-
## Applying Store-Specific Styling
342+
## Store-Specific Styling
344343

345-
Now that you have CSS variables defined for each store, you need to apply the store identifier as a CSS class to enable the different styles.
344+
There are two key steps to implement store-specific styling:
345+
346+
### 1. Applying Store Identifier Class
347+
348+
First, you need to apply the store identifier as a CSS class to enable different styles for each store:
346349

347350
::tabs{:titles='["Next.js", "Nuxt"]'}
348351

@@ -386,9 +389,96 @@ const route = useRoute();
386389
```
387390
::
388391

389-
## Styling Components for Different Stores
392+
### 2. Defining Store-Specific CSS Variables
390393

391-
With the store identifier applied as a class, you can now customize components with store-specific styles. You'll need to update your Tailwind configuration to support this.
394+
Once the store identifier class is applied, you can define CSS variables that change based on the store:
395+
396+
::tabs{:titles='["Next.js", "Nuxt"]'}
397+
398+
#tab-1
399+
In your Next.js app, add custom CSS variables in your global styles:
400+
401+
```scss
402+
// apps/storefront-unified-nextjs/app/[locale]/globals.scss
403+
@tailwind base;
404+
@tailwind components;
405+
@tailwind utilities;
406+
407+
// Base styles...
408+
409+
// Electronics store theme
410+
.electronics {
411+
--colors-primary-50: 45 249 255;
412+
--colors-primary-100: 233 243 255;
413+
--colors-primary-200: 200 224 255;
414+
--colors-primary-300: 166 204 255;
415+
--colors-primary-400: 110 161 255;
416+
--colors-primary-500: 51 117 255;
417+
--colors-primary-600: 46 106 230;
418+
--colors-primary-700: 38 78 191;
419+
--colors-primary-800: 29 63 153;
420+
--colors-primary-900: 176 196 244;
421+
}
422+
423+
// Apparel store theme (different color scheme)
424+
.apparel {
425+
--colors-primary-50: 243 254 249;
426+
--colors-primary-100: 224 247 235;
427+
--colors-primary-200: 187 235 210;
428+
--colors-primary-300: 135 216 177;
429+
--colors-primary-400: 77 192 140;
430+
--colors-primary-500: 45 165 116;
431+
--colors-primary-600: 34 134 95;
432+
--colors-primary-700: 31 110 80;
433+
--colors-primary-800: 30 86 65;
434+
--colors-primary-900: 23 64 49;
435+
}
436+
```
437+
438+
#tab-2
439+
In your Nuxt app, add custom CSS variables in your style.scss:
440+
441+
```scss
442+
// apps/storefront-unified-nuxt/assets/style.scss
443+
@tailwind base;
444+
@tailwind components;
445+
@tailwind utilities;
446+
447+
// Base styles...
448+
449+
// Electronics store theme
450+
.electronics {
451+
--colors-primary-50: 45 249 255;
452+
--colors-primary-100: 233 243 255;
453+
--colors-primary-200: 200 224 255;
454+
--colors-primary-300: 166 204 255;
455+
--colors-primary-400: 110 161 255;
456+
--colors-primary-500: 51 117 255;
457+
--colors-primary-600: 46 106 230;
458+
--colors-primary-700: 38 78 191;
459+
--colors-primary-800: 29 63 153;
460+
--colors-primary-900: 176 196 244;
461+
}
462+
463+
// Apparel store theme (different color scheme)
464+
.apparel {
465+
--colors-primary-50: 243 254 249;
466+
--colors-primary-100: 224 247 235;
467+
--colors-primary-200: 187 235 210;
468+
--colors-primary-300: 135 216 177;
469+
--colors-primary-400: 77 192 140;
470+
--colors-primary-500: 45 165 116;
471+
--colors-primary-600: 34 134 95;
472+
--colors-primary-700: 31 110 80;
473+
--colors-primary-800: 30 86 65;
474+
--colors-primary-900: 23 64 49;
475+
}
476+
```
477+
::
478+
479+
### 3. Using Store-Specific Styles
480+
481+
Now you can use these variables in your components through Tailwind's configuration:
392482

393483
::tabs{:titles='["Next.js", "Nuxt"]'}
394484

@@ -417,20 +507,22 @@ const config: Config = {
417507
export default config;
418508
```
419509

420-
Then use these variants (`electronics:`, `apparel:` etc.) in your components:
510+
Then use these variants in your components:
421511

422512
```tsx
423-
// apps/storefront-unified-nextjs/components/navigations/navbar-top.tsx
424-
export default function NavbarTop({ children, className, filled }: NavbarTopProps) {
513+
// apps/storefront-unified-nextjs/components/ui/navbar-top.tsx
514+
export default function NavbarTop({ children, className }: NavbarTopProps) {
425515
return (
426516
<header
427517
className={classNames(
428-
'sticky top-0 z-40 flex h-14 bg-primary-800 electronics:!bg-primary-600 apparel:!bg-primary-400 md:-top-5 md:h-20 md:pt-2.5',
429-
// other classes...
518+
'sticky top-0 z-40 flex h-14 bg-primary-800',
519+
'electronics:!bg-primary-600',
520+
'apparel:!bg-primary-400',
521+
'md:-top-5 md:h-20 md:pt-2.5',
522+
className
430523
)}
431-
data-testid="navbar-top"
432524
>
433-
{/* Component content */}
525+
{children}
434526
</header>
435527
);
436528
}
@@ -459,25 +551,30 @@ export default {
459551
} as Config;
460552
```
461553

462-
Then use these variants (`electronics:`, `apparel:` etc.) in your components:
554+
Then use these variants in your components:
463555

464556
```vue
465-
// apps/storefront-unified-nuxt/components/ui/NavbarTop/NavbarTop.vue
557+
<!-- apps/storefront-unified-nuxt/components/ui/NavbarTop.vue -->
466558
<template>
467559
<header
468560
:class="[
469-
'h-14 md:h-20 flex z-40 sticky top-0 md:-top-5 md:pt-2.5 md:shadow-md',
470-
{ 'bg-primary-700 electronics:bg-primary-500 apparel:bg-primary-300 text-white': filled },
471-
// other classes...
561+
'sticky top-0 z-40 flex h-14',
562+
'bg-primary-800',
563+
'electronics:!bg-primary-600',
564+
'apparel:!bg-primary-400',
565+
'md:-top-5 md:h-20 md:pt-2.5',
472566
]"
473-
data-testid="navbar-top"
474567
>
475-
<!-- Component content -->
568+
<slot />
476569
</header>
477570
</template>
478571
```
479572
::
480573

574+
::tip Using CSS Variables with Tailwind
575+
The CSS variables we defined can be used with Tailwind's color system. For example, `bg-primary-500` will use the store-specific primary color defined in the CSS variables. For more information, see the [Tailwind CSS documentation](https://v3.tailwindcss.com/docs/customizing-colors#using-css-variables).
576+
::
577+
481578
## Conditional Components
482579

483580
There are two main approaches to handling store-specific components:

0 commit comments

Comments
 (0)