mirror of
https://github.com/getredash/redash.git
synced 2026-03-22 10:00:17 -04:00
* Prettier all the JS files * Add GitHub Action to autoformat code pushed to master * Fix eslint violation due to formatting. * Remove GitHub actions for styling * Add restyled.io config
41 lines
929 B
JavaScript
41 lines
929 B
JavaScript
import React, { useMemo } from "react";
|
|
import PropTypes from "prop-types";
|
|
import AntSwitch from "antd/lib/switch";
|
|
import Typography from "antd/lib/typography";
|
|
|
|
export default function Switch({ id, children, disabled, ...props }) {
|
|
const fallbackId = useMemo(
|
|
() =>
|
|
`visualization-editor-control-${Math.random()
|
|
.toString(36)
|
|
.substr(2, 10)}`,
|
|
[]
|
|
);
|
|
id = id || fallbackId;
|
|
|
|
if (children) {
|
|
return (
|
|
<label htmlFor={id} className="d-flex align-items-center">
|
|
<AntSwitch id={id} disabled={disabled} {...props} />
|
|
<Typography.Text className="m-l-10" disabled={disabled}>
|
|
{children}
|
|
</Typography.Text>
|
|
</label>
|
|
);
|
|
}
|
|
|
|
return <AntSwitch {...props} />;
|
|
}
|
|
|
|
Switch.propTypes = {
|
|
id: PropTypes.string,
|
|
disabled: PropTypes.bool,
|
|
children: PropTypes.node,
|
|
};
|
|
|
|
Switch.defaultProps = {
|
|
id: null,
|
|
disabled: false,
|
|
children: null,
|
|
};
|