diff --git a/CHANGELOG.md b/CHANGELOG.md index b9d391dc..172907d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Precise UI Changelog +## 1.6.3 + +- fix(563167): add validation error + ## 1.6.2 - Change to `flex-base: auto` for `RadioButtonCircle` to work on different box-sizing models diff --git a/integration/__image_snapshots__/RadioButtonGroup_13-snap.png b/integration/__image_snapshots__/RadioButtonGroup_13-snap.png index e7d9358d..56e9ba37 100644 Binary files a/integration/__image_snapshots__/RadioButtonGroup_13-snap.png and b/integration/__image_snapshots__/RadioButtonGroup_13-snap.png differ diff --git a/integration/__image_snapshots__/RadioButtonGroup_15-snap.png b/integration/__image_snapshots__/RadioButtonGroup_15-snap.png index f0246761..e7d9358d 100644 Binary files a/integration/__image_snapshots__/RadioButtonGroup_15-snap.png and b/integration/__image_snapshots__/RadioButtonGroup_15-snap.png differ diff --git a/integration/__image_snapshots__/RadioButtonGroup_17-snap.png b/integration/__image_snapshots__/RadioButtonGroup_17-snap.png new file mode 100644 index 00000000..f0246761 Binary files /dev/null and b/integration/__image_snapshots__/RadioButtonGroup_17-snap.png differ diff --git a/integration/__image_snapshots__/RadioButtonGroup_3-snap.png b/integration/__image_snapshots__/RadioButtonGroup_3-snap.png index 80c0348e..fe82d96f 100644 Binary files a/integration/__image_snapshots__/RadioButtonGroup_3-snap.png and b/integration/__image_snapshots__/RadioButtonGroup_3-snap.png differ diff --git a/integration/__image_snapshots__/RadioButtonGroup_5-snap.png b/integration/__image_snapshots__/RadioButtonGroup_5-snap.png index 82857572..80c0348e 100644 Binary files a/integration/__image_snapshots__/RadioButtonGroup_5-snap.png and b/integration/__image_snapshots__/RadioButtonGroup_5-snap.png differ diff --git a/integration/__image_snapshots__/RadioButtonGroup_7-snap.png b/integration/__image_snapshots__/RadioButtonGroup_7-snap.png index f31a1cdd..82857572 100644 Binary files a/integration/__image_snapshots__/RadioButtonGroup_7-snap.png and b/integration/__image_snapshots__/RadioButtonGroup_7-snap.png differ diff --git a/integration/__image_snapshots__/RadioButtonGroup_9-snap.png b/integration/__image_snapshots__/RadioButtonGroup_9-snap.png index 56e9ba37..f31a1cdd 100644 Binary files a/integration/__image_snapshots__/RadioButtonGroup_9-snap.png and b/integration/__image_snapshots__/RadioButtonGroup_9-snap.png differ diff --git a/package.json b/package.json index a9d88c59..1aeb5d91 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "precise-ui", - "version": "1.6.2", + "version": "1.6.3", "description": "Precise UI React component library powered by Styled Components.", "keywords": [ "react", diff --git a/src/components/RadioButtonGroup/Example.md b/src/components/RadioButtonGroup/Example.md index e311f81a..f10600e4 100644 --- a/src/components/RadioButtonGroup/Example.md +++ b/src/components/RadioButtonGroup/Example.md @@ -12,6 +12,18 @@ const { RadioButtonGroup, RadioButton } = require('precise-ui'); ``` +The `RadioButtonGroup` can also be used to show error massage underneath the radio buttons if you have validation. + +```jsx +const { RadioButtonGroup, RadioButton } = require('precise-ui'); + + + First + Second + Third + +``` + The style of the radio buttons can be varied. Here we use some wrapping to prevent an overflow. Bravo radio button is selected by default. ```jsx @@ -123,4 +135,4 @@ const { RadioButtonGroup, Checkbox, Form } = require('precise-ui'); Third -``` \ No newline at end of file +``` diff --git a/src/components/RadioButtonGroup/index.tsx b/src/components/RadioButtonGroup/index.tsx index 69e9c82d..d7225b0f 100644 --- a/src/components/RadioButtonGroup/index.tsx +++ b/src/components/RadioButtonGroup/index.tsx @@ -6,6 +6,8 @@ import { RadioButtonGroupContextType, RadioButtonGroupNotifier, } from '../../contexts/RadioButtonGroupContext'; +import { PaddedContainer } from '../PaddedContainer'; +import { InputError } from '../InputError'; export type RadioButtonGroupChangeEvent = InputChangeEvent; @@ -22,6 +24,7 @@ export type StateValue = Array | string | undefined; export interface RadioButtonGroupState { controlled: boolean; value: StateValue; + error?: React.ReactChild; } class RadioButtonGroupInt extends React.PureComponent { @@ -31,12 +34,13 @@ class RadioButtonGroupInt extends React.PureComponent { @@ -145,7 +150,20 @@ class RadioButtonGroupInt extends React.PureComponent{this.props.children}; + const { error } = this.state; + + const Error = error && ( + + {error} + + ); + + return ( + + {this.props.children} + {Error} + + ); } }