-
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
1 parent
1c79bb5
commit a5ea72c
Showing
5 changed files
with
148 additions
and
144 deletions.
There are no files selected for viewing
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { css } from '@emotion/react' | ||
import { Layout } from '../../subject/Layout' | ||
import { RENDER_COUNT } from './data' | ||
|
||
const literalCss = css` | ||
display: inline-flex; | ||
& input[type='checkbox'] { | ||
cursor: pointer; | ||
position: relative; | ||
appearance: none; | ||
width: 48px; | ||
height: 28px; | ||
background-color: lightgray; | ||
border-radius: 16px; | ||
transition: background-color 0.2s ease-in-out; | ||
overflow: hidden; | ||
&::before { | ||
content: ''; | ||
position: absolute; | ||
width: 20px; | ||
height: 20px; | ||
background-color: gray; | ||
border-radius: 50%; | ||
left: 4px; | ||
top: 4px; | ||
margin-block: auto; | ||
transition: transform 0.2s ease; | ||
box-shadow: -2px 2px 10px 0px rgba(0, 0, 0, 0.35); | ||
} | ||
/* hover, active content */ | ||
&::after { | ||
content: ''; | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
left: 0; | ||
background-color: transparent; | ||
transition: background-color 0.2s ease-in-out; | ||
} | ||
&:active { | ||
&::after { | ||
background-color: white; | ||
} | ||
} | ||
} | ||
& input[type='checkbox']:checked { | ||
background-color: pink; | ||
&::before { | ||
background-color: white; | ||
transform: translateX(100%); | ||
} | ||
} | ||
` | ||
|
||
export function TogglesLiteral() { | ||
return ( | ||
<Layout> | ||
{Array.from({ length: RENDER_COUNT }).map((_, idx) => ( | ||
<label css={literalCss} key={idx}> | ||
<input type='checkbox' /> | ||
</label> | ||
))} | ||
</Layout> | ||
) | ||
} |
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,71 @@ | ||
import { css } from '@emotion/react' | ||
import { Layout } from '../../subject/Layout' | ||
import { RENDER_COUNT } from './data' | ||
|
||
const objCss = css({ | ||
display: 'inline-flex', | ||
|
||
"& input[type='checkbox']": { | ||
cursor: 'pointer', | ||
position: 'relative', | ||
appearance: 'none', | ||
width: '48px', | ||
height: '28px', | ||
backgroundColor: 'lightgray', | ||
borderRadius: '16px', | ||
transition: 'background-color 0.2s ease-in-out', | ||
overflow: 'hidden', | ||
|
||
'&::before': { | ||
content: '""', | ||
position: 'absolute', | ||
width: '20px', | ||
height: '20px', | ||
backgroundColor: 'gray', | ||
borderRadius: '50%', | ||
left: '4px', | ||
top: '4px', | ||
marginBlock: 'auto', | ||
transition: 'transform 0.2s ease', | ||
boxShadow: '-2px 2px 10px 0px rgba(0, 0, 0, 0.35)', | ||
}, | ||
|
||
'&::after': { | ||
content: '""', | ||
position: 'absolute', | ||
top: '0', | ||
right: '0', | ||
bottom: '0', | ||
left: '0', | ||
backgroundColor: 'transparent', | ||
transition: 'background-color 0.2s ease-in-out', | ||
}, | ||
|
||
'&:active': { | ||
'&::after': { | ||
backgroundColor: 'white', | ||
}, | ||
}, | ||
}, | ||
|
||
"& input[type='checkbox']:checked": { | ||
backgroundColor: 'pink', | ||
|
||
'&::before': { | ||
backgroundColor: 'white', | ||
transform: 'translateX(100%)', | ||
}, | ||
}, | ||
}) | ||
|
||
export function TogglesObj() { | ||
return ( | ||
<Layout> | ||
{Array.from({ length: RENDER_COUNT }).map((_, idx) => ( | ||
<label css={objCss} key={idx}> | ||
<input type='checkbox' /> | ||
</label> | ||
))} | ||
</Layout> | ||
) | ||
} |
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 @@ | ||
export const RENDER_COUNT = 12 |
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