Skip to content

Commit

Permalink
Merge branch 'main' into readme-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Apr 3, 2023
2 parents 81f2697 + fff99db commit a7f8db9
Show file tree
Hide file tree
Showing 12 changed files with 778 additions and 40 deletions.
50 changes: 50 additions & 0 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@ Map {
"disabled": Object {
"type": "bool",
},
"helperText": Object {
"type": "node",
},
"hideLabel": Object {
"type": "bool",
},
Expand All @@ -466,6 +469,12 @@ Map {
"indeterminate": Object {
"type": "bool",
},
"invalid": Object {
"type": "bool",
},
"invalidText": Object {
"type": "node",
},
"labelText": Object {
"isRequired": true,
"type": "node",
Expand All @@ -479,9 +488,50 @@ Map {
"title": Object {
"type": "string",
},
"warn": Object {
"type": "bool",
},
"warnText": Object {
"type": "node",
},
},
"render": [Function],
},
"CheckboxGroup" => Object {
"propTypes": Object {
"children": Object {
"type": "node",
},
"className": Object {
"type": "string",
},
"helperText": Object {
"type": "node",
},
"invalid": Object {
"type": "bool",
},
"invalidText": Object {
"type": "node",
},
"legendId": Object {
"type": "node",
},
"legendText": Object {
"isRequired": true,
"type": "node",
},
"readOnly": Object {
"type": "bool",
},
"warn": Object {
"type": "bool",
},
"warnText": Object {
"type": "node",
},
},
},
"CheckboxSkeleton" => Object {
"propTypes": Object {
"className": Object {
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/__tests__/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ describe('Carbon Components React', () => {
"ButtonSet",
"ButtonSkeleton",
"Checkbox",
"CheckboxGroup",
"CheckboxSkeleton",
"ClassPrefix",
"ClickableTile",
Expand Down
151 changes: 131 additions & 20 deletions packages/react/src/components/Checkbox/Checkbox.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,23 @@
import React from 'react';
import { default as Checkbox, CheckboxSkeleton } from './';
import mdx from './Checkbox.mdx';
import CheckboxGroup from '../CheckboxGroup';

const prefix = 'cds';
const checkboxEvents = {
className: 'some-class',
labelText: 'Checkbox label',
};

const fieldsetCheckboxProps = () => ({
className: 'some-class',
legendText: 'Group label',
});

export default {
title: 'Components/Checkbox',
component: Checkbox,
subcomponents: {
CheckboxGroup,
CheckboxSkeleton,
},
parameters: {
Expand All @@ -26,55 +36,156 @@ export default {

export const Default = () => {
return (
<fieldset className={`${prefix}--fieldset`}>
<legend className={`${prefix}--label`}>Group label</legend>
<CheckboxGroup {...fieldsetCheckboxProps()}>
<Checkbox labelText={`Checkbox label`} id="checkbox-label-1" />
<Checkbox labelText={`Checkbox label`} id="checkbox-label-2" />
</fieldset>
</CheckboxGroup>
);
};

export const Single = () => {
return (
<>
<Checkbox
{...checkboxEvents}
id="checkbox-3"
helperText="Helper text goes here"
/>
<br /> <br />
<Checkbox
{...checkboxEvents}
id="checkbox-4"
invalid
invalidText="Invalid text goes here"
/>
<br /> <br />
<Checkbox
{...checkboxEvents}
id="checkbox-5"
warn
warnText="Warning text goes here"
/>
<br /> <br />
<Checkbox {...checkboxEvents} id="checkbox-6" readOnly />
</>
);
};

export const Skeleton = () => <CheckboxSkeleton />;

export const Playground = (args) => (
<fieldset className={`${prefix}--fieldset`}>
<legend className={`${prefix}--label`}>Group label</legend>
<Checkbox labelText={`Checkbox label`} id="checkbox-label-1" {...args} />
<Checkbox labelText={`Checkbox label`} id="checkbox-label-2" {...args} />
</fieldset>
<CheckboxGroup {...fieldsetCheckboxProps()} {...args}>
<Checkbox
defaultChecked
{...checkboxEvents}
id="checkbox-0"
helperText="hello"
/>
<Checkbox {...checkboxEvents} id="checkbox-1" />
<Checkbox disabled {...checkboxEvents} id="checkbox-2" />
</CheckboxGroup>
);

Playground.argTypes = {
checked: {
helperText: {
description: 'Provide text for the form group for additional help',
control: {
type: 'text',
},
defaultValue: 'Helper text goes here',
},
invalid: {
description: 'Specify whether the form group is currently invalid',
control: {
type: 'boolean',
},
defaultValue: false,
},
className: {
control: false,
invalidText: {
description:
'Provide the text that is displayed when the form group is in an invalid state',
control: {
type: 'text',
},
defaultValue: 'Invalid message goes here',
},
defaultChecked: {
control: false,
legendText: {
description:
'Provide the text to be rendered inside of the fieldset <legend>',
control: {
type: 'text',
},
},
disabled: {
readOnly: {
description: 'Specify whether the CheckboxGroup is read-only',
control: {
type: 'boolean',
},
defaultValue: false,
},
hideLabel: {
warn: {
description: 'Specify whether the form group is currently in warning state',
control: {
type: 'boolean',
},
defaultValue: false,
},
warnText: {
description:
'Provide the text that is displayed when the form group is in warning state',
control: {
type: 'text',
},
defaultValue: 'Warning message goes here',
},
checked: {
table: {
disable: true,
},
},
className: {
table: {
disable: true,
},
},
defaultChecked: {
table: {
disable: true,
},
},
disabled: {
table: {
disable: true,
},
},
hideLabel: {
table: {
disable: true,
},
},
id: {
control: false,
table: {
disable: true,
},
},
indeterminate: {
control: {
type: 'boolean',
table: {
disable: true,
},
},
labelText: {
control: false,
table: {
disable: true,
},
},
onChange: {
table: {
disable: true,
},
},
title: {
table: {
disable: true,
},
},
};
Loading

0 comments on commit a7f8db9

Please sign in to comment.