2021-09-01 20:06:33 +09:00
|
|
|
import React from 'react';
|
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
|
2021-09-14 09:22:04 +09:00
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
2021-09-01 20:06:33 +09:00
|
|
|
export type HeaderProps = {
|
|
|
|
hasTopLink?: boolean;
|
|
|
|
};
|
|
|
|
|
2021-09-14 14:28:40 +09:00
|
|
|
const messageNumber = Math.floor(Math.random() * 6) + 1;
|
|
|
|
|
2021-09-01 20:06:33 +09:00
|
|
|
export const Header: React.FC<HeaderProps> = ({hasTopLink, children}) => {
|
2021-09-14 09:22:04 +09:00
|
|
|
const { t } = useTranslation();
|
2021-09-01 20:06:33 +09:00
|
|
|
return (
|
2021-09-14 14:28:40 +09:00
|
|
|
<header className={'xarticle card mt-5 mb-3'}>
|
2021-09-01 20:06:33 +09:00
|
|
|
<div className="body">
|
|
|
|
<h1 className="text-primary mb-0" style={{ fontSize: '2rem' }}>
|
2021-09-14 09:22:04 +09:00
|
|
|
{hasTopLink ? <Link to="/">{t('title')}</Link> : t('title')}
|
2021-09-01 20:06:33 +09:00
|
|
|
</h1>
|
2021-09-14 14:28:40 +09:00
|
|
|
<h2 className="text-dimmed ml-1">{t(`_welcomeMessage.pattern${messageNumber}`)}</h2>
|
2021-09-01 20:06:33 +09:00
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
</header>
|
|
|
|
);
|
|
|
|
};
|