Skip to content

Commit

Permalink
feat(radio-group): add error and hint fields
Browse files Browse the repository at this point in the history
  • Loading branch information
apust committed Dec 3, 2020
1 parent a9d0eaa commit 69e12f5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/packages/core/src/radio-group/RadioGroup.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { RadioGroup } from '.';
label="Options"
value={value}
onChange={event => setValue(event.target.value)}
hint="Group hint"
legend="Group legend"
options={[
{ value: '1', title: 'option 1', description: 'option 1 description' },
{ value: '2', title: 'option 2' },
Expand Down
11 changes: 10 additions & 1 deletion src/packages/core/src/radio-group/RadioGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export const RadioGroup = (props: RadioGroupProps) => {
readonly = false,
onChange,
options,
error,
hint,
...rest
} = props;

Expand All @@ -41,7 +43,14 @@ export const RadioGroup = (props: RadioGroupProps) => {
));

return (
<Fieldset {...rest} className={className} id={id} legend={legend}>
<Fieldset
className={className}
id={id}
legend={legend}
error={error}
hint={hint}
{...rest}
>
{renderOptions}
</Fieldset>
);
Expand Down
10 changes: 10 additions & 0 deletions src/packages/core/src/radio-group/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ export interface RadioGroupProps extends CommonAttributes {
*/
disabled?: boolean;

/**
* Error message.
*/
error?: string;

/**
* Hint message. Hidden when `error` is not empty.
*/
hint?: string;

/**
* Radio group id.
*/
Expand Down

0 comments on commit 69e12f5

Please sign in to comment.