lbry-desktop/ui/component/common/nag.jsx

32 lines
895 B
React
Raw Normal View History

2019-12-06 22:12:48 +01:00
// @flow
2020-02-21 22:05:20 +01:00
import type { Node } from 'react';
2019-12-06 22:12:48 +01:00
import * as ICONS from 'constants/icons';
2020-02-26 19:39:03 +01:00
import classnames from 'classnames';
2019-12-06 22:12:48 +01:00
import React from 'react';
import Button from 'component/button';
type Props = {
2020-02-21 22:05:20 +01:00
message: string | Node,
2019-12-06 22:12:48 +01:00
actionText: string,
href?: string,
2020-02-26 19:39:03 +01:00
type?: string,
2019-12-06 22:12:48 +01:00
onClick?: () => void,
onClose?: () => void,
};
export default function Nag(props: Props) {
2020-02-26 19:39:03 +01:00
const { message, actionText, href, onClick, onClose, type } = props;
2019-12-06 22:12:48 +01:00
const buttonProps = onClick ? { onClick } : { href };
return (
2020-02-26 19:39:03 +01:00
<div className={classnames('nag', { 'nag--helpful': type === 'helpful' })}>
2019-12-06 22:12:48 +01:00
{message}
2020-02-26 19:39:03 +01:00
<Button className={classnames('nag__button', { 'nag__button--helpful': type === 'helpful' })} {...buttonProps}>
2019-12-06 22:12:48 +01:00
{actionText}
</Button>
{onClose && <Button className="nag__button nag__close" icon={ICONS.REMOVE} onClick={onClose} />}
</div>
);
}