import React, { VFC } from "react";
import styled, { css } from "styled-components";
import type { WithThemeSchemeProp } from "../types";
import { NamedColors } from "../utils/style";
import { ReactMonolithLogo } from "./icons";
interface PageHeaderProps {
currentModule?: "documentation" | "api-reference" | "blueprints";
}
const REACT_MONOLITH_LOGO_SIZE = 36;
const SIDE_MENU_WIDTH = 320;
export const PageHeader: VFC<PageHeaderProps & WithThemeSchemeProp> = ({
themeScheme,
}) => {
const invertThemeScheme = themeScheme === "light" ? "dark" : "light";
return (
<StyledPageHeader themeScheme={themeScheme}>
<StyledLogoArea themeScheme={themeScheme}>
<a href={"/"}>
<ReactMonolithLogo size={REACT_MONOLITH_LOGO_SIZE} />
<h1 style={{ margin: 0, marginLeft: 20 }}>React Monolith</h1>
</a>
</StyledLogoArea>
<StyledPageHeaderNav>
<a aria-label={"Documentation"} href={"/docs"}>
Documentation
</a>
<a aria-label={"API Reference"} href={"/api-reference"}>
API Reference
</a>
<a aria-label={"Blueprints"} href={"/blueprints"}>
Blueprints
</a>
<a aria-label={"Playground"} href={"/playground"}>
Playground
</a>
<a aria-label={"Contribute"} href={"/contribute"}>
Contribute
</a>
</StyledPageHeaderNav>
<StyledActionsArea>
<a
href={`/theme/${invertThemeScheme}`}
style={{ color: NamedColors.TEXT_MUTED[themeScheme] }}
title={`Click to enable ${
themeScheme === "light" ? "dark" : "light"
} mode`}
>
{`${themeScheme === "light" ? "Dark" : "Light"} mode`}
</a>
</StyledActionsArea>
</StyledPageHeader>
);
};
const StyledPageHeader = styled.header<WithThemeSchemeProp>`
display: flex;
flex-flow: row nowrap;
justify-content: flex-start;
align-items: center;
height: 100%;
width: 100%;
gap: 16px;
& a {
${({ themeScheme }) => css`
color: ${NamedColors.TEXT_MUTED[themeScheme]};
`};
transition: color 140ms ease-in-out 0s;
text-decoration: none;
&:hover {
${({ themeScheme }) => css`
color: ${NamedColors.TEXT_DEFAULT[themeScheme]};
`};
text-decoration: underline;
}
}
`;
const StyledLogoArea = styled.div<WithThemeSchemeProp>`
max-width: ${SIDE_MENU_WIDTH}px;
width: 100%;
& > a {
display: flex;
flex-flow: row nowrap;
justify-content: flex-start;
align-items: center;
${({ themeScheme }) => css`
color: ${NamedColors.TEXT_DEFAULT[themeScheme]};
`};
}
`;
const StyledPageHeaderNav = styled.nav`
display: flex;
flex-flow: row nowrap;
justify-content: flex-start;
align-items: center;
flex: 1;
height: 100%;
width: 100%;
gap: 24px;
margin-left: 4px;
a {
font-size: 20px;
line-height: 24px;
}
`;
const StyledActionsArea = styled.div`
display: flex;
flex-flow: row nowrap;
justify-content: flex-end;
align-items: center;
padding-right: 12px;
`;