index.js 414 B

1234567891011121314151617
  1. import React from 'react';
  2. import './index.less';
  3. import Assets from '@src/components/Assets';
  4. function Switch(props) {
  5. const { checked, children, onChange } = props;
  6. return (
  7. <div className="switch" onClick={() => {
  8. if (onChange) onChange(!checked);
  9. }}>
  10. <Assets name={checked ? 'swich_on' : 'swich_off'} />
  11. {children}
  12. </div>
  13. );
  14. }
  15. Switch.propTypes = {};
  16. export default Switch;