@@ -4,74 +4,85 @@ import { SYSTEM } from '../internal/environment';
44import { ContainerProps } from './interfaces' ;
55
66export function getRootStyles ( style : ContainerProps . Style | undefined ) {
7- let properties = { } ;
8-
9- if ( SYSTEM === 'core' && style ?. root ) {
10- properties = {
11- background : style . root ?. background ,
12- borderColor : style . root ?. borderColor ,
13- borderRadius : style . root ?. borderRadius ,
14- borderWidth : style . root ?. borderWidth ,
15- boxShadow : style . root ?. boxShadow ,
16- } ;
7+ if ( SYSTEM !== 'core' ) {
8+ return { } ;
179 }
1810
19- return properties ;
11+ const properties = {
12+ background : style ?. root ?. background ,
13+ borderColor : style ?. root ?. borderColor ,
14+ borderRadius : style ?. root ?. borderRadius ,
15+ borderWidth : style ?. root ?. borderWidth ,
16+ boxShadow : style ?. root ?. boxShadow ,
17+ } ;
18+
19+ return Object . fromEntries ( Object . entries ( properties ) . filter ( ( [ , value ] ) => value !== undefined ) ) ;
2020}
2121
2222export function getContentStyles ( style : ContainerProps . Style | undefined ) {
23- let properties = { } ;
23+ if ( SYSTEM !== 'core' ) {
24+ return { } ;
25+ }
26+
27+ const properties = {
28+ paddingBlock : style ?. content ?. paddingBlock ,
29+ paddingInline : style ?. content ?. paddingInline ,
30+ } ;
31+
32+ return Object . fromEntries ( Object . entries ( properties ) . filter ( ( [ , value ] ) => value !== undefined ) ) ;
33+ }
2434
25- if ( SYSTEM === 'core' && style ?. content ) {
26- properties = {
27- paddingBlock : style . content ?. paddingBlock ,
28- paddingInline : style . content ?. paddingInline ,
29- } ;
35+ export function getContentWrapperStyles ( style : ContainerProps . Style | undefined ) {
36+ if ( SYSTEM !== 'core' ) {
37+ return { } ;
3038 }
3139
32- return properties ;
40+ const properties = {
41+ borderRadius : style ?. root ?. borderRadius ,
42+ } ;
43+
44+ return Object . fromEntries ( Object . entries ( properties ) . filter ( ( [ , value ] ) => value !== undefined ) ) ;
3345}
3446
3547export function getHeaderStyles ( style : ContainerProps . Style | undefined ) {
36- let properties = { } ;
37-
38- if ( SYSTEM === 'core' && style ?. header ) {
39- properties = {
40- ...( style ?. root ?. background && { background : style ?. root ?. background } ) ,
41- ...( style ?. root ?. borderRadius && { background : style ?. root ?. borderRadius } ) ,
42- paddingBlock : style . header ?. paddingBlock ,
43- paddingInline : style . header ?. paddingInline ,
44- } ;
48+ if ( SYSTEM !== 'core' ) {
49+ return { } ;
4550 }
4651
47- return properties ;
52+ const properties = {
53+ background : style ?. root ?. background ,
54+ paddingBlock : style ?. header ?. paddingBlock ,
55+ paddingInline : style ?. header ?. paddingInline ,
56+ } ;
57+
58+ return Object . fromEntries ( Object . entries ( properties ) . filter ( ( [ , value ] ) => value !== undefined ) ) ;
4859}
4960
5061export function getFooterStyles ( style : ContainerProps . Style | undefined ) {
51- let properties = { } ;
52-
53- if ( SYSTEM === 'core' && style ?. footer ) {
54- properties = {
55- borderColor : style . footer ?. divider ?. borderColor ,
56- borderWidth : style . footer ?. divider ?. borderWidth ,
57- paddingBlock : style . footer ?. root ?. paddingBlock ,
58- paddingInline : style . footer ?. root ?. paddingInline ,
59- } ;
62+ if ( SYSTEM !== 'core' ) {
63+ return { } ;
6064 }
6165
62- return properties ;
66+ const properties = {
67+ borderColor : style ?. footer ?. divider ?. borderColor ,
68+ borderWidth : style ?. footer ?. divider ?. borderWidth ,
69+ paddingBlock : style ?. footer ?. root ?. paddingBlock ,
70+ paddingInline : style ?. footer ?. root ?. paddingInline ,
71+ } ;
72+
73+ return Object . fromEntries ( Object . entries ( properties ) . filter ( ( [ , value ] ) => value !== undefined ) ) ;
6374}
6475
6576export function getMediaStyles ( mediaPosition : string , style : ContainerProps . Style | undefined ) {
66- let properties = { } ;
67-
68- if ( SYSTEM === 'core' && style ?. root ?. borderRadius ) {
69- properties = {
70- borderRadius : style ?. root ?. borderRadius ,
71- ...( mediaPosition === 'top' && { borderEndStartRadius : '0px' , borderEndEndRadius : '0px' } ) ,
72- ...( mediaPosition === 'side' && { borderStartEndRadius : '0px' , borderEndEndRadius : '0px' } ) ,
73- } ;
77+ if ( SYSTEM !== 'core' ) {
78+ return { } ;
7479 }
7580
76- return properties ;
81+ const properties = {
82+ borderRadius : style ?. root ?. borderRadius ,
83+ ...( mediaPosition === 'top' && { borderEndStartRadius : '0px' , borderEndEndRadius : '0px' } ) ,
84+ ...( mediaPosition === 'side' && { borderStartEndRadius : '0px' , borderEndEndRadius : '0px' } ) ,
85+ } ;
86+
87+ return Object . fromEntries ( Object . entries ( properties ) . filter ( ( [ , value ] ) => value !== undefined ) ) ;
7788}
0 commit comments