-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor from styled components to goober
- Loading branch information
Agney
committed
Mar 13, 2021
1 parent
4b8eb89
commit 6739d20
Showing
11 changed files
with
68 additions
and
79 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
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 |
---|---|---|
@@ -1,27 +1,11 @@ | ||
import { ThemedCssFunction, css, DefaultTheme } from "styled-components"; | ||
const customMediaQuery = (maxWidth: number) => | ||
`@media (max-width: ${maxWidth}px)`; | ||
|
||
interface ISize { | ||
[K: string]: number; | ||
} | ||
const media = Object.freeze({ | ||
custom: customMediaQuery, | ||
desktop: customMediaQuery(922), | ||
tablet: customMediaQuery(768), | ||
phone: customMediaQuery(576), | ||
}); | ||
|
||
const sizes: Readonly<ISize> = { | ||
desktop: 992, | ||
tablet: 768, | ||
phone: 576, | ||
}; | ||
|
||
// Iterate through the sizes and create a media template | ||
const media = (Object.keys(sizes) as (keyof typeof sizes)[]).reduce( | ||
(acc, label) => { | ||
acc[label] = (first: any, ...interpolations: any[]) => css` | ||
@media (max-width: ${sizes[label]}px) { | ||
${css(first, ...interpolations)} | ||
} | ||
`; | ||
|
||
return acc; | ||
}, | ||
{} as { [key in keyof typeof sizes]: ThemedCssFunction<DefaultTheme> } | ||
); | ||
|
||
export default media; | ||
export default media; |