mirror of
https://gitee.com/dcren/cloud-native-app-initializer.git
synced 2026-08-25 19:06:31 +08:00
34 lines
649 B
JavaScript
34 lines
649 B
JavaScript
|
|
import PropTypes from 'prop-types'
|
||
|
|
import React from 'react'
|
||
|
|
|
||
|
|
const Switch = ({ id, isOn, onChange }) => {
|
||
|
|
return (
|
||
|
|
<span className='switch'>
|
||
|
|
<input
|
||
|
|
checked={isOn}
|
||
|
|
onChange={onChange}
|
||
|
|
className='switch-checkbox'
|
||
|
|
id={id}
|
||
|
|
name='switch-new'
|
||
|
|
type='checkbox'
|
||
|
|
/>
|
||
|
|
{/* eslint-disable-next-line */}
|
||
|
|
<label className='switch-label' htmlFor={id}>
|
||
|
|
<span className='switch-button' />
|
||
|
|
</label>
|
||
|
|
</span>
|
||
|
|
)
|
||
|
|
}
|
||
|
|
|
||
|
|
Switch.defaultProps = {
|
||
|
|
isOn: false,
|
||
|
|
onChange: null,
|
||
|
|
}
|
||
|
|
|
||
|
|
Switch.propTypes = {
|
||
|
|
isOn: PropTypes.bool,
|
||
|
|
onChange: PropTypes.func,
|
||
|
|
}
|
||
|
|
|
||
|
|
export default Switch
|