Skip to content

Commit

Permalink
FFE-198: Add condensed view for button
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin A. Midtsund committed May 18, 2017
1 parent 7d66387 commit 7e94c86
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
15 changes: 15 additions & 0 deletions examples/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,33 @@ function ButtonsExample() {
<div className="ffe-content-container">
<ActionButton>I'm an action button</ActionButton>
</div>
<div className="ffe-content-container">
<ActionButton condensed>Condensed action button</ActionButton>
</div>
<div className="ffe-content-container">
<PrimaryButton>I'm a primary button</PrimaryButton>
</div>
<div className="ffe-content-container">
<PrimaryButton condensed>Condensed primary button</PrimaryButton>
</div>
<div className="ffe-content-container">
<SecondaryButton>I'm a secondary button</SecondaryButton>
</div>
<div className="ffe-content-container">
<SecondaryButton condensed>Condensed secondary button</SecondaryButton>
</div>
<div className="ffe-content-container">
<ShortcutButton>I'm a shortcut button</ShortcutButton>
</div>
<div className="ffe-content-container">
<ShortcutButton condensed>Condensed shortcut button</ShortcutButton>
</div>
<div className="ffe-content-container">
<TertiaryButton>I'm a tertiary button</TertiaryButton>
</div>
<div className="ffe-content-container">
<TertiaryButton condensed>Condensed tertiary button</TertiaryButton>
</div>
<div className="ffe-content-container">
<BackButton>I'm a back button</BackButton>
</div>
Expand Down
7 changes: 5 additions & 2 deletions src/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { cloneElement, PropTypes } from 'react';

export default function Button(props) {
const decorate = (icon, buttonType) => cloneElement(icon, { className: `ffe-${buttonType}-button__label-icon` });

const {
action,
ariaLoadingMessage = 'Vennligst vent',
Expand All @@ -15,16 +14,19 @@ export default function Button(props) {
label,
leftIcon,
rightIcon,
condensed,
simpleContent = false,
...rest
} = props;

const loadingClass = isLoading ? `ffe-${buttonType}-button--loading` : '';
const condensedClass = condensed ? `ffe-${buttonType}-button--condensed` : '';

return (
<button
aria-disabled={disableButton}
aria-busy={isLoading}
className={`ffe-${buttonType}-button ${loadingClass} ${className}`}
className={`ffe-${buttonType}-button ${loadingClass} ${condensedClass} ${className}`}
data-action={action}
disabled={disableButton || isLoading}
{... isTabbable === false ? { tabIndex: -1 } : {}}
Expand Down Expand Up @@ -58,6 +60,7 @@ Button.propTypes = {
ariaLoadingMessage: PropTypes.string,
children: PropTypes.node,
className: PropTypes.string,
condensed: PropTypes.bool,
disableButton: PropTypes.bool,
buttonType: PropTypes.oneOf([
'action',
Expand Down
7 changes: 7 additions & 0 deletions src/Button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,12 @@ describe('Button', () => {
expect(wrapper.find('button').prop('autoFocus')).to.be.true;
});
});

describe('condensed', () => {
it('has condensed class', () => {
const button = shallow(<Button condensed={true} />);
expect(button).to.have.className('ffe-primary-button--condensed');
});
});
});
});

0 comments on commit 7e94c86

Please sign in to comment.