-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
media.tsx 파일에 반응형 크기 설정 파일 생성
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { css, type CSSObject, type Interpolation } from 'styled-components'; | ||
|
||
export type Breakpoints = 'small' | 'medium' | 'large' | 'notLarge'; | ||
|
||
export const breakpoints: Record<Breakpoints, string> = { | ||
small: '@media (max-width: 375px)', | ||
medium: '@media (max-width: 744px)', | ||
large: '@media (min-width: 745px)', | ||
notLarge: '@media not all and (min-width: 745px)', | ||
}; | ||
|
||
const media = Object.entries(breakpoints).reduce((acc, [key, value]) => { | ||
return { | ||
...acc, | ||
[key]: ( | ||
first: CSSObject | TemplateStringsArray, | ||
...interpolations: Interpolation<Object>[] | ||
) => css` | ||
${value} { | ||
${css(first, ...interpolations)} | ||
} | ||
`, | ||
}; | ||
}, {}) as Record<Breakpoints, any>; | ||
|
||
export default media; |