@@ -385,14 +385,35 @@ export const Navigation = forwardRef(function Navigation<S extends SearchResult>
385
385
) )
386
386
}
387
387
</ Stream >
388
- { /* Locale / Language Dropdown */ }
389
- { locales && locales . length > 1 ? (
390
- < LocaleSwitcher
391
- activeLocaleId = { activeLocaleId }
392
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
393
- locales = { locales as [ Locale , Locale , ...Locale [ ] ] }
394
- />
395
- ) : null }
388
+ < div className = "p-2 @4xl:p-5" >
389
+ < div className = "flex items-center px-3 py-1 @4xl:py-2" >
390
+ { /* Locale / Language Dropdown */ }
391
+ { locales && locales . length > 1 ? (
392
+ < LocaleSwitcher
393
+ activeLocaleId = { activeLocaleId }
394
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
395
+ locales = { locales as [ Locale , Locale , ...Locale [ ] ] }
396
+ />
397
+ ) : null }
398
+
399
+ { /* Currency Dropdown */ }
400
+ < Stream
401
+ fallback = { null }
402
+ value = { Streamable . all ( [ streamableCurrencies , streamableActiveCurrencyId ] ) }
403
+ >
404
+ { ( [ currencies , activeCurrencyId ] ) =>
405
+ currencies && currencies . length > 1 && currencyAction ? (
406
+ < CurrencyForm
407
+ action = { currencyAction }
408
+ activeCurrencyId = { activeCurrencyId }
409
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
410
+ currencies = { currencies as [ Currency , ...Currency [ ] ] }
411
+ />
412
+ ) : null
413
+ }
414
+ </ Stream >
415
+ </ div >
416
+ </ div >
396
417
</ div >
397
418
</ Popover . Content >
398
419
</ Popover . Portal >
@@ -573,6 +594,7 @@ export const Navigation = forwardRef(function Navigation<S extends SearchResult>
573
594
{ locales && locales . length > 1 ? (
574
595
< LocaleSwitcher
575
596
activeLocaleId = { activeLocaleId }
597
+ className = "hidden @4xl:block"
576
598
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
577
599
locales = { locales as [ Locale , Locale , ...Locale [ ] ] }
578
600
/>
@@ -588,6 +610,7 @@ export const Navigation = forwardRef(function Navigation<S extends SearchResult>
588
610
< CurrencyForm
589
611
action = { currencyAction }
590
612
activeCurrencyId = { activeCurrencyId }
613
+ className = "hidden @4xl:block"
591
614
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
592
615
currencies = { currencies as [ Currency , ...Currency [ ] ] }
593
616
/>
@@ -855,61 +878,67 @@ const useSwitchLocale = () => {
855
878
function LocaleSwitcher ( {
856
879
locales,
857
880
activeLocaleId,
881
+ className,
858
882
} : {
859
883
activeLocaleId ?: string ;
860
884
locales : [ Locale , ...Locale [ ] ] ;
885
+ className ?: string ;
861
886
} ) {
862
887
const activeLocale = locales . find ( ( locale ) => locale . id === activeLocaleId ) ;
863
888
const [ isPending , startTransition ] = useTransition ( ) ;
864
889
const switchLocale = useSwitchLocale ( ) ;
865
890
866
891
return (
867
- < DropdownMenu . Root >
868
- < DropdownMenu . Trigger
869
- className = { clsx (
870
- 'flex items-center gap-1 text-xs uppercase transition-opacity disabled:opacity-30' ,
871
- navButtonClassName ,
872
- ) }
873
- disabled = { isPending }
874
- >
875
- { activeLocale ?. id ?? locales [ 0 ] . id }
876
- < ChevronDown size = { 16 } strokeWidth = { 1.5 } />
877
- </ DropdownMenu . Trigger >
878
- < DropdownMenu . Portal >
879
- < DropdownMenu . Content
880
- align = "end"
881
- className = "z-50 max-h-80 overflow-y-scroll rounded-xl bg-[var(--nav-locale-background,hsl(var(--background)))] p-2 shadow-xl data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 @4xl:w-32 @4xl:rounded-2xl @4xl:p-2"
882
- sideOffset = { 16 }
892
+ < div className = { className } >
893
+ < DropdownMenu . Root >
894
+ < DropdownMenu . Trigger
895
+ className = { clsx (
896
+ 'flex items-center gap-1 text-xs uppercase transition-opacity disabled:opacity-30' ,
897
+ navButtonClassName ,
898
+ ) }
899
+ disabled = { isPending }
883
900
>
884
- { locales . map ( ( { id, label } ) => (
885
- < DropdownMenu . Item
886
- className = { clsx (
887
- 'cursor-default rounded-lg bg-[var(--nav-locale-link-background,transparent)] px-2.5 py-2 font-[family-name:var(--nav-locale-link-font-family,var(--font-family-body))] text-sm font-medium text-[var(--nav-locale-link-text,hsl(var(--contrast-400)))] outline-none ring-[var(--nav-focus,hsl(var(--primary)))] transition-colors hover:bg-[var(--nav-locale-link-background-hover,hsl(var(--contrast-100)))] hover:text-[var(--nav-locale-link-text-hover,hsl(var(--foreground)))]' ,
888
- {
889
- 'text-[var(--nav-locale-link-text-selected,hsl(var(--foreground)))]' :
890
- id === activeLocaleId ,
891
- } ,
892
- ) }
893
- key = { id }
894
- onSelect = { ( ) => startTransition ( ( ) => switchLocale ( id ) ) }
895
- >
896
- { label }
897
- </ DropdownMenu . Item >
898
- ) ) }
899
- </ DropdownMenu . Content >
900
- </ DropdownMenu . Portal >
901
- </ DropdownMenu . Root >
901
+ { activeLocale ?. id ?? locales [ 0 ] . id }
902
+ < ChevronDown size = { 16 } strokeWidth = { 1.5 } />
903
+ </ DropdownMenu . Trigger >
904
+ < DropdownMenu . Portal >
905
+ < DropdownMenu . Content
906
+ align = "end"
907
+ className = "z-50 max-h-80 overflow-y-scroll rounded-xl bg-[var(--nav-locale-background,hsl(var(--background)))] p-2 shadow-xl data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 @4xl:w-32 @4xl:rounded-2xl @4xl:p-2"
908
+ sideOffset = { 16 }
909
+ >
910
+ { locales . map ( ( { id, label } ) => (
911
+ < DropdownMenu . Item
912
+ className = { clsx (
913
+ 'cursor-default rounded-lg bg-[var(--nav-locale-link-background,transparent)] px-2.5 py-2 font-[family-name:var(--nav-locale-link-font-family,var(--font-family-body))] text-sm font-medium text-[var(--nav-locale-link-text,hsl(var(--contrast-400)))] outline-none ring-[var(--nav-focus,hsl(var(--primary)))] transition-colors hover:bg-[var(--nav-locale-link-background-hover,hsl(var(--contrast-100)))] hover:text-[var(--nav-locale-link-text-hover,hsl(var(--foreground)))]' ,
914
+ {
915
+ 'text-[var(--nav-locale-link-text-selected,hsl(var(--foreground)))]' :
916
+ id === activeLocaleId ,
917
+ } ,
918
+ ) }
919
+ key = { id }
920
+ onSelect = { ( ) => startTransition ( ( ) => switchLocale ( id ) ) }
921
+ >
922
+ { label }
923
+ </ DropdownMenu . Item >
924
+ ) ) }
925
+ </ DropdownMenu . Content >
926
+ </ DropdownMenu . Portal >
927
+ </ DropdownMenu . Root >
928
+ </ div >
902
929
) ;
903
930
}
904
931
905
932
function CurrencyForm ( {
906
933
action,
907
934
currencies,
908
935
activeCurrencyId,
936
+ className,
909
937
} : {
910
938
activeCurrencyId ?: string ;
911
939
action : CurrencyAction ;
912
940
currencies : [ Currency , ...Currency [ ] ] ;
941
+ className ?: string ;
913
942
} ) {
914
943
const router = useRouter ( ) ;
915
944
const [ isPending , startTransition ] = useTransition ( ) ;
@@ -922,52 +951,54 @@ function CurrencyForm({
922
951
} , [ lastResult ?. error ] ) ;
923
952
924
953
return (
925
- < DropdownMenu . Root >
926
- < DropdownMenu . Trigger
927
- className = { clsx (
928
- 'flex items-center gap-1 text-xs uppercase transition-opacity disabled:opacity-30' ,
929
- navButtonClassName ,
930
- ) }
931
- disabled = { isPending }
932
- >
933
- { activeCurrency ?. label ?? currencies [ 0 ] . label }
934
- < ChevronDown size = { 16 } strokeWidth = { 1.5 } />
935
- </ DropdownMenu . Trigger >
936
- < DropdownMenu . Portal >
937
- < DropdownMenu . Content
938
- align = "end"
939
- className = "z-50 max-h-80 overflow-y-scroll rounded-xl bg-[var(--nav-locale-background,hsl(var(--background)))] p-2 shadow-xl data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 @4xl:w-32 @4xl:rounded-2xl @4xl:p-2"
940
- sideOffset = { 16 }
954
+ < div className = { className } >
955
+ < DropdownMenu . Root >
956
+ < DropdownMenu . Trigger
957
+ className = { clsx (
958
+ 'flex items-center gap-1 text-xs uppercase transition-opacity disabled:opacity-30' ,
959
+ navButtonClassName ,
960
+ ) }
961
+ disabled = { isPending }
941
962
>
942
- { currencies . map ( ( currency ) => (
943
- < DropdownMenu . Item
944
- className = { clsx (
945
- 'cursor-default rounded-lg bg-[var(--nav-locale-link-background,transparent)] px-2.5 py-2 font-[family-name:var(--nav-locale-link-font-family,var(--font-family-body))] text-sm font-medium text-[var(--nav-locale-link-text,hsl(var(--contrast-400)))] outline-none ring-[var(--nav-focus,hsl(var(--primary)))] transition-colors hover:bg-[var(--nav-locale-link-background-hover,hsl(var(--contrast-100)))] hover:text-[var(--nav-locale-link-text-hover,hsl(var(--foreground)))]' ,
946
- {
947
- 'text-[var(--nav-locale-link-text-selected,hsl(var(--foreground)))]' :
948
- currency . id === activeCurrencyId ,
949
- } ,
950
- ) }
951
- key = { currency . id }
952
- onSelect = { ( ) => {
953
- // eslint-disable-next-line @typescript-eslint/require-await
954
- startTransition ( async ( ) => {
955
- const formData = new FormData ( ) ;
956
-
957
- formData . append ( 'id' , currency . id ) ;
958
- formAction ( formData ) ;
959
-
960
- // This is needed to refresh the Data Cache after the product has been added to the cart.
961
- // The cart id is not picked up after the first time the cart is created/updated.
962
- router . refresh ( ) ;
963
- } ) ;
964
- } }
965
- >
966
- { currency . label }
967
- </ DropdownMenu . Item >
968
- ) ) }
969
- </ DropdownMenu . Content >
970
- </ DropdownMenu . Portal >
971
- </ DropdownMenu . Root >
963
+ { activeCurrency ?. label ?? currencies [ 0 ] . label }
964
+ < ChevronDown size = { 16 } strokeWidth = { 1.5 } />
965
+ </ DropdownMenu . Trigger >
966
+ < DropdownMenu . Portal >
967
+ < DropdownMenu . Content
968
+ align = "end"
969
+ className = "z-50 max-h-80 overflow-y-scroll rounded-xl bg-[var(--nav-locale-background,hsl(var(--background)))] p-2 shadow-xl data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 @4xl:w-32 @4xl:rounded-2xl @4xl:p-2"
970
+ sideOffset = { 16 }
971
+ >
972
+ { currencies . map ( ( currency ) => (
973
+ < DropdownMenu . Item
974
+ className = { clsx (
975
+ 'cursor-default rounded-lg bg-[var(--nav-locale-link-background,transparent)] px-2.5 py-2 font-[family-name:var(--nav-locale-link-font-family,var(--font-family-body))] text-sm font-medium text-[var(--nav-locale-link-text,hsl(var(--contrast-400)))] outline-none ring-[var(--nav-focus,hsl(var(--primary)))] transition-colors hover:bg-[var(--nav-locale-link-background-hover,hsl(var(--contrast-100)))] hover:text-[var(--nav-locale-link-text-hover,hsl(var(--foreground)))]' ,
976
+ {
977
+ 'text-[var(--nav-locale-link-text-selected,hsl(var(--foreground)))]' :
978
+ currency . id === activeCurrencyId ,
979
+ } ,
980
+ ) }
981
+ key = { currency . id }
982
+ onSelect = { ( ) => {
983
+ // eslint-disable-next-line @typescript-eslint/require-await
984
+ startTransition ( async ( ) => {
985
+ const formData = new FormData ( ) ;
986
+
987
+ formData . append ( 'id' , currency . id ) ;
988
+ formAction ( formData ) ;
989
+
990
+ // This is needed to refresh the Data Cache after the product has been added to the cart.
991
+ // The cart id is not picked up after the first time the cart is created/updated.
992
+ router . refresh ( ) ;
993
+ } ) ;
994
+ } }
995
+ >
996
+ { currency . label }
997
+ </ DropdownMenu . Item >
998
+ ) ) }
999
+ </ DropdownMenu . Content >
1000
+ </ DropdownMenu . Portal >
1001
+ </ DropdownMenu . Root >
1002
+ </ div >
972
1003
) ;
973
1004
}
0 commit comments