From 1ab77decfd40f5b381ccc801583a8a1c40bac94f Mon Sep 17 00:00:00 2001 From: Aleksandr Gumroian Date: Fri, 27 Sep 2024 14:43:39 +0200 Subject: [PATCH] docs: Refactor RadioSet & ignore Radio component --- src/bootstrap/Radio.js | 48 +++++++++++++++++++++++++++++++++++++++ src/bootstrap/RadioSet.js | 38 ++----------------------------- src/index.js | 3 ++- styleguide.config.js | 2 +- 4 files changed, 53 insertions(+), 38 deletions(-) create mode 100644 src/bootstrap/Radio.js diff --git a/src/bootstrap/Radio.js b/src/bootstrap/Radio.js new file mode 100644 index 0000000..c7892c8 --- /dev/null +++ b/src/bootstrap/Radio.js @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2024 CZ.NIC z.s.p.o. (https://www.nic.cz/) + * + * This is free software, licensed under the GNU General Public License v3. + * See /LICENSE for more information. + */ + +import React from "react"; + +import PropTypes from "prop-types"; + +Radio.propTypes = { + label: PropTypes.oneOfType([ + PropTypes.string, + PropTypes.element, + PropTypes.node, + PropTypes.arrayOf(PropTypes.node), + ]).isRequired, + id: PropTypes.string.isRequired, + inline: PropTypes.bool, + helpText: PropTypes.string, + className: PropTypes.string, +}; + +function Radio({ label, id, helpText, inline, className, ...props }) { + return ( +
+ + +
+ ); +} + +export default Radio; diff --git a/src/bootstrap/RadioSet.js b/src/bootstrap/RadioSet.js index 53a0fb4..3483a9c 100644 --- a/src/bootstrap/RadioSet.js +++ b/src/bootstrap/RadioSet.js @@ -10,6 +10,8 @@ import React from "react"; import PropTypes from "prop-types"; import { useUID } from "react-uid"; +import Radio from "./Radio"; + RadioSet.propTypes = { /** Name attribute of the input HTML tag. */ name: PropTypes.string.isRequired, @@ -73,40 +75,4 @@ function RadioSet({ name, label, choices, value, helpText, inline, ...props }) { ); } -Radio.propTypes = { - label: PropTypes.oneOfType([ - PropTypes.string, - PropTypes.element, - PropTypes.node, - PropTypes.arrayOf(PropTypes.node), - ]).isRequired, - id: PropTypes.string.isRequired, - inline: PropTypes.bool, - helpText: PropTypes.string, - className: PropTypes.string, -}; - -export function Radio({ label, id, helpText, inline, className, ...props }) { - return ( -
- - -
- ); -} - export default RadioSet; diff --git a/src/index.js b/src/index.js index 2299e94..c88899a 100644 --- a/src/index.js +++ b/src/index.js @@ -28,7 +28,8 @@ export { default as FileInput } from "./bootstrap/FileInput"; export { default as Input } from "./bootstrap/Input"; export { default as NumberInput } from "./bootstrap/NumberInput"; export { default as PasswordInput } from "./bootstrap/PasswordInput"; -export { default as RadioSet, Radio } from "./bootstrap/RadioSet"; +export { default as Radio } from "./bootstrap/Radio"; +export { default as RadioSet } from "./bootstrap/RadioSet"; export { default as Select } from "./bootstrap/Select"; export { default as TextInput } from "./bootstrap/TextInput"; export { formFieldsSize, buttonFormFieldsSize } from "./bootstrap/constants"; diff --git a/styleguide.config.js b/styleguide.config.js index 5a4df8b..cdb6d8b 100644 --- a/styleguide.config.js +++ b/styleguide.config.js @@ -65,7 +65,7 @@ module.exports = { components: "src/bootstrap/*.js", exampleMode: "expand", usageMode: "expand", - ignore: ["src/bootstrap/constants.js"], + ignore: ["src/bootstrap/constants.js", "src/bootstrap/Radio.js"], sectionDepth: 0, }, ],