2019-03-05 05:46:57 +01:00
|
|
|
// @flow
|
2020-09-02 22:08:37 +02:00
|
|
|
import type { Node } from 'react';
|
2019-03-05 05:46:57 +01:00
|
|
|
import * as React from 'react';
|
|
|
|
import classnames from 'classnames';
|
2022-04-01 21:10:32 +02:00
|
|
|
// $FlowFixMe cannot resolve ...
|
|
|
|
import YrblHappy from 'static/img/yrblhappy.svg';
|
|
|
|
// $FlowFixMe cannot resolve ...
|
|
|
|
import YrblSad from 'static/img/yrblsad.svg';
|
2019-03-05 05:46:57 +01:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
title?: string,
|
|
|
|
subtitle?: string | React.Node,
|
|
|
|
type: string,
|
|
|
|
className?: string,
|
2020-09-02 22:08:37 +02:00
|
|
|
actions?: Node,
|
2020-12-11 19:33:27 +01:00
|
|
|
alwaysShow?: boolean,
|
2019-03-05 05:46:57 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
const yrblTypes = {
|
2022-04-01 21:10:32 +02:00
|
|
|
happy: YrblHappy,
|
|
|
|
sad: YrblSad,
|
2019-03-05 05:46:57 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export default class extends React.PureComponent<Props> {
|
|
|
|
static defaultProps = {
|
|
|
|
type: 'happy',
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
2020-12-16 19:31:07 +01:00
|
|
|
const { title, subtitle, type, className, actions, alwaysShow = false } = this.props;
|
2019-03-05 05:46:57 +01:00
|
|
|
|
|
|
|
const image = yrblTypes[type];
|
|
|
|
|
|
|
|
return (
|
2019-04-03 06:17:00 +02:00
|
|
|
<div className="yrbl__wrap">
|
2020-12-11 19:33:27 +01:00
|
|
|
<img
|
|
|
|
alt="Friendly gerbil"
|
2020-12-16 19:31:07 +01:00
|
|
|
className={classnames('yrbl', className, {
|
2020-12-11 19:33:27 +01:00
|
|
|
'yrbl--always-show': alwaysShow,
|
|
|
|
})}
|
|
|
|
src={`${image}`}
|
|
|
|
/>
|
2020-09-02 22:08:37 +02:00
|
|
|
<div>
|
2020-09-08 18:52:51 +02:00
|
|
|
{(title || subtitle) && (
|
2020-09-02 22:08:37 +02:00
|
|
|
<div className="yrbl__content">
|
|
|
|
<h2 className="section__title">{title}</h2>
|
|
|
|
<p className="section__subtitle">{subtitle}</p>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{actions}
|
|
|
|
</div>
|
2019-03-05 05:46:57 +01:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|