Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝 docs(react-button): Fix not working controls and add more properties. #79

Merged
merged 1 commit into from
Apr 9, 2021
Merged
Changes from all commits
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
163 changes: 107 additions & 56 deletions packages/react-button/docs/button.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,56 +9,52 @@ export default {

const Template = args => <Button {...args} />;

export const primary = () => {
return (
<Box>
<BoxHeader title="Button Component"></BoxHeader>
<BoxBody>
<p>Some description here</p>
<BoxSection
title="As a button"
>
<Button
label="I'm a button"
/>
</BoxSection>

<BoxSection
title="As an anchor"
>
<Button
label="I'm an anchor"
href="#"
onClick={ ( e ) => e.preventDefault() }
/>
</BoxSection>

<BoxSection
title="As a label"
>
<Button
label="I'm a label"
htmlFor="nothing"
className="custom-class"
/>
</BoxSection>
</BoxBody>
</Box>
);
};
export const primary = Template.bind({});
primary.storyName = "Default";
primary.args = {
label: 'Button',
design: null,
color: null,
icon: null,
loading: null,
disabled: null,
className: null,
htmlFor: null,
href: null,
onClick: null,
};
primary.argTypes = {
label: {
description: 'The text that shows up in the button',
table: {
type: { summary: 'string' },
defaultValue: { summary: '' },
},
control: {
type: 'text'
}
},
design: {
description: 'The button style',
table: {
type: { summary: 'string' },
defaultValue: { summary: 'solid' },
},
control: {
type: "select",
options: ["", "ghost"]
options: ["solid", "ghost"]
}
},
color: {
description: 'The button color',
table: {
type: { summary: 'string' },
defaultValue: { summary: 'gray' },
},
control: {
type: "select",
options: [
"",
"gray",
"blue",
"green",
"red",
Expand All @@ -68,7 +64,77 @@ primary.argTypes = {
"white"
]
}
}
},
icon: {
description: 'Name of the icon to include in the button. Check out the <a href="https://wpmudev.github.io/shared-ui/icons/" target="_blank">available icons</a>',
table: {
type: { summary: 'string' },
defaultValue: { summary: 'null' },
},
control: {
type: 'text'
}
},
loading: {
description: 'Whether the button should show up as "loading"',
table: {
type: { summary: 'boolean' },
defaultValue: { summary: 'false' },
},
control: {
type: "boolean"
}
},
disabled: {
description: 'Whether the button should be disabled',
table: {
type: { summary: 'boolean' },
defaultValue: { summary: 'false' },
},
control: {
type: "boolean"
}
},
className: {
description: 'Extra classes to add to the button',
table: {
type: { summary: 'string' },
defaultValue: { summary: 'null' },
},
control: {
type: 'text'
}
},
htmlFor: {
description: 'When you want the button to be a label, provide the ID of the input it is a label for. Passing a value that is not `null` makes the button be a `<label>`',
table: {
type: { summary: 'string' },
defaultValue: { summary: 'null' },
},
control: {
type: 'text'
}
},
href: {
description: 'When you want the button to be an hyperlink, provide value of the `href` attribute. Passing a value that is not `null` makes the button be an `<a>`',
table: {
type: { summary: 'string' },
defaultValue: { summary: 'null' },
},
control: {
type: 'text'
}
},
onClick: {
description: 'Callback for the onClick event',
table: {
type: { summary: 'function' },
defaultValue: { summary: 'null' },
},
control: {
type: null
}
},
};

export const loading = Template.bind({});
Expand All @@ -77,26 +143,11 @@ loading.args = {
...primary.args,
loading: true
};
loading.argTypes = {
...primary.argTypes,
loading: {
control: {
type: "boolean"
}
}
};
loading.argTypes = primary.argTypes;

export const disabled = Template.bind({});
disabled.storyName = "Disabled";
disabled.args = {
...primary.args,
disabled: true
};
disabled.argTypes = {
...primary.argTypes,
disabled: {
control: {
type: "boolean"
}
}
};