10import { motion } from 'motion/react'
20import React, { useState } from 'react'
30import { useEffect } from 'react'
60interface SwitchProps {
70 onChange?: (checked: boolean) => void
90 style?: React.CSSProperties
12export default function Switch({ onChange, checked = false, style }: SwitchProps) {
13 const [__checked, setChecked] = useState(checked) // 内部状态
19 const __clickHandler = () => {
20 setChecked(!__checked)
21 onChange && onChange(!__checked)
25 <label className="super-toggle-switch" style={style}>
27 className="super-toggle-container"
29 justifyContent: __checked ? 'flex-end' : 'flex-start',
31 onClick={__clickHandler}
34 className="super-toggle-handle"
36 style={{ backgroundColor: __checked ? '#e3e6e8' : '#5d666f' }}
44 <div>Show Perspective</div>