Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit 28b7d6e

Browse files
lucasecdbMatt Goo
authored and
Matt Goo
committed
feat(button): Add dense variant to button (#228)
1 parent 72c1b81 commit 28b7d6e

File tree

5 files changed

+15
-1
lines changed

5 files changed

+15
-1
lines changed

packages/button/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ className | String | Classes to be applied to the root element.
4646
raised | Boolean | Enables raised variant.
4747
unelevated | Boolean | Enables unelevated variant.
4848
outlined | Boolean | Enables outlined variant.
49+
dense | Boolean | Enables dense variant.
4950
icon | Element | Icon to render within root element.
5051
children | String | Text to be displayed within root element.
5152
disabled | Boolean | Disables button if true.

packages/button/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export class Button extends Component {
3232
raised,
3333
unelevated,
3434
outlined,
35+
dense,
3536
icon,
3637
children,
3738
initRipple,
@@ -43,6 +44,7 @@ export class Button extends Component {
4344
'mdc-button--raised': raised,
4445
'mdc-button--unelevated': unelevated,
4546
'mdc-button--outlined': outlined,
47+
'mdc-button--dense': dense,
4648
});
4749

4850
const SemanticButton = this.props.href ? 'a' : 'button';
@@ -76,6 +78,7 @@ Button.propTypes = {
7678
raised: PropTypes.bool,
7779
unelevated: PropTypes.bool,
7880
outlined: PropTypes.bool,
81+
dense: PropTypes.bool,
7982
disabled: PropTypes.bool,
8083
unbounded: PropTypes.bool,
8184
initRipple: PropTypes.func,
@@ -89,6 +92,7 @@ Button.defaultProps = {
8992
raised: false,
9093
unelevated: false,
9194
outlined: false,
95+
dense: false,
9296
disabled: false,
9397
unbounded: false,
9498
initRipple: () => {},

test/screenshot/button/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ const ButtonScreenshotTest = () => {
3939
<Button disabled raised>Disabled Raised</Button>
4040
</div>
4141

42+
<div className='button-container'>
43+
<Button dense>Dense</Button>
44+
</div>
45+
4246
<div className='button-container'>
4347
<Button href='https://google.com' raised>Anchor Tag</Button>
4448
</div>

test/screenshot/golden.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"button": "b01eeaad126491150baf47a736f5d5fbcfc284e62a47d91e9e50dcf1163925c1",
2+
"button": "a0cf6b2a5d09400657303bb2a7b220dbe33642a8f44fd7571cdfcf5517fb3586",
33
"card": "b2fd82763c383be438ff6578083bf9009711c7470333d07eb916ab690fc42d31",
44
"line-ripple": "56b136db2dc7e09260849447e6bde9b55a837af332a05d9f52506ab1c95e2e57",
55
"fab": "db36f52195c420062d91dd5ebe5432ad87247b3c1146fd547b0a195079bbce2f",

test/unit/button/index.test.js

+5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ test('renders an outlined button', () => {
3838
assert.isTrue(wrapper.hasClass('mdc-button--outlined'));
3939
});
4040

41+
test('renders a dense button', () => {
42+
const wrapper = shallow(<Button dense />);
43+
assert.isTrue(wrapper.hasClass('mdc-button--dense'));
44+
});
45+
4146
test('renders a button tag', () => {
4247
const wrapper = shallow(<Button />);
4348
assert.equal(wrapper.type(), 'button');

0 commit comments

Comments
 (0)