Skip to content

Commit

Permalink
v2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Wendel committed Jul 11, 2016
1 parent 80c7681 commit 51f135d
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 175 deletions.
7 changes: 5 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
"extends": "airbnb",
"rules": {
"indent": [2, 4, { "SwitchCase": 1 }],
"react/jsx-indent": [2, 4],
"react/jsx-indent-props": [2, 4]
"react/jsx-indent": 0,
"react/jsx-indent-props": [2, 4],
"react/wrap-multilines": 0,
"eol-last": 0,
"comma-dangle": 0
},
"env": {
"mocha": true
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v2.3.0

* Buttons now accepts inline styles as a `style` prop

## v2.2.0

* Added tertiary button
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,11 @@ to disable a button, you can do this as well by setting the `disableButton` prop
```

This works for all button types, but make sure you have a really good reason for using it!

### Styling

Any style attributes given to a button component will be passed on to the underlying html button element.

```javascript
<Button style={{transform: 'rotate(30deg)'}}>...</Button>
```
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "ffe-button-react",
"version": "2.2.0",
"version": "2.3.0",
"description": "React implementation of ffe-button",
"main": "lib/index.js",
"scripts": {
"build": "babel -d lib/. --ignore=*.test.js src/.",
"lint": "eslint src/.",
"test:nsp": "nsp check",
"test:spec": "mocha --require babel-register --reporter mocha-tap13 src/**/*.test.js",
"test:spec": "mocha --require babel-register src/**/*.test.js",
"tdd": "mocha --require babel-register src/**/*.test.js -w",
"test": "npm run test:spec && npm run test:nsp",
"prepublish": "npm run build",
"has-published": "npm show . versions -s | grep -q ${npm_package_version}"
Expand Down
43 changes: 6 additions & 37 deletions src/ActionButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,12 @@ import React, { PropTypes } from 'react';
import Button from './Button';

export default function ActionButton(props) {
const {
action,
ariaLoadingMessage,
children,
disableButton,
id,
isLoading,
label,
onClick,
isTabbable,
} = props;

return (
<Button
action={action}
ariaLoadingMessage={ariaLoadingMessage}
disableButton={disableButton}
id={id}
isLoading={isLoading}
label={label}
onClick={onClick}
type="action"
isTabbable={isTabbable}
>
{children}
</Button>
);
return <Button {...props} type="action">
{props.children}
</Button>;
}


ActionButton.propTypes = {
action: PropTypes.string,
ariaLoadingMessage: PropTypes.string,
children: PropTypes.node,
disableButton: PropTypes.bool,
id: PropTypes.string,
isLoading: PropTypes.bool,
label: PropTypes.string,
onClick: PropTypes.func.isRequired,
isTabbable: PropTypes.bool,
};
children: PropTypes.node
};
4 changes: 4 additions & 0 deletions src/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ export default function Button(props) {
onClick,
type = 'primary',
simpleContent = false,
style = {},
isTabbable,
} = props;
const tabIndex = isTabbable ? 0 : -1;

return (
<button
onClick={onClick}
Expand All @@ -24,6 +26,7 @@ export default function Button(props) {
disabled={disableButton}
aria-disabled={disableButton}
tabIndex={tabIndex}
style={style}
>
{simpleContent ?
(label || children) :
Expand Down Expand Up @@ -58,4 +61,5 @@ Button.propTypes = {
type: PropTypes.string,
simpleContent: PropTypes.bool,
isTabbable: PropTypes.bool,
style: PropTypes.object
};
42 changes: 5 additions & 37 deletions src/PrimaryButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,11 @@ import React, { PropTypes } from 'react';
import Button from './Button';

export default function PrimaryButton(props) {
const {
action,
ariaLoadingMessage,
children,
disableButton,
id,
isLoading,
label,
onClick,
isTabbable,
} = props;

return (
<Button
action={action}
ariaLoadingMessage={ariaLoadingMessage}
disableButton={disableButton}
id={id}
isLoading={isLoading}
label={label}
onClick={onClick}
type="primary"
isTabbable={isTabbable}
>
{children}
</Button>
);
return <Button {...props} type="primary">
{props.children}
</Button>;
}

PrimaryButton.propTypes = {
action: PropTypes.string,
ariaLoadingMessage: PropTypes.string,
children: PropTypes.node,
disableButton: PropTypes.bool,
id: PropTypes.string,
isLoading: PropTypes.bool,
label: PropTypes.string,
onClick: PropTypes.func.isRequired,
isTabbable: PropTypes.bool,
};
children: PropTypes.node
};
43 changes: 6 additions & 37 deletions src/SecondaryButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,12 @@ import React, { PropTypes } from 'react';
import Button from './Button';

export default function SecondaryButton(props) {
const {
action,
ariaLoadingMessage,
children,
disableButton,
id,
isLoading,
label,
onClick,
isTabbable,
} = props;

return (
<Button
action={action}
ariaLoadingMessage={ariaLoadingMessage}
disableButton={disableButton}
id={id}
isLoading={isLoading}
label={label}
onClick={onClick}
type="secondary"
isTabbable={isTabbable}
>
{children}
</Button>
);
return <Button {...props} type="secondary">
{props.children}
</Button>;
}


SecondaryButton.propTypes = {
action: PropTypes.string,
ariaLoadingMessage: PropTypes.string,
children: PropTypes.node,
disableButton: PropTypes.bool,
id: PropTypes.string,
isLoading: PropTypes.bool,
label: PropTypes.string,
onClick: PropTypes.func.isRequired,
isTabbable: PropTypes.bool,
};
children: PropTypes.node
};
42 changes: 5 additions & 37 deletions src/ShortcutButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,11 @@ import React, { PropTypes } from 'react';
import Button from './Button';

export default function ShortcutButton(props) {
const {
action,
ariaLoadingMessage,
children,
disableButton,
id,
isLoading,
label,
onClick,
isTabbable,
} = props;

return (
<Button
action={action}
ariaLoadingMessage={ariaLoadingMessage}
disableButton={disableButton}
id={id}
isLoading={isLoading}
label={label}
onClick={onClick}
type="shortcut"
isTabbable={isTabbable}
>
{children}
</Button>
);
return <Button {...props} type="shortcut">
{props.children}
</Button>;
}

ShortcutButton.propTypes = {
action: PropTypes.string,
ariaLoadingMessage: PropTypes.string,
children: PropTypes.node,
disableButton: PropTypes.bool,
id: PropTypes.string,
isLoading: PropTypes.bool,
label: PropTypes.string,
onClick: PropTypes.func.isRequired,
isTabbable: PropTypes.bool,
};
children: PropTypes.node
};
26 changes: 3 additions & 23 deletions src/TertiaryButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,9 @@ import React, { PropTypes } from 'react';
import Button from './Button';

export default function TertiaryButton(props) {
const {
action,
children,
disableButton,
id,
label,
onClick,
isTabbable = true,
} = props;
return (
<Button
action={action}
disableButton={disableButton}
id={id}
label={label}
onClick={onClick}
type="tertiary"
simpleContent
isTabbable={isTabbable}
>
{children}
</Button>
);
return <Button {...props} type="tertiary" simpleContent>
{props.children}
</Button>;
}

TertiaryButton.propTypes = {
Expand Down

0 comments on commit 51f135d

Please sign in to comment.