HEX
Server: LiteSpeed
System: Linux premium212.web-hosting.com 4.18.0-553.124.4.lve.el8.x86_64 #1 SMP Fri May 15 13:02:13 UTC 2026 x86_64
User: vitanhod (1367)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /home/vitanhod/barnabites.es/wp-content/themes/rishi/customizer/src/@components/Switch.jsx
import styled from "@emotion/styled";

const SwitchStyles = styled.div`
    width: 40px;
    height: 22px;
    border-radius: 45px;
    background-color: #d1d1d1;
    position: relative;
    box-shadow: var(--cw__box-shadow);
    transition: var(--cw__transition);
    cursor: pointer;
    span{
        content: "";
        width: 18px;
        height: 18px;
        border-radius: 50%;
        background-color: #ffffff;
        position: absolute;
        top: 2px;
        left: 2px;
        transition: var(--cw__transition);
        box-shadow: 2px 0px 4px rgba(0,0,0, .1)
    }
    &.checked{
        background-color: var(--cw__secondary-color);
        span{
            left: 20px;
            box-shadow: -2px 0px 4px rgba(0,0,0, .1)
        }
    }
`

const Switch = ({ onChange, value, onClick }) => {

	const handleSwitchOnKeyDown = (e) => {
		if (e.type === "keydown" && e.key === "Enter") {
			onChange(!value)
		}
	}

	return <SwitchStyles
		tabIndex={0}
		className={`cw__switch${value ? ' checked' : ''}`}
		onClick={(e) => {
			onClick && onClick(e)
			onChange(!value)
		}}
		onKeyDown={handleSwitchOnKeyDown}
	>
		<span></span>
	</SwitchStyles>
}

export default Switch