Skip to content

Commit 1200e62

Browse files
Jonathan Berneypivotal
authored andcommitted
feat(buttons): Buttons can now be full width
[Finishes #144221815] Signed-off-by: Elana Koren <ekoren@pivotal.io>
1 parent e17ebb6 commit 1200e62

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

library/spec/pivotal-ui-react/buttons/button_spec.js renamed to library/spec/pivotal-ui-react/buttons/buttons_spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ describe('UIButton', () => {
125125
});
126126
});
127127

128+
describe('when full width is true', () => {
129+
it('adds the full width class', () => {
130+
subject = renderComponent({fullWidth: true});
131+
const button = ReactTestUtils.findRenderedDOMComponentWithTag(subject, 'button');
132+
133+
expect(button).toHaveClass('btn-full');
134+
});
135+
});
136+
128137
describe('when small is true', () => {
129138
it('adds the small button class', () => {
130139
subject = renderComponent({small: true});

library/src/pivotal-ui-react/buttons/buttons.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@ export class UIButton extends React.Component {
1313
kind: PropTypes.oneOf(['default', 'danger', 'primary', 'brand']),
1414
large: PropTypes.bool,
1515
small: PropTypes.bool,
16+
fullWidth: PropTypes.bool,
1617
iconPosition: PropTypes.oneOf(['left', 'right'])
1718
}
1819

1920
static defaultProps = {
2021
kind: 'default',
2122
iconPosition: 'left'
22-
}
23+
};
2324

2425
render() {
25-
const {alt, flat, icon, iconPosition, iconOnly, large, small, kind, children, ...others} = this.props;
26+
const {alt, flat, icon, iconPosition, iconOnly, large, small, kind, children, fullWidth, ...others} = this.props;
2627

2728

2829
const buttonClasses = {
@@ -35,7 +36,8 @@ export class UIButton extends React.Component {
3536
'btn-lg': large,
3637
'btn-sm': small,
3738
'btn-icon': iconOnly,
38-
'btn-icon-right': !!icon && iconPosition === 'right'
39+
'btn-icon-right': !!icon && iconPosition === 'right',
40+
'btn-full': fullWidth
3941
}
4042
]
4143
};

library/src/pivotal-ui/components/buttons/buttons.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
}
7373
}
7474

75+
.btn-full {
76+
width: 100%;
77+
}
7578

7679
.btn-lg {
7780
height: $base-unit*5;

styleguide/docs/react/buttons.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ iconOnly | no | Boolean | false | If specified, will render as an ic
2323
iconPosition | no | String | | If specified, places the icon to the left or the right of the text and or children
2424
large | no | Boolean | false | Whether to render the button large
2525
small | no | Boolean | false | Whether to render the button small
26+
fullWidth | no | Boolean | false | Whether to render the button full width
2627
2728
## Basic usage
2829
@@ -90,6 +91,8 @@ parent: button_react
9091
---
9192
To make a button large, set the `large` property to true, to make it small, set `small` to true.
9293
94+
To make a button full width, set `fullWidth` to true.
95+
9396
```react_example_table
9497
<DefaultButton large>
9598
Big Button
@@ -102,6 +105,10 @@ Default
102105
<DefaultButton small>
103106
Small Button
104107
</DefaultButton>
108+
109+
<DefaultButton fullWidth>
110+
Full Width Button
111+
</DefaultButton>
105112
```
106113
107114
*/

0 commit comments

Comments
 (0)