@@ -20,24 +20,56 @@ const calcSpaceValue = (space: NumericSpace | FlexSpace) => {
2020 }
2121} ;
2222
23- const calcInlineVars = ( space : FlexSpace | ByBreakpoint < NumericSpace > ) => {
24- if ( typeof space === 'number' || typeof space === 'string' ) {
25- return {
26- [ styles . vars . space ] : calcSpaceValue ( space ) ,
23+ const calcInlineVars = (
24+ space : FlexSpace | ByBreakpoint < NumericSpace > ,
25+ verticalSpace ?: ByBreakpoint < NumericSpace >
26+ ) => {
27+ const calcSpaceVars = (
28+ space : FlexSpace | ByBreakpoint < NumericSpace > ,
29+ varNames : { default : string ; mobile : string ; tablet : string ; desktop : string }
30+ ) => {
31+ if ( typeof space === 'number' || typeof space === 'string' ) {
32+ return {
33+ [ varNames . default ] : calcSpaceValue ( space ) ,
34+ } ;
35+ }
36+ const vars = {
37+ [ varNames . mobile ] : calcSpaceValue ( space . mobile ) ,
38+ [ varNames . desktop ] : calcSpaceValue ( space . desktop ) ,
2739 } ;
28- }
29- const vars = {
30- [ styles . vars . spaceMobile ] : calcSpaceValue ( space . mobile ) ,
31- [ styles . vars . spaceDesktop ] : calcSpaceValue ( space . desktop ) ,
40+ if ( space . tablet ) {
41+ vars [ varNames . tablet ] = calcSpaceValue ( space . tablet ) ;
42+ }
43+ return vars ;
3244 } ;
33- if ( space . tablet ) {
34- vars [ styles . vars . spaceTablet ] = calcSpaceValue ( space . tablet ) ;
45+
46+ const spaceVars = calcSpaceVars ( space , {
47+ default : styles . vars . space ,
48+ mobile : styles . vars . spaceMobile ,
49+ tablet : styles . vars . spaceTablet ,
50+ desktop : styles . vars . spaceDesktop ,
51+ } ) ;
52+
53+ if ( verticalSpace ) {
54+ const verticalSpaceVars = calcSpaceVars ( verticalSpace , {
55+ default : styles . vars . verticalSpace ,
56+ mobile : styles . vars . verticalSpaceMobile ,
57+ tablet : styles . vars . verticalSpaceTablet ,
58+ desktop : styles . vars . verticalSpaceDesktop ,
59+ } ) ;
60+
61+ return {
62+ ...spaceVars ,
63+ ...verticalSpaceVars ,
64+ } ;
3565 }
36- return vars ;
66+
67+ return spaceVars ;
3768} ;
3869
3970type Props = {
4071 space : FlexSpace | ByBreakpoint < NumericSpace > ;
72+ verticalSpace ?: ByBreakpoint < NumericSpace > ;
4173 alignItems ?: 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline' ;
4274 children : React . ReactNode ;
4375 className ?: string ;
@@ -51,6 +83,7 @@ type Props = {
5183
5284const Inline = ( {
5385 space,
86+ verticalSpace,
5487 className,
5588 children,
5689 role,
@@ -72,7 +105,7 @@ const Inline = ({
72105 wrap ? styles . wrap : fullWidth ? styles . fullWidth : styles . noFullWidth ,
73106 isStringSpace ? ( wrap ? styles . stringSpaceWithWrap : styles . stringSpace ) : styles . marginInline
74107 ) }
75- style = { { ...applyCssVars ( calcInlineVars ( space ) ) , alignItems} }
108+ style = { { ...applyCssVars ( calcInlineVars ( space , verticalSpace ) ) , alignItems} }
76109 role = { role }
77110 aria-label = { ariaLabel }
78111 aria-labelledby = { ariaLabel ? undefined : ariaLabelledBy }
0 commit comments