-
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.
feat: slide 버튼 윈도우 사이즈에 맞게 반응형 디자인 되도록 구현
- Loading branch information
Showing
11 changed files
with
205 additions
and
10 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
19 changes: 19 additions & 0 deletions
19
src/components/NormalProject/getButtonPositionWithBreakPoints.ts
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,19 @@ | ||
import { getCurrentBreakPoints } from '../../utils/layout/getCurrentBreakPoints'; | ||
|
||
export const getButtonPositionWithBreakPoints = ( | ||
breakPoints: BreakPointsBoolean, | ||
) => { | ||
const currentBreakPoints = getCurrentBreakPoints(breakPoints); | ||
switch (currentBreakPoints) { | ||
case 'breakpoint-m': | ||
return 38; | ||
case 'breakpoint-l': | ||
return 48; | ||
case 'breakpoint-xl': | ||
return 60; | ||
case 'breakpoint-xxl': | ||
return 60; | ||
default: | ||
return 80; | ||
} | ||
}; |
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,6 +1,19 @@ | ||
export const ODSBreakpointTokenVariables = { | ||
export const ODSBreakpointTokenVariables: BreakPointsTokenInterface = { | ||
'breakpoint-s': 'screen and (max-width: 599px)', | ||
'breakpoint-m': 'screen and (max-width: 839px)', | ||
'breakpoint-l': 'screen and (max-width: 1023px)', | ||
'breakpoint-xl': 'screen and (max-width: 1280px)', | ||
'breakpoint-xxl': 'screen and (max-width: 1535px)', | ||
'breakpoint-FHD': 'screen and (max-width: 1919px)', | ||
}; | ||
|
||
export const ODSBreakpointTokenVariablesArray: BreakPointsToken[] = Object.keys( | ||
ODSBreakpointTokenVariables, | ||
) as BreakPointsToken[]; | ||
|
||
export const ODSBreakPointTokenKeyVariables = Object.assign( | ||
{}, | ||
...ODSBreakpointTokenVariablesArray.map((key) => ({ [key]: key })), | ||
) as { | ||
[key in BreakPointsToken]: BreakPointsToken; | ||
}; |
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,19 @@ | ||
import { useMediaQuery } from 'react-responsive'; | ||
|
||
export const useODSBreakPoints = (): BreakPointsBoolean => { | ||
const breakpointS = useMediaQuery({ query: '(max-width: 599px)' }); | ||
const breakpointM = useMediaQuery({ query: '(max-width: 839px)' }); | ||
const breakpointL = useMediaQuery({ query: '(max-width: 1023px)' }); | ||
const breakpointXL = useMediaQuery({ query: '(max-width: 1280px)' }); | ||
const breakpointXXL = useMediaQuery({ query: '(max-width: 1535px)' }); | ||
const breakpointFHD = useMediaQuery({ query: '(max-width: 1919px)' }); | ||
|
||
return { | ||
breakpointS, | ||
breakpointM, | ||
breakpointL, | ||
breakpointXL, | ||
breakpointXXL, | ||
breakpointFHD, | ||
}; | ||
}; |
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,20 @@ | ||
import { useEffect, useState } from 'react'; | ||
|
||
export const useWindowResize = () => { | ||
const [windowSize, setWindowSize] = useState<WindowBasedPoints>({ | ||
width: window.innerWidth, | ||
height: window.innerHeight, | ||
}); | ||
useEffect(() => { | ||
const handleResize = () => { | ||
setWindowSize({ | ||
width: window.innerWidth, | ||
height: window.innerHeight, | ||
}); | ||
}; | ||
|
||
window.addEventListener('resize', handleResize); | ||
return () => window.removeEventListener('resize', handleResize); | ||
}, []); | ||
return windowSize; | ||
}; |
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,4 @@ | ||
interface WindowBasedPoints { | ||
width: number; | ||
height: number; | ||
} |
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,17 @@ | ||
import { ODSBreakPointTokenKeyVariables } from '@/const/breakpoints'; | ||
|
||
export const getCurrentBreakPoints = ( | ||
breakPoints: BreakPointsBoolean, | ||
): BreakPointsToken => { | ||
if (breakPoints.breakpointS) | ||
return ODSBreakPointTokenKeyVariables['breakpoint-s']; | ||
if (breakPoints.breakpointM) | ||
return ODSBreakPointTokenKeyVariables['breakpoint-m']; | ||
if (breakPoints.breakpointL) | ||
return ODSBreakPointTokenKeyVariables['breakpoint-l']; | ||
if (breakPoints.breakpointXL) | ||
return ODSBreakPointTokenKeyVariables['breakpoint-xl']; | ||
if (breakPoints.breakpointXXL) | ||
return ODSBreakPointTokenKeyVariables['breakpoint-xxl']; | ||
return 'breakpoint-FHD'; | ||
}; |