mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-02 22:01:52 +00:00
Added checkbox to control the findIfExists shlink flag
This commit is contained in:
32
src/utils/Checkbox.js
Normal file
32
src/utils/Checkbox.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
const propTypes = {
|
||||
checked: PropTypes.bool.isRequired,
|
||||
onChange: PropTypes.func.isRequired,
|
||||
children: PropTypes.oneOfType([ PropTypes.string, PropTypes.node ]),
|
||||
className: PropTypes.string,
|
||||
};
|
||||
|
||||
const Checkbox = ({ checked, onChange, className, children }) => {
|
||||
const id = uuid();
|
||||
|
||||
return (
|
||||
<span className={classNames('custom-control custom-checkbox', className)} style={{ display: 'inline' }}>
|
||||
<input
|
||||
type="checkbox"
|
||||
className="custom-control-input"
|
||||
id={id}
|
||||
checked={checked}
|
||||
onChange={(e) => onChange(e.target.checked, e)}
|
||||
/>
|
||||
<label className="custom-control-label" htmlFor={id}>{children}</label>
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
Checkbox.propTypes = propTypes;
|
||||
|
||||
export default Checkbox;
|
||||
Reference in New Issue
Block a user