-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ refactor(css-grid): cenralize grid styles
- Loading branch information
1 parent
688c095
commit 0eecd44
Showing
20 changed files
with
159 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { css } from "styled-components"; | ||
import { BREAKPOINTS } from "./breakpoints"; | ||
|
||
export type GridSpanSizes = "1" | "2" | "3" | "4"; | ||
|
||
export type GridHeightSizes = "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8"; | ||
|
||
export const gridHeightToPx = (unit: GridHeightSizes) => +unit * 100; | ||
|
||
export const GRID_SPAN_CONFIG: Record< | ||
GridSpanSizes, | ||
{ lg: number; sm: number; xl: number } | ||
> = { | ||
"1": { | ||
sm: 1, | ||
lg: 1, | ||
xl: 1, | ||
}, | ||
"2": { | ||
sm: 1, | ||
lg: 2, | ||
xl: 2, | ||
}, | ||
"3": { | ||
sm: 1, | ||
lg: 2, | ||
xl: 3, | ||
}, | ||
"4": { | ||
sm: 1, | ||
lg: 2, | ||
xl: 4, | ||
}, | ||
}; | ||
|
||
export const gridRoot = css` | ||
display: grid; | ||
column-gap: 16px; | ||
grid-template-columns: repeat(4, 1fr); | ||
@media (max-width: ${BREAKPOINTS.lg}) { | ||
grid-template-columns: repeat(2, 1fr); | ||
} | ||
@media (max-width: ${BREAKPOINTS.sm}) { | ||
grid-template-columns: 1fr; | ||
} | ||
`; | ||
|
||
export const gridItem = css<{ | ||
$span: GridSpanSizes; | ||
}>` | ||
grid-column-start: span ${(props) => GRID_SPAN_CONFIG[props.$span].xl}; | ||
@media (max-width: ${BREAKPOINTS.lg}) { | ||
grid-column-start: span ${(props) => GRID_SPAN_CONFIG[props.$span].lg}; | ||
} | ||
@media (max-width: ${BREAKPOINTS.sm}) { | ||
grid-column-start: span ${(props) => GRID_SPAN_CONFIG[props.$span].sm}; | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.