@@ -3,58 +3,94 @@ import GridPropsType, { GridItemProps } from "./types";
33
44const Grid = styled . div < GridPropsType > `
55 display: grid;
6- ${ ( { templateColumns } ) => templateColumns && `grid-template-columns: ${ templateColumns . join ( " " ) } ;` }
7- ${ ( { templateRows } ) => templateRows && `grid-template-rows: ${ templateRows . join ( " " ) } ;` }
8- ${ ( { templateAreas } ) => templateAreas && `grid-template-areas: ${ templateAreas . map ( ( row ) => `"${ row } "` ) . join ( " " ) } ;` }
9- ${ ( { autoColumns } ) => autoColumns && `grid-auto-columns: ${ autoColumns } ;` }
10- ${ ( { autoRows } ) => autoRows && `grid-auto-rows: ${ autoRows } ;` }
11- ${ ( { autoFlow } ) => autoFlow && `grid-auto-flow: ${ autoFlow } ;` }
12- ${ ( { gap } ) =>
13- gap != null &&
14- ( typeof gap === "string" ? `gap: ${ gap } ;` : `row-gap: ${ gap . rowGap ?? "" } ; column-gap: ${ gap . columnGap ?? "" } ;` ) }
15- ${ ( { placeItems } ) =>
16- placeItems &&
17- ( typeof placeItems === "string"
18- ? `place-items: ${ placeItems } `
19- : `align-items: ${ placeItems . alignItems ?? "" } ; justify-items: ${ placeItems . justifyItems ?? "" } ;` ) }
20- ${ ( { placeContent } ) =>
21- placeContent &&
22- ( typeof placeContent === "string"
23- ? `place-content: ${ placeContent } `
24- : `align-content: ${ placeContent . alignContent ?? "" } ; justify-content: ${ placeContent . justifyContent ?? "" } ;` ) }
25-
26- ${ ( { areaName } ) => areaName && `grid-area: ${ areaName } ;` }
27- ${ ( { column } ) =>
28- column &&
29- `grid-column: ${
30- typeof column === "string" || typeof column === "number" ? column : `${ column . start } / ${ column . end } ;`
31- } ;`}
32- ${ ( { row } ) =>
33- row && `grid-row: ${ typeof row === "string" || typeof row === "number" ? row : `${ row . start } / ${ row . end } ;` } ;` }
34- ${ ( { placeSelf } ) =>
35- placeSelf &&
36- ( typeof placeSelf === "string"
37- ? `place-self: ${ placeSelf } `
38- : `align-self: ${ placeSelf . alignSelf ?? "" } ; justify-self: ${ placeSelf . justifySelf ?? "" } ;` ) }
6+ ${ ( props ) => `
7+ ${ props . templateColumns ? `grid-template-columns: ${ props . templateColumns . join ( " " ) } ;` : "" }
8+ ${ props . templateRows ? `grid-template-rows: ${ props . templateRows . join ( " " ) } ;` : "" }
9+ ${ props . templateAreas ? `grid-template-areas: ${ props . templateAreas . map ( ( row ) => `"${ row } "` ) . join ( " " ) } ;` : "" }
10+ ${ props . autoColumns ? `grid-auto-columns: ${ props . autoColumns } ;` : "" }
11+ ${ props . autoRows ? `grid-auto-rows: ${ props . autoRows } ;` : "" }
12+ ${ props . autoFlow ? `grid-auto-flow: ${ props . autoFlow } ;` : "" }
13+ ${ props . areaName ? `grid-area: ${ props . areaName } ;` : "" }
14+ ${
15+ props . gap != null
16+ ? typeof props . gap === "string"
17+ ? `gap: ${ props . gap } ;`
18+ : `row-gap: ${ props . gap . rowGap ?? "" } ; column-gap: ${ props . gap . columnGap ?? "" } ;`
19+ : ""
20+ }
21+ ${
22+ props . placeItems
23+ ? typeof props . placeItems === "string"
24+ ? `place-items: ${ props . placeItems } ;`
25+ : `align-items: ${ props . placeItems . alignItems ?? "" } ; justify-items: ${ props . placeItems . justifyItems ?? "" } ;`
26+ : ""
27+ }
28+ ${
29+ props . placeContent
30+ ? typeof props . placeContent === "string"
31+ ? `place-content: ${ props . placeContent } ;`
32+ : `align-content: ${ props . placeContent . alignContent ?? "" } ; justify-content: ${ props . placeContent . justifyContent ?? "" } ;`
33+ : ""
34+ }
35+ ${
36+ props . column
37+ ? `grid-column: ${
38+ typeof props . column === "string" || typeof props . column === "number"
39+ ? props . column
40+ : `${ props . column . start } / ${ props . column . end } ;`
41+ } ;`
42+ : ""
43+ }
44+ ${
45+ props . row
46+ ? `grid-row: ${
47+ typeof props . row === "string" || typeof props . row === "number"
48+ ? props . row
49+ : `${ props . row . start } / ${ props . row . end } ;`
50+ } ;`
51+ : ""
52+ }
53+ ${
54+ props . placeSelf
55+ ? typeof props . placeSelf === "string"
56+ ? `place-self: ${ props . placeSelf } ;`
57+ : `align-self: ${ props . placeSelf . alignSelf ?? "" } ; justify-self: ${ props . placeSelf . justifySelf ?? "" } ;`
58+ : ""
59+ }
60+ ` }
3961` ;
4062
4163const GridItem = styled . div < GridItemProps > `
42- ${ ( { areaName } ) => areaName && `grid-area: ${ areaName } ;` }
43- ${ ( { column } ) =>
44- column &&
45- `grid-column: ${
46- typeof column === "string" || typeof column === "number" ? column : `${ column . start } / ${ column . end } ;`
47- } ;`}
48- ${ ( { row } ) =>
49- row && `grid-row: ${ typeof row === "string" || typeof row === "number" ? row : `${ row . start } / ${ row . end } ;` } ;` }
50- ${ ( { placeSelf } ) =>
51- placeSelf &&
52- ( typeof placeSelf === "string"
53- ? `place-self: ${ placeSelf } `
54- : `align-self: ${ placeSelf . alignSelf ?? "" } ; justify-self: ${ placeSelf . justifySelf ?? "" } ;` ) }
64+ ${ ( props ) => `
65+ ${ props . areaName ? `grid-area: ${ props . areaName } ;` : "" }
66+ ${
67+ props . column
68+ ? `grid-column: ${
69+ typeof props . column === "string" || typeof props . column === "number"
70+ ? props . column
71+ : `${ props . column . start } / ${ props . column . end } ;`
72+ } ;`
73+ : ""
74+ }
75+ ${
76+ props . row
77+ ? `grid-row: ${
78+ typeof props . row === "string" || typeof props . row === "number"
79+ ? props . row
80+ : `${ props . row . start } / ${ props . row . end } ;`
81+ } ;`
82+ : ""
83+ }
84+ ${
85+ props . placeSelf
86+ ? typeof props . placeSelf === "string"
87+ ? `place-self: ${ props . placeSelf } ;`
88+ : `align-self: ${ props . placeSelf . alignSelf ?? "" } ; justify-self: ${ props . placeSelf . justifySelf ?? "" } ;`
89+ : ""
90+ }
91+ ` }
5592` ;
5693
5794const DxcGrid = ( props : GridPropsType ) => < Grid { ...props } /> ;
58-
5995DxcGrid . Item = GridItem ;
6096export default DxcGrid ;
0 commit comments