From 81dc730b0d7d0d7b000036cdcbc25a63d54ef605 Mon Sep 17 00:00:00 2001 From: Adam Kendis Date: Tue, 28 Jan 2020 12:09:57 -0800 Subject: [PATCH 01/15] Added classnames dependency. Used for dynamic className generation to comply with Bulma style modifiers. --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 5b0b787e8..33f525ccb 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "axios": "^0.19.0", "babel-jest": "^24.9.0", "bulma": "^0.8.0", + "classnames": "^2.2.6", "dataframe-js": "^1.4.3", "dotenv-webpack": "^1.7.0", "gh-pages": "^2.1.1", From 89ea9ca32c91fb82bcacd7e2d1cc1cc64c6061fd Mon Sep 17 00:00:00 2001 From: Adam Kendis Date: Tue, 28 Jan 2020 12:17:09 -0800 Subject: [PATCH 02/15] Generic button component adhering to Bulma styling modifiers. --- src/components/common/Button.jsx | 87 ++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 src/components/common/Button.jsx diff --git a/src/components/common/Button.jsx b/src/components/common/Button.jsx new file mode 100644 index 000000000..04b4027cd --- /dev/null +++ b/src/components/common/Button.jsx @@ -0,0 +1,87 @@ +import React from 'react'; +import PropTypes from 'proptypes'; +import classNames from 'classnames'; + +const Button = ({ + label, + handleClick, + color, + light, + size, + fullWidth, + outlined, + inverted, + rounded, + hovered, + focused, + active, + loading, + isStatic, + disabled, +}) => { + // Dynamically generates className for Bulma styling from props. + const buttonClassName = classNames('button', { + [`is-${color}`]: color, + 'is-light': light, + [`is-${size}`]: size, + 'is-fullwidth': fullWidth, + 'is-outlined': outlined, + 'is-inverted': inverted, + 'is-rounded': rounded, + 'is-hovered': hovered, + 'is-focused': focused, + 'is-active': active, + 'is-loading': loading, + 'is-static': isStatic, + 'is-disabled': disabled, + }); + + return ( + + ); +}; + +export default Button; + +Button.propTypes = { + label: PropTypes.string, + handleClick: PropTypes.func, + color: PropTypes.string, + light: PropTypes.bool, + size: PropTypes.oneOf(['small', 'normal', 'medium', 'large']), + fullWidth: PropTypes.bool, + outlined: PropTypes.bool, + inverted: PropTypes.bool, + rounded: PropTypes.bool, + hovered: PropTypes.bool, + focused: PropTypes.bool, + active: PropTypes.bool, + loading: PropTypes.bool, + isStatic: PropTypes.bool, + disabled: PropTypes.bool, +}; + +Button.defaultProps = { + label: null, + handleClick: () => {}, + color: null, + light: false, + size: 'normal', + fullWidth: false, + outlined: false, + inverted: false, + rounded: false, + hovered: false, + focused: false, + active: false, + loading: false, + isStatic: false, + disabled: false, +}; From b0c5060b7434811b4397d7e21fd37596873b2dbd Mon Sep 17 00:00:00 2001 From: Adam Kendis Date: Tue, 28 Jan 2020 12:18:13 -0800 Subject: [PATCH 03/15] Rephrased comment for greater clarity. --- src/components/common/Button.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/common/Button.jsx b/src/components/common/Button.jsx index 04b4027cd..daf8e87bf 100644 --- a/src/components/common/Button.jsx +++ b/src/components/common/Button.jsx @@ -19,7 +19,7 @@ const Button = ({ isStatic, disabled, }) => { - // Dynamically generates className for Bulma styling from props. + // Dynamically generates button className from props to comply with Bulma styling modifiers. const buttonClassName = classNames('button', { [`is-${color}`]: color, 'is-light': light, From 99de5cb4150db891103d93b18c8dc64d8f09b0a0 Mon Sep 17 00:00:00 2001 From: Adam Kendis Date: Tue, 28 Jan 2020 12:59:58 -0800 Subject: [PATCH 04/15] Added bulma-checkradio and react-id-generator dependencies. --- package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.json b/package.json index 33f525ccb..2d6cb5a32 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "axios": "^0.19.0", "babel-jest": "^24.9.0", "bulma": "^0.8.0", + "bulma-checkradio": "^1.1.1", "classnames": "^2.2.6", "dataframe-js": "^1.4.3", "dotenv-webpack": "^1.7.0", @@ -16,6 +17,7 @@ "proptypes": "^1.1.0", "react": "^16.8.6", "react-dom": "^16.8.6", + "react-id-generator": "^3.0.0", "react-leaflet": "^2.4.0", "react-leaflet-choropleth": "^2.0.0", "react-redux": "^7.1.3", From 171e79470a13d3f3a04339d9acd70f4ea3518c8c Mon Sep 17 00:00:00 2001 From: Adam Kendis Date: Tue, 28 Jan 2020 13:00:37 -0800 Subject: [PATCH 05/15] Unique id generation added to Button component. --- src/components/common/Button.jsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/common/Button.jsx b/src/components/common/Button.jsx index daf8e87bf..48b79be28 100644 --- a/src/components/common/Button.jsx +++ b/src/components/common/Button.jsx @@ -1,6 +1,7 @@ import React from 'react'; import PropTypes from 'proptypes'; import classNames from 'classnames'; +import { useId } from 'react-id-generator'; const Button = ({ label, @@ -35,9 +36,12 @@ const Button = ({ 'is-static': isStatic, 'is-disabled': disabled, }); + const [uniqueId] = useId(); + const htmlId = `btn-${uniqueId}`; return (