Skip to content

Commit

Permalink
ts - stick to convention for function props
Browse files Browse the repository at this point in the history
  • Loading branch information
xeger committed Oct 26, 2018
1 parent 1b6a5c9 commit 9bb8ff2
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/components/Alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ export default class Alert extends React.Component {
icon: PropTypes.bool,
className: PropTypes.string,
onToggle: PropTypes.func
}
};

static defaultProps = {
className: '',
color: 'warning',
dismissible: false,
icon: false,
onToggle: null
}
onToggle: () => {}
};

static displayName = 'Alert';

Expand All @@ -41,15 +41,22 @@ export default class Alert extends React.Component {
toggle = () => {
const visible = !this.state.visible;
this.setState({ visible });
if (this.props.onToggle) this.props.onToggle(visible);
}
this.props.onToggle(visible);
};

componentWillReceiveProps() {
this.setState({ visible: true });
}

render() {
const { color, children, className, dismissible, icon, ...props } = this.props;
const {
color,
children,
className,
dismissible,
icon,
...props
} = this.props;

return (
<AlertComponent
Expand All @@ -60,8 +67,14 @@ export default class Alert extends React.Component {
{...props}
>
<div className="d-flex align-items-start">
{icon ? <Icon name={ICON_MAP[color]} size="lg" className="mr-3 mt-1" /> : null}
{icon ? <div style={{ overflow: 'hidden' }}>{children}</div> : <div>{children}</div>}
{icon ? (
<Icon name={ICON_MAP[color]} size="lg" className="mr-3 mt-1" />
) : null}
{icon ? (
<div style={{ overflow: 'hidden' }}>{children}</div>
) : (
<div>{children}</div>
)}
</div>
</AlertComponent>
);
Expand Down

0 comments on commit 9bb8ff2

Please sign in to comment.