Skip to content

Commit

Permalink
fix(Button): make changes based on audit (#10610)
Browse files Browse the repository at this point in the history
* fix(Button): make changes based on audit

* docs(Button): add next folder back

* docs(Button): remove excess stories

* docs(Button): re-add stories for simplicity

Co-authored-by: Taylor Jones <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 2, 2022
1 parent cb0ccf9 commit 1cb3a75
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/react/src/components/Button/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ Button.propTypes = {
isExpressive: PropTypes.bool,

/**
* Specify whether the Button is currently selected
* Specify whether the Button is currently selected. Only applies to the Ghost variant.
*/
isSelected: PropTypes.bool,

Expand Down
130 changes: 130 additions & 0 deletions packages/react/src/components/Button/next/Button.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/**
* Copyright IBM Corp. 2016, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

import React from 'react';
import { action } from '@storybook/addon-actions';
import { Add16 } from '@carbon/icons-react';
import { default as Button, ButtonSkeleton } from '../';
import ButtonSet from '../../ButtonSet';

export default {
title: 'Components/Button',
component: Button,
subcomponents: {
ButtonSet,
ButtonSkeleton,
},
argTypes: {
kind: {
options: [
'primary',
'secondary',
'tertiary',
'ghost',
'danger',
'danger--tertiary',
'danger--ghost',
],
control: { type: 'select' },
},
size: {
options: ['sm', 'md', 'lg', 'xl', '2xl'],
control: { type: 'select' },
},
children: {
control: false,
},
renderIcon: {
control: false,
},
as: {
control: false,
},
small: {
table: {
disable: true,
},
},
},
};

export const _Default = (args) => {
return <Button {...args}>Button</Button>;
};

export const Secondary = (args) => {
return (
<Button kind="secondary" {...args}>
Button
</Button>
);
};

export const Tertiary = (args) => {
return (
<Button kind="tertiary" {...args}>
Button
</Button>
);
};

export const Danger = (args) => {
return (
<>
<Button kind="danger" {...args}>
Button
</Button>
&nbsp;
<Button kind="danger--tertiary" {...args}>
Tertiary Danger Button
</Button>
&nbsp;
<Button kind="danger--ghost" {...args}>
Ghost Danger Button
</Button>
</>
);
};

export const Ghost = (args) => {
return (
<Button kind="ghost" {...args}>
Button
</Button>
);
};

export const IconButton = (args) => (
<Button
renderIcon={Add16}
iconDescription="Icon Description"
hasIconOnly
onClick={action('onClick')}
{...args}
/>
);

export const SetOfButtons = (args) => {
return (
<ButtonSet>
<Button kind="secondary" {...args}>
Secondary button
</Button>
<Button kind="primary" {...args}>
Primary button
</Button>
</ButtonSet>
);
};

export const Skeleton = () => (
<div>
<ButtonSkeleton />
&nbsp;
<ButtonSkeleton size="sm" />
</div>
);
7 changes: 4 additions & 3 deletions packages/styles/scss/components/button/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@
transparent,
transparent,
$link-primary,
$background-hover,
$layer-hover,
currentColor,
$background-active
$layer-active
);

padding: $button-padding-ghost;
Expand Down Expand Up @@ -243,6 +243,7 @@

&:active {
border-color: $button-danger-active;
background-color: $button-danger-active;
color: $text-on-color;
}

Expand Down Expand Up @@ -334,7 +335,7 @@

//expressive styles
.#{$prefix}--btn--expressive {
@include type-style('body-short-02');
@include type-style('body-compact-02');

min-height: 3rem;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/styles/scss/components/button/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $button-focus-color: custom-property.get-var('button-focus-color', $focus);

@mixin button-base {
@include component-reset.reset;
@include type-style('body-short-01');
@include type-style('body-compact-01');

position: relative;
display: inline-flex;
Expand Down

0 comments on commit 1cb3a75

Please sign in to comment.