parent
2669aa4853
commit
bb58b9a5f6
7 changed files with 37 additions and 69 deletions
@ -1,57 +0,0 @@ |
|||||||
.switch { |
|
||||||
position: relative; |
|
||||||
} |
|
||||||
|
|
||||||
.switch input[type="checkbox"] { |
|
||||||
visibility: hidden; |
|
||||||
position: absolute; |
|
||||||
} |
|
||||||
|
|
||||||
.switch input[type="checkbox"]:checked + label { |
|
||||||
-webkit-transform: rotate(0deg); |
|
||||||
transform: rotate(0deg); |
|
||||||
background-color: #000; |
|
||||||
} |
|
||||||
|
|
||||||
.switch input[type="checkbox"]:checked + label:before { |
|
||||||
-webkit-transform: translateX(35.5px); |
|
||||||
transform: translateX(35.5px); |
|
||||||
background-color: #fff; |
|
||||||
} |
|
||||||
|
|
||||||
.switch label { |
|
||||||
display: -webkit-box; |
|
||||||
display: -ms-flexbox; |
|
||||||
display: flex; |
|
||||||
width: 70px; |
|
||||||
height: 34px; |
|
||||||
border: 3px solid; |
|
||||||
border-radius: 99em; |
|
||||||
position: relative; |
|
||||||
-webkit-transition: -webkit-transform 0.3s ease-in-out; |
|
||||||
transition: -webkit-transform 0.3s ease-in-out; |
|
||||||
transition: transform 0.3s ease-in-out; |
|
||||||
transition: transform 0.3s ease-in-out, -webkit-transform 0.3s ease-in-out; |
|
||||||
-webkit-transform-origin: 50% 50%; |
|
||||||
transform-origin: 50% 50%; |
|
||||||
cursor: pointer; |
|
||||||
} |
|
||||||
|
|
||||||
.switch label:before { |
|
||||||
-webkit-transition: -webkit-transform 0.3s ease; |
|
||||||
transition: -webkit-transform 0.3s ease; |
|
||||||
transition: transform 0.3s ease; |
|
||||||
transition: transform 0.3s ease, -webkit-transform 0.3s ease; |
|
||||||
-webkit-transition-delay: 0s; |
|
||||||
transition-delay: 0s; |
|
||||||
content: ""; |
|
||||||
display: block; |
|
||||||
position: absolute; |
|
||||||
width: 24px; |
|
||||||
height: 24px; |
|
||||||
background-color: #000; |
|
||||||
border-radius: 50%; |
|
||||||
top: 2px; |
|
||||||
left: 3px; |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
|
||||||
"index.scss" |
|
||||||
], |
|
||||||
"names": [], |
|
||||||
"file": "index.css" |
|
||||||
} |
|
@ -1,7 +1,5 @@ |
|||||||
// it has style inside index.scss ---> // Start Switch && end Switch
|
// it has style inside index.scss ---> // Start Switch && end Switch
|
||||||
|
|
||||||
import React from "react"; |
import React from "react"; |
||||||
import "./index.scss"; |
|
||||||
|
|
||||||
const Switch = () => { |
const Switch = () => { |
||||||
return ( |
return ( |
@ -0,0 +1,25 @@ |
|||||||
|
import React, { useState } from "react"; |
||||||
|
|
||||||
|
import Switch from "./Switch"; |
||||||
|
|
||||||
|
function SwitchDesign() { |
||||||
|
const list = { |
||||||
|
1: <Switch />, |
||||||
|
}; |
||||||
|
const [type, setType] = useState(1); |
||||||
|
return ( |
||||||
|
<div className="w-full flex flex-col items-center"> |
||||||
|
<select |
||||||
|
className="mb-10 w-20 bg-gray-200" |
||||||
|
onChange={(e) => setType(e.target.value)} |
||||||
|
> |
||||||
|
{Object.keys(list).map((option, index) => ( |
||||||
|
<option key={index}>{option}</option> |
||||||
|
))} |
||||||
|
</select> |
||||||
|
{list[type]} |
||||||
|
</div> |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
export default SwitchDesign; |
Loading…
Reference in new issue