Skip to content

Commit

Permalink
Merge c9d67d2 into f46d413
Browse files Browse the repository at this point in the history
  • Loading branch information
blumendorf committed Nov 19, 2019
2 parents f46d413 + c9d67d2 commit 5e3c70b
Show file tree
Hide file tree
Showing 202 changed files with 3,211 additions and 6,659 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.0.0-alpha.6",
"@lightelligence/styles": "^1.0.0-rc.1",
"@testing-library/jest-dom": "^4.2.3",
"classnames": "^2.2.6",
"clipboard-copy": "^3.1.0",
Expand Down
26 changes: 13 additions & 13 deletions src/components/ActionButton/ActionButton.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ It is responsive and on mobile devices only the icon is shown (unless you add th


```js
import { DataCards, DataCardsItem, ActionButton } from '@lightelligence/react';
import { CardTable, CardTableItem, ActionButton } from '@lightelligence/react';

const fields = [
{ key: 'id', label: '' },
Expand Down Expand Up @@ -58,21 +58,21 @@ const rows = [
},
];

<DataCards
<CardTable
fields={fields}
rows={rows}
align="center"
layout="table"
>
<DataCardsItem
<CardTableItem
align="center"
field="id"
/>
<DataCardsItem halfSize align="center" field="default" />
<DataCardsItem halfSize align="center" field="primary" />
<DataCardsItem halfSize align="center" field="destructive" />
<DataCardsItem halfSize align="center" field="confirmative" />
</DataCards>;
<CardTableItem halfSize align="center" field="default" />
<CardTableItem halfSize align="center" field="primary" />
<CardTableItem halfSize align="center" field="destructive" />
<CardTableItem halfSize align="center" field="confirmative" />
</CardTable>;
```

## Properties
Expand Down Expand Up @@ -197,19 +197,19 @@ import { ActionButton, FloatingList } from '@lightelligence/react';
<>
<p>
Disabled:
<ActionButton iconLeft="action-add-default" label="Disabled" disabled />
<ActionButton iconLeft="add-default" label="Disabled" disabled />
</p>
<p>
Standalone Disabled:
<ActionButton iconLeft="action-add-default" label="Standalone disabled" standalone disabled />
<ActionButton iconLeft="add-default" label="Standalone disabled" standalone disabled />
</p>
<p>
Base Disabled:
<ActionButton iconLeft="action-add-default" label="Base disabled" base disabled />
<ActionButton iconLeft="add-default" label="Base disabled" base disabled />
</p>
<p>
Standalone Base Disabled:
<ActionButton iconLeft="action-add-default" label="Standalone Base Disabled" standalone base disabled />
<ActionButton iconLeft="add-default" label="Standalone Base Disabled" standalone base disabled />
</p>
</>
```
Expand All @@ -224,7 +224,7 @@ import * as olt from '@lightelligence/styles';

<>
<div className={olt.ActionButtonProximityArea} style={{padding: '50px', border: '1px dotted lightgray'}}>
<ActionButton iconLeft="action-add-default" buttonType="primary" label="With Proximity" />
<ActionButton iconLeft="add-default" buttonType="primary" label="With Proximity" />
</div>
</>
```
139 changes: 99 additions & 40 deletions src/components/Button/Button.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,121 @@
import React from 'react';
import { pascalize } from 'humps';
import { string, bool, node, func } from 'prop-types';
import { string, bool, node, func, oneOf } from 'prop-types';
import classnames from 'classnames';
import * as olt from '@lightelligence/styles';

const Button = ({
className,
color,
outline,
children,
disabled,
tag,
icon,
onClick,
...props
}) => {
const Element = tag || 'button';
const Button = React.forwardRef(
(
{
className,
emphasis,
// avoid name clash with type which can be passed to input elements
buttonType,
theme,
children,
disabled,
tag,
iconLeft,
iconRight,
onClick,
...props
},
ref,
) => {
const Element = tag || 'button';
return (
<Element
disabled={disabled}
onClick={onClick}
ref={ref}
{...props}
className={classnames(
olt.Button,
emphasis && olt[`Button${pascalize(emphasis)}`],
buttonType && olt[`Button${pascalize(buttonType)}`],
theme && olt[`Button${pascalize(theme)}`],
iconLeft && olt[`Icon${pascalize(iconLeft)}`],
iconLeft && olt.ButtonIconLeft,
iconRight && olt[`Icon${pascalize(iconRight)}`],
iconRight && olt.ButtonIconRight,
className,
)}
>
{children}
</Element>
);
},
);

return (
<Element
onClick={onClick}
{...(Element === 'button' && disabled ? { disabled } : {})}
{...props}
className={classnames(
olt.Button,
color && olt[`Button${pascalize(color)}`],
outline && olt.ButtonOutline,
icon && olt.ButtonIcon,
icon && olt.IconSmall,
icon && olt[`Icon${pascalize(icon)}`],
className,
)}
>
{children}
</Element>
);
};
Button.displayName = 'Button';

Button.propTypes = {
tag: string,
/**
* The html tag that should be rendered for this button.
* Should be `button`, `input` or `a`.
*/
tag: oneOf(['button', 'input', 'a']),
/**
* Forward an additional className to the underlying component.
*/
className: string,
outline: bool,
/**
* Should the button be rendered as icon only.
*/
icon: string,
/**
* An icon that should be rendered to the left of the button label.
*/
iconLeft: string,
/**
* An icon that should be rendered to the right of the button label.
*/
iconRight: string,
/**
* The `disabled` state of this button.
*/
disabled: bool,
/**
* The label of this button.
*/
children: node,
color: string,
/**
* This function is called when a the button is clicked.
*/
onClick: func,
/**
* The emphasis of this button, by default its rendered with `primary`-emphasis.
*/
emphasis: oneOf(['primary', 'secondary', 'tertiary']),
/**
* The type of this button, by default its rendered as `default`.
*/
buttonType: oneOf([
'default',
'confirmative',
'destructive',
'action',
'paginationPrev',
'paginationNext',
]),
/**
* The theme of this button, by default its rendered with theme `light`.
*/
theme: oneOf(['light', 'dark']),
};

Button.defaultProps = {
tag: 'button',
className: null,
disabled: false,
icon: '',
outline: false,
className: undefined,
disabled: undefined,
icon: undefined,
iconLeft: undefined,
iconRight: undefined,
children: null,
color: undefined,
onClick: undefined,
emphasis: undefined,
buttonType: undefined,
theme: 'light',
};

export { Button };

0 comments on commit 5e3c70b

Please sign in to comment.