Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Add storybook demo for CheckboxControl #3030

Merged
merged 2 commits into from
Dec 10, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions assets/js/base/components/checkbox-control/stories/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* External dependencies
*/
import { text } from '@storybook/addon-knobs';
import { useState } from 'react';

/**
* Internal dependencies
*/
import Component from '../';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like in other stories we are importing the components with their name (in this case, it would be CheckboxControl), and the story has a generic name (in some that I checked, it was named Default). Do you think we should keep it consistent here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I agree! I'll make this change


export default {
title: 'WooCommerce Blocks/@base-components/CheckboxControl',
component: CheckboxControl,
};

export const CheckboxControl = () => {
const [ checked, setChecked ] = useState( false );

return (
<Component
label={ text( 'Label', 'Yes please' ) }
checked={ checked }
onChange={ ( value ) => setChecked( value ) }
/>
);
};