-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NDD-168] Selection Box 컴포넌트 생성 (2h/2h) (#47)
* feat: SelectionBox 컴포넌트 추가 * style: typography에 title4 속성 추가
- Loading branch information
1 parent
1a146ed
commit 143d912
Showing
3 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
FE/src/components/foundation/SelectionBox/SelectionBox.styles.tsx
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,49 @@ | ||
import { theme } from '@/styles/theme'; | ||
import { css } from '@emotion/react'; | ||
|
||
export const selectionBox = css` | ||
::before { | ||
content: ''; | ||
position: absolute; | ||
background-color: ${theme.colors.point.primary.default}; | ||
} | ||
`; | ||
|
||
export const selectionBoxDirection = { | ||
top: css` | ||
::before { | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 0.4rem; | ||
border-radius: 0 0 0.2rem 0.2rem; | ||
} | ||
`, | ||
left: css` | ||
::before { | ||
top: 0; | ||
left: 0; | ||
width: 0.4rem; | ||
height: 100%; | ||
border-radius: 0 0.2rem 0.2rem 0; | ||
} | ||
`, | ||
right: css` | ||
::before { | ||
top: 0; | ||
right: 0; | ||
width: 0.4rem; | ||
height: 100%; | ||
border-radius: 0.2rem 0 0 0.2rem; | ||
} | ||
`, | ||
bottom: css` | ||
::before { | ||
bottom: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 0.4rem; | ||
border-radius: 0.2rem 0.2rem 0 0; | ||
} | ||
`, | ||
} as const; |
57 changes: 57 additions & 0 deletions
57
FE/src/components/foundation/SelectionBox/SelectionBox.tsx
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,57 @@ | ||
import { css } from '@emotion/react'; | ||
import { selectionBox, selectionBoxDirection } from './SelectionBox.styles'; | ||
import { HTMLElementTypes } from '@/types/utils'; | ||
|
||
type SelectionButtonProps = { | ||
children: React.ReactNode; | ||
id: string; | ||
name?: string; | ||
lineDirection?: 'left' | 'right' | 'top' | 'bottom'; | ||
value?: string; | ||
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void; | ||
} & HTMLElementTypes<HTMLDivElement>; | ||
|
||
const SelectionBox: React.FC<SelectionButtonProps> = ({ | ||
children, | ||
id, | ||
name, | ||
lineDirection = 'left', | ||
onChange, | ||
value, | ||
...args | ||
}) => { | ||
return ( | ||
<div | ||
css={css` | ||
display: inline-block; | ||
position: relative; | ||
padding: 0 2rem; | ||
`} | ||
{...args} | ||
> | ||
<input | ||
id={id} | ||
name={name} | ||
type={name ? 'radio' : 'checkbox'} | ||
onChange={onChange} | ||
value={value} | ||
css={css` | ||
display: none; | ||
`} | ||
/> | ||
<label | ||
htmlFor={id} | ||
css={css` | ||
${'#' + id}:checked + & { | ||
${selectionBox} | ||
${selectionBoxDirection[lineDirection]} | ||
} | ||
`} | ||
> | ||
{children} | ||
</label> | ||
</div> | ||
); | ||
}; | ||
|
||
export default SelectionBox; |
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