-
Notifications
You must be signed in to change notification settings - Fork 0
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
[#13] 토글 공통 컴포넌트 구현 #22
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import ToggleRoot from './ToggleRoot' | ||
import ToggleThumb from './ToggleThumb' | ||
|
||
const Toggle = () => { | ||
return ( | ||
<ToggleRoot> | ||
<ToggleThumb /> | ||
</ToggleRoot> | ||
) | ||
} | ||
|
||
export default Toggle |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use client' | ||
|
||
import * as Switch from '@radix-ui/react-switch' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 현재 radix 라이브러리를 전체를 가르키는 변수명을 [기능]Primitive 로 이름짓구 있습니다. SwitchPrimitive로 바꾸면 컨벤션을 유지 할 수 있을꺼같아요 !! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오 감사합니다 !! |
||
import { theme } from '@/styles/theme' | ||
import styled from 'styled-components' | ||
|
||
const StyledRoot = styled(Switch.Root)` | ||
width: 58px; | ||
height: 31px; | ||
background-color: ${theme.color.grey200}; | ||
border-radius: 9999px; | ||
position: relative; | ||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0); | ||
|
||
&[data-state='checked'] { | ||
background-color: ${theme.color.purple700}; | ||
} | ||
` | ||
|
||
const ToggleRoot = ({ children, ...props }: Switch.PrimitiveButtonProps) => { | ||
return <StyledRoot {...props}>{children}</StyledRoot> | ||
} | ||
|
||
export default ToggleRoot |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use client' | ||
|
||
import * as Switch from '@radix-ui/react-switch' | ||
import { theme } from '@/styles/theme' | ||
import styled from 'styled-components' | ||
|
||
const StyledThumb = styled(Switch.SwitchThumb)` | ||
display: block; | ||
width: 25px; | ||
height: 25px; | ||
background-color: ${theme.color.white}; | ||
border-radius: 9999px; | ||
transition: transform 300ms; | ||
transform: translateX(2px); | ||
will-change: transform; | ||
|
||
&[data-state='checked'] { | ||
transform: translateX(30px); | ||
} | ||
` | ||
|
||
const ToggleThumb = ({ ...props }: Switch.SwitchThumbProps) => { | ||
return <StyledThumb {...props} /> | ||
} | ||
|
||
export default ToggleThumb |
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.
👍🏻👍🏻👍🏻👍🏻 경로만 절대로 바꾸면 좋을 것 같아용 !!
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.
수정하겠습니다 !