-
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.
- Loading branch information
Showing
3 changed files
with
56 additions
and
8 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
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,24 @@ | ||
'use client' | ||
|
||
import * as Switch from '@radix-ui/react-switch' | ||
import { theme } from '@/styles/theme' | ||
import styled from 'styled-components' | ||
|
||
const StyledRoot = styled(Switch.Root)` | ||
width: 42px; | ||
height: 25px; | ||
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 |
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,27 @@ | ||
'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: 21px; | ||
height: 21px; | ||
background-color: ${theme.color.white}; | ||
border-radius: 9999px; | ||
box-shadow: 0 2px 2px var(--black-a7); | ||
transition: transform 300ms; | ||
transform: translateX(2px); | ||
will-change: transform; | ||
&[data-state='checked'] { | ||
transform: translateX(19px); | ||
} | ||
` | ||
|
||
const ToggleThumb = ({ ...props }: Switch.SwitchThumbProps) => { | ||
return <StyledThumb {...props} /> | ||
} | ||
|
||
export default ToggleThumb |