Skip to content

Commit bed7d47

Browse files
committed
docs: update optional props
1 parent c88cfd5 commit bed7d47

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

docs/content/guides/6.multistore/3.patterns/2.design/4.different-code-per-store.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ The `DecoratedPrice` requires a new prop `customText`, exclusively for `store-b`
186186
187187
1. **Duplicate** the component for `store-b`.
188188
2. **Modify the props interface** to include the new prop.
189-
3. **Implement fallback behaviors** it's best to make new props as optional to ensure existing components using the old interface remain functional
189+
3. **Implement fallback behaviors** make new props as optional to ensure existing components using the old interface remain functional
190190
4. **Modify components usage** update props passed to the changed component in other parts of your store that are using it
191191
192192
#### In Next.js
@@ -443,7 +443,7 @@ This approach is particularly useful when you've identified that certain feature
443443
#### Example Workflow
444444
445445
1. **Remove** the specialized props from the parent store component
446-
2. **Add** the props only to the store specific component
446+
2. **Add** the props only to the store specific component. Use optional props to ensure compatibility with other stores
447447
3. **Update** implementations of the changed component in specific store
448448
449449
#### In Next.js
@@ -523,7 +523,7 @@ export interface ClassNameVariants {
523523
// Added prop to store-a
524524
export interface DecoratedPriceProps {
525525
className?: string;
526-
classNameVariants: ClassNameVariants; // [!code ++]
526+
classNameVariants?: ClassNameVariants; // [!code ++]
527527
price: SfProduct['price'];
528528
}
529529

@@ -538,7 +538,7 @@ export default function DecoratedPrice({ className, classNameVariants, price, ..
538538
price && (
539539
<div className={classNames('flex items-baseline gap-x-2', className)} {...rest}>
540540
<span
541-
className={classNames('font-semibold', classNameVariants.regular, { // [!code ++]
541+
className={classNames('font-semibold', classNameVariants?.regular, { // [!code ++]
542542
className={classNames('font-semibold', { // [!code --]
543543
'text-neutral-900': !special,
544544
'text-secondary-700': special,
@@ -550,7 +550,7 @@ export default function DecoratedPrice({ className, classNameVariants, price, ..
550550
{special && (
551551
<span
552552
className={classNames('font-normal text-neutral-500 line-through')} // [!code --]
553-
className={classNames('font-normal text-neutral-500 line-through', classNameVariants.special)} // [!code ++]
553+
className={classNames('font-normal text-neutral-500 line-through', classNameVariants?.special)} // [!code ++]
554554
data-testid="regular-price"
555555
>
556556
{special}
@@ -617,7 +617,7 @@ And add it to specific stores that need it:
617617
data-testid="special-price"
618618
:class="[
619619
'font-semibold',
620-
classNameVariants.regular, // [!code ++]
620+
classNameVariants?.regular, // [!code ++]
621621
{
622622
'text-neutral-900': !special,
623623
'text-secondary-700': special,
@@ -630,7 +630,7 @@ And add it to specific stores that need it:
630630
v-if="special"
631631
data-testid="regular-price"
632632
:class="['font-normal text-neutral-500 line-through']" // [!code --]
633-
:class="['font-normal text-neutral-500 line-through', classNameVariants.special]" // [!code ++]
633+
:class="['font-normal text-neutral-500 line-through', classNameVariants?.special]" // [!code ++]
634634
>
635635
{{ special }}
636636
</span>
@@ -641,7 +641,7 @@ And add it to specific stores that need it:
641641
// Prop is added to the store-a component
642642
defineProps<{
643643
className?: string;
644-
classNameVariants: ClassNameVariants; // [!code ++]
644+
classNameVariants?: ClassNameVariants; // [!code ++]
645645
regular: string;
646646
special?: string;
647647
}>();
@@ -679,4 +679,4 @@ While introducing breaking changes, follow these strategies to ensure stability:
679679
680680
## Conclusion
681681
682-
Customizing individual components in a **multibrand setup** can effectively address brand-specific requirements while maintaining maintainable code. Follow these steps to confidently adjust component markups while avoiding breaking changes whenever possible.
682+
Customizing individual components in a **multibrand setup** can effectively address brand-specific requirements while keeping the code maintainable. Follow these steps to confidently adjust component markups while avoiding breaking changes whenever possible.

0 commit comments

Comments
 (0)