mirror of
https://gitee.com/dcren/cloud-native-app-initializer.git
synced 2026-08-25 19:06:31 +08:00
Project initial
This commit is contained in:
33
initializer-page/src/components/common/form/Switch.js
Normal file
33
initializer-page/src/components/common/form/Switch.js
Normal file
@@ -0,0 +1,33 @@
|
||||
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
|
||||
Reference in New Issue
Block a user