Skip to content

Commit

Permalink
Merge e1c2443 into 52e491b
Browse files Browse the repository at this point in the history
  • Loading branch information
blumendorf committed Dec 12, 2019
2 parents 52e491b + e1c2443 commit 375a632
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"access": "public"
},
"dependencies": {
"@lightelligence/styles": "1.2.1",
"@lightelligence/styles": "1.3.0",
"classnames": "^2.2.6",
"clipboard-copy": "^3.1.0",
"humps": "^2.0.1",
Expand Down
7 changes: 7 additions & 0 deletions src/components/Button/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const Button = React.forwardRef(
tag,
iconLeft,
iconRight,
loading,
onClick,
...props
},
Expand All @@ -38,6 +39,7 @@ export const Button = React.forwardRef(
iconLeft && olt.ButtonIconLeft,
iconRight && olt[`Icon${pascalize(iconRight)}`],
iconRight && olt.ButtonIconRight,
loading && olt.ButtonProgress,
className,
)}
>
Expand Down Expand Up @@ -75,6 +77,10 @@ Button.propTypes = {
* The `disabled` state of this button.
*/
disabled: bool,
/**
* The `laoding` state of this button.
*/
loading: bool,
/**
* The label of this button.
*/
Expand Down Expand Up @@ -108,6 +114,7 @@ Button.defaultProps = {
tag: 'button',
className: undefined,
disabled: undefined,
loading: false,
icon: undefined,
iconLeft: undefined,
iconRight: undefined,
Expand Down
17 changes: 17 additions & 0 deletions src/components/Button/Button.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,23 @@ import { Button } from '@lightelligence/react';
<Button disabled>Disabled</Button>;
```

### Loading

```js
import { Button, FloatingList } from '@lightelligence/react';
initialState = { loading: false};
const load = () => {
setState({ loading: true });
setTimeout(()=>setState({ loading: false }), 2500)
};

<FloatingList>
<Button onClick={load} loading={state.loading}>Spin Them</Button>
<Button onClick={load} emphasis="secondary" loading={state.loading}>Spin Them</Button>
<Button onClick={load} emphasis="tertiary" loading={state.loading}>Spin Them</Button>
</FloatingList>
```

### Emphasis

The emphasis of this button. Valid values are:
Expand Down
9 changes: 9 additions & 0 deletions src/components/Button/Button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ describe('Button', () => {
expect(button.classList.contains('myClass')).toBe(true);
});

test('correctly sets the css-modifier for loading', () => {
const { getByText } = renderButton({
children: 'Button',
loading: true,
});
const button = getByText('Button');
expect(button.classList.contains(oltStyles.ButtonProgress)).toBe(true);
});

test('correctly sets the css-modifier for emphasis secondary', () => {
const { getByText } = renderButton({
children: 'Button',
Expand Down

0 comments on commit 375a632

Please sign in to comment.