sudo-archive/src/components/Title.js

33 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-07-13 22:31:37 +00:00
import React from 'react';
2021-08-02 12:15:18 +00:00
import { useHistory } from 'react-router-dom';
2021-07-13 22:31:37 +00:00
import { useMovie } from '../hooks/useMovie'
import { Arrow } from '../components/Arrow'
import './Title.css'
// size: "big" | "medium" | "small" | null
// accent: string | null
// accentLink: string | null
export function Title(props) {
2021-08-02 12:15:18 +00:00
const { streamData, resetStreamData } = useMovie();
const history = useHistory();
2021-07-13 22:31:37 +00:00
const size = props.size || "big";
const accentLink = props.accentLink || "";
const accent = props.accent || "";
return (
<div>
{accent.length > 0 ? (
2021-08-02 12:15:18 +00:00
<p onClick={() => {
if (accentLink.length > 0) {
history.push(`/${streamData.type}`);
resetStreamData();
}
}} className={`title-accent ${accentLink.length > 0 ? 'title-accent-link' : ''}`}>
2021-07-13 22:31:37 +00:00
{accentLink.length > 0 ? (<Arrow left/>) : null}{accent}
</p>
) : null}
<h1 className={"title " + ( size ? 'title-size-' + size : '' )}>{props.children}</h1>
</div>
)
}