-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
반응형 디자인 유틸리티 추가. chip 일부 컴포넌트 구현 #5
The head ref may contain hidden characters: "\uC7A5\uC7AC\uD601"
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
71ff1f6
Chore: eslint, prettier 설정 추가
foxholic9 9f8ca4b
Feat: ColorCircle 컴포넌트 생성
foxholic9 e2233ac
Move: Chip 폴더 추가, 파일 경로 변경
foxholic9 e1540f7
Feat: scss용 반응형 디자인 유틸리티
foxholic9 5d45ba1
Feat: 컴포넌트 반응형디자인용 커스텀 훅
foxholic9 6779934
Feat: 색상 점 컴포넌트화
foxholic9 9cc58f9
Merge branch 'dev' into feature-장재혁
foxholic9 37278b5
Style: 콜론 관련해서 팀과 통일시켰습니다.
foxholic9 8ecfc4d
Merge branch 'dev' into 장재혁
foxholic9 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
interface CircleProps { | ||
color: string; | ||
diameter: number; | ||
children?: React.ReactNode; | ||
} | ||
|
||
// 색상코드, 지름, 내부요소 prop을 받아 원을 만들어줍니다. | ||
// 색상코드는 가능하면 #이 붙는 RGB로, 지름은 숫자만 쓰면 px단위로 지정됩니다. | ||
// 내부요소는 필수가 아니며, 있을 시 중앙정렬됩니다. | ||
function ColorCircle({ color, diameter, children }: CircleProps) { | ||
const circleStyle = { | ||
backgroundColor: color, | ||
width: `${diameter}px`, | ||
height: `${diameter}px`, | ||
borderRadius: '50%', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
color: '#fff', | ||
textAlign: 'center', | ||
} as React.CSSProperties; | ||
|
||
return <div style={circleStyle}>{children}</div>; | ||
} | ||
|
||
ColorCircle.defaultProps = { | ||
children: undefined, | ||
}; | ||
|
||
export default ColorCircle; |
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,22 @@ | ||
import ColorCircle from './ColorCircle'; | ||
|
||
interface ColorDotProps { | ||
color: string; | ||
} | ||
|
||
// 작은 점이 여럿 사용되서 컴포넌트로 분리했습니다. | ||
// useMemo를 사용하면 같은 색 컴포넌트는 렌더링을 한번만 하게 할 수 있습니다. | ||
function ColorDot({ color }: ColorDotProps) { | ||
const colorCircleProps = { | ||
color, | ||
diameter: 8, | ||
}; | ||
|
||
return <ColorCircle {...colorCircleProps} />; | ||
} | ||
|
||
export default ColorDot; | ||
|
||
// 사용예시 | ||
// <ColorDot color="#00ff37" /> | ||
// <ColorDot color="#ff0000" /> |
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,30 @@ | ||
interface CircleProps { | ||
color: string; | ||
diameter: number; | ||
children?: React.ReactNode; | ||
} | ||
|
||
// 색상코드, 지름, 내부요소 prop을 받아 원을 만들어줍니다. | ||
// 색상코드는 가능하면 #이 붙는 RGB로, 지름은 숫자만 쓰면 px단위로 지정됩니다. | ||
// 내부요소는 필수가 아니며, 있을 시 중앙정렬됩니다. | ||
function ColorCircle({ color, diameter, children }: CircleProps) { | ||
const circleStyle = { | ||
backgroundColor: color, | ||
width: `${diameter}px`, | ||
height: `${diameter}px`, | ||
borderRadius: '50%', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
color: '#fff', | ||
textAlign: 'center', | ||
} as React.CSSProperties; | ||
|
||
return <div style={circleStyle}>{children}</div>; | ||
} | ||
|
||
ColorCircle.defaultProps = { | ||
children: undefined, | ||
}; | ||
|
||
export default ColorCircle; |
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,40 @@ | ||
// 장치별 사이즈 정의 | ||
$size-mobile: 767px; | ||
$size-tablet: 768px; | ||
$size-tablet-max: 1023px; | ||
$size-desktop: 1024px; | ||
|
||
// [모바일]가로 767px 이하일 때 | ||
@mixin mobile { | ||
@media (max-width: $size-mobile) { | ||
@content; | ||
} | ||
} | ||
|
||
// [태블릿]가로 768px 이상, 1023px이하 | ||
@mixin tablet { | ||
@media (min-width: $size-tablet) and (max-width: $size-tablet-max) { | ||
@content; | ||
} | ||
} | ||
|
||
// [데스크탑]가로 1024px 이상 | ||
@mixin desktop { | ||
@media (min-width: $size-desktop) { | ||
@content; | ||
} | ||
} | ||
|
||
// 사용 예시 | ||
// @include mobile{ | ||
// /*브라우저 사이즈767px이하일때*/ | ||
// background: black; | ||
// } | ||
// @include tablet{ | ||
// /*브라우저 사이즈1023px이하일때*/ | ||
// background: white; | ||
// } | ||
// @include desktop{ | ||
// /*브라우저 사이즈1024px이상일때*/ | ||
// background: gray; | ||
// } |
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 @@ | ||
@import './media.scss'; |
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,32 @@ | ||
import { useState, useEffect } from 'react'; | ||
|
||
const useWindowSize = () => { | ||
// windowSize는 화면의 가로, 세로 크기를 객체로 갖습니다. | ||
const [windowSize, setWindowSize] = useState({ | ||
width: window.innerWidth, | ||
height: window.innerHeight, | ||
}); | ||
|
||
const handleResize = () => { | ||
setWindowSize({ | ||
width: window.innerWidth, | ||
height: window.innerHeight, | ||
}); | ||
}; | ||
|
||
// 초기값 설정 | ||
useEffect(() => { | ||
window.addEventListener('resize', handleResize); | ||
handleResize(); | ||
return () => window.removeEventListener('resize', handleResize); | ||
}, []); | ||
return windowSize; | ||
}; | ||
|
||
export default useWindowSize; | ||
|
||
// 컴포넌트에서 반응형 디자인을 구현하기 위한 커스텀 훅입니다. | ||
// scss에서의 반응형 디자인은 styles/media.scss를 참고해주세요. | ||
|
||
// import useWindowSize from './useWindowSize'; | ||
// const { width } = useWindowSize(); 하여 width나 height를 추출합니다. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
반응형 관련 기준이 되는 파일이 있으면 좋겠다고 생각했는데
잘 작성해주신 것 같습니다. 감사합니다!