lbry-desktop/ui/component/yrbl/index.jsx

46 lines
1 KiB
React
Raw Normal View History

2019-03-04 23:46:57 -05:00
// @flow
2020-09-02 16:08:37 -04:00
import type { Node } from 'react';
2019-03-04 23:46:57 -05:00
import * as React from 'react';
import classnames from 'classnames';
import { YRBL_HAPPY_IMG_URL, YRBL_SAD_IMG_URL } from 'config';
2019-03-04 23:46:57 -05:00
type Props = {
title?: string,
subtitle?: string | React.Node,
type: string,
className?: string,
2020-09-02 16:08:37 -04:00
actions?: Node,
2019-03-04 23:46:57 -05:00
};
const yrblTypes = {
happy: YRBL_HAPPY_IMG_URL,
sad: YRBL_SAD_IMG_URL,
2019-03-04 23:46:57 -05:00
};
export default class extends React.PureComponent<Props> {
static defaultProps = {
type: 'happy',
};
render() {
2020-09-02 16:08:37 -04:00
const { title, subtitle, type, className, actions } = this.props;
2019-03-04 23:46:57 -05:00
const image = yrblTypes[type];
return (
<div className="yrbl__wrap">
2019-04-04 00:40:28 -04:00
<img alt="Friendly gerbil" className={classnames('yrbl', className)} src={`${image}`} />
2020-09-02 16:08:37 -04:00
<div>
2020-09-08 12:52:51 -04:00
{(title || subtitle) && (
2020-09-02 16:08:37 -04:00
<div className="yrbl__content">
<h2 className="section__title">{title}</h2>
<p className="section__subtitle">{subtitle}</p>
</div>
)}
{actions}
</div>
2019-03-04 23:46:57 -05:00
</div>
);
}
}