Skip to content

Commit

Permalink
button secondary housekeeping (#16495)
Browse files Browse the repository at this point in the history
* button secondary housekeeping

* add snapshot

* add export constants
  • Loading branch information
garrettbear authored Nov 15, 2022
1 parent f9ed4a5 commit d4bf8ad
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 6 deletions.
1 change: 1 addition & 0 deletions ui/components/component-library/button-primary/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { ButtonPrimary } from './button-primary';
export { BUTTON_PRIMARY_SIZES } from './button-primary.constants';
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import { ButtonSecondary } from '../ui/component-library/button/button-secondary

### Danger

Use the `danger` boolean prop to change the `ButtonPrimary` to danger color.
Use the `danger` boolean prop to change the `ButtonSecondary` to danger color.

<Canvas>
<Story id="ui-components-component-library-button-secondary-button-secondary-stories-js--danger" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ButtonSecondary should render button element correctly 1`] = `
<div>
<button
class="box mm-button mm-button--size-md mm-button-secondary box--padding-right-4 box--padding-left-4 box--display-inline-flex box--flex-direction-row box--justify-content-center box--align-items-center"
data-testid="button-secondary"
>
<span
class="box text mm-button__content text--body-md text--color-inherit box--gap-2 box--flex-direction-row box--justify-content-center box--align-items-center box--display-flex"
>
Button Secondary
</span>
</button>
</div>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ButtonSecondary.propTypes = {
*/
danger: PropTypes.bool,
/**
* The possible size values for ButtonSecondary: 'SIZES.SM', 'SIZES.MD', 'SIZES.LG',
* Possible size values: 'SIZES.SM'(32px), 'SIZES.MD'(40px), 'SIZES.LG'(48px).
* Default value is 'SIZES.MD'.
*/
size: PropTypes.oneOf(Object.values(BUTTON_SECONDARY_SIZES)),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import React from 'react';
import { ALIGN_ITEMS, DISPLAY } from '../../../helpers/constants/design-system';
import {
ALIGN_ITEMS,
DISPLAY,
SIZES,
} from '../../../helpers/constants/design-system';
import Box from '../../ui/box/box';
import { ICON_NAMES } from '../icon';
import { ButtonSecondary } from './button-secondary';
Expand Down Expand Up @@ -110,13 +114,13 @@ DefaultStory.storyName = 'Default';

export const Size = (args) => (
<Box display={DISPLAY.FLEX} alignItems={ALIGN_ITEMS.BASELINE} gap={1}>
<ButtonSecondary {...args} size={BUTTON_SECONDARY_SIZES.SM}>
<ButtonSecondary {...args} size={SIZES.SM}>
Small Button
</ButtonSecondary>
<ButtonSecondary {...args} size={BUTTON_SECONDARY_SIZES.MD}>
<ButtonSecondary {...args} size={SIZES.MD}>
Medium (Default) Button
</ButtonSecondary>
<ButtonSecondary {...args} size={BUTTON_SECONDARY_SIZES.LG}>
<ButtonSecondary {...args} size={SIZES.LG}>
Large Button
</ButtonSecondary>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('ButtonSecondary', () => {
expect(getByText('Button Secondary')).toBeDefined();
expect(container.querySelector('button')).toBeDefined();
expect(getByTestId('button-secondary')).toHaveClass('mm-button');
expect(container).toMatchSnapshot();
});

it('should render anchor element correctly', () => {
Expand Down
1 change: 1 addition & 0 deletions ui/components/component-library/button-secondary/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { ButtonSecondary } from './button-secondary';
export { BUTTON_SECONDARY_SIZES } from './button-secondary.constants';

0 comments on commit d4bf8ad

Please sign in to comment.