security-checklist/components/Header/index.js

78 lines
1.9 KiB
JavaScript
Raw Normal View History

// @flow
import * as React from 'react';
import Link from 'next/link';
2019-02-03 22:34:32 +00:00
import {
Container,
ButtonRowContainer,
Label,
LogoLink,
2019-02-03 22:34:32 +00:00
Progression,
2019-02-09 12:48:31 +00:00
ProgressBar,
ProgressLabel } from './style';
import { PrimaryButton, GhostButton } from '../Button';
2019-01-13 20:30:54 +00:00
import Logo from './Logo';
2019-02-09 10:50:37 +00:00
import Confetti from './Confetti';
type Props = {
showHeaderShadow: boolean,
2019-02-03 22:34:32 +00:00
displayProgress: boolean,
totalItemsCount: number,
currentCount: number,
};
export default function Header(props: Props) {
2019-02-03 22:34:32 +00:00
const { showHeaderShadow, totalItemsCount, currentCount, displayProgress } = props;
return (
<Container showHeaderShadow={showHeaderShadow} data-cy="header">
<div>
<Link href="/">
<LogoLink href="/">
<Label>Security Checklist</Label>
<Logo />
</LogoLink>
</Link>
</div>
<ButtonRowContainer>
<Link href="/about">
<GhostButton as="a" href="/about">
About
</GhostButton>
</Link>
<PrimaryButton
href="https://github.com/brianlovin/security-checklist"
target="_blank"
rel="noopener noreferrer"
as="a"
>
Contribute
</PrimaryButton>
</ButtonRowContainer>
2019-02-09 12:48:31 +00:00
{ displayProgress && (
<Progression
id="progress"
aria-label={`${currentCount} of ${totalItemsCount} completed`}
2019-02-09 13:30:13 +00:00
tabIndex="0"
2019-02-09 12:48:31 +00:00
>
<ProgressBar
id="progress_bar"
aria-describedby="progress_tooltip"
2019-02-13 14:43:40 +00:00
disabled={currentCount > 0 ? false : true}
2019-02-09 12:48:31 +00:00
/>
<ProgressLabel
id="progress_tooltip"
role="tooltip"
2019-02-09 13:52:35 +00:00
>
2019-02-13 17:31:23 +00:00
{ currentCount === totalItemsCount
2019-02-13 17:53:14 +00:00
? `🎉 Checklist complete! 🎉`
2019-02-13 17:31:23 +00:00
: `${currentCount} of ${totalItemsCount} completed`}
2019-02-09 13:52:35 +00:00
</ProgressLabel>
<Confetti fireConfetti={currentCount === totalItemsCount} />
2019-02-09 12:48:31 +00:00
</Progression>)}
</Container>
);
}