/* eslint-disable react/require-default-props */ import React, { ChangeEvent, CSSProperties } from 'react'; import { styled } from '@jarvisnetwork/ui'; const Container = styled.label` position: relative; display: inline-block; width: 46px; height: 22px; .label { position: absolute; cursor: pointer; border-radius: 13px; top: 0; left: 0; right: 0; bottom: 0; background-color: ${(props) => props.theme.text.disabled}; -webkit-transition: 0.3s; transition: 0.3s; } .label:before { position: absolute; content: ''; height: 14px; width: 14px; left: 4px; bottom: 4px; background-color: ${(props) => props.theme.common.white}; -webkit-transition: 0.3s; transition: 0.3s; border-radius: 50%; } input { display: none; } input:checked + .label { background-color: ${(props) => props.theme.common.success}; } input:focus + .label { box-shadow: 0 0 1px ${(props) => props.theme.common.success}; } input:checked + .label:before { -webkit-transform: translateX(22px); -ms-transform: translateX(22px); transform: translateX(22px); } `; interface BasicCheckboxProps { className?: string; style?: CSSProperties; } interface ToggleProps extends BasicCheckboxProps { checked: boolean; name?: string; onChange: (e: ChangeEvent) => void; } export const Toggle = React.memo( ({ className, style, ...props }: ToggleProps) => { const inputProps: ToggleProps = { ...props }; const inputName = inputProps.name || `input-${Math.random()}`; return ( ); } );