ISSUE-008 - Major refactor of the Menu Bar. Utilizing some really fun resize hooks and dropping the ugly route header idea.

This commit is contained in:
Kyle Geib committed 2021-12-22 15:57:31 -05:00
1 parent 73ba3b4ddd
commit f4ccb9b3dd
13 files changed
+86 -83

No files matched your search

-8
View File
@@ -1,8 +0,0 @@
import styled from "styled-components";
export const Nav = styled.nav`
border-bottom: solid 1px;
padding-bottom: 1rem;
padding-left: 1rem;
`;
Nav.displayName = "Nav";
@@ -1,16 +0,0 @@
import React from "react";
import { HeaderBar } from "./styles";
type RouteHeaderProps = {
title: string,
};
export const RouteHeader = React.forwardRef<HTMLHeadElement, RouteHeaderProps>(
(props, ref) => (
<HeaderBar ref={ref}>
{props.title}
</HeaderBar>
),
);
RouteHeader.displayName = "RouteHeader"; // Required due to forwardRef().
@@ -1 +0,0 @@
export * from "./RouteHeader";
@@ -1,14 +0,0 @@
import styled from "styled-components";
export const HeaderBar = styled.header`
top: 0;
left: 0;
right: 0;
z-index: 5;
padding: 0 0.3em;
background-color: ${p => p.theme.colors.grey};
height: 20px;
font-family: ${p => p.theme.fonts.accent};
font-size: 0.8em;
`;
HeaderBar.displayName = "HeaderBar";
+34 -20
View File
@@ -1,29 +1,43 @@
import { FC, Children } from "react";
import React, { Children } from "react";
import { Link } from "react-router-dom";
import { InlineCluster } from "@bedrock-layout/inline-cluster";
import useForwardedRef from "@bedrock-layout/use-forwarded-ref";
import { MenuBar, MenuItem } from "./styles";
import f1Logo from "../../public/images/logos/f1-logo-red.svg";
export const MainMenu = React.forwardRef<HTMLDivElement>(
(_, ref) => (
<Menu ref={ref} title="F1 World Broadcast Emulator Project">
<Link to="/">Home</Link>
<Link to="/broadcast">Broadcast Page</Link>
</Menu>
),
);
MainMenu.displayName = "MainMenu";
type MenuProps = {
children: React.ReactNode,
title: string,
};
export const Menu: FC<MenuProps> = ({
title,
children,
}) => {
const childrenArray = Children.toArray(children);
return (
<MenuBar>
<img src={f1Logo} alt="Formula One logo" height="20px"/>
<h3>{title}</h3>
<nav>
<InlineCluster as="ul" gutter="sm" justify="end">
{childrenArray.map((child, i) => (
<MenuItem key={i}>{child}</MenuItem>
))}
</InlineCluster>
</nav>
</MenuBar>
);
};
export const Menu = React.forwardRef<HTMLDivElement, MenuProps>(
(props, ref) => {
const innerRef = useForwardedRef(ref);
const childrenArray = Children.toArray(props.children);
return (
<MenuBar ref={innerRef}>
<img src={f1Logo} alt="Formula One logo" height="20px" />
<h3>{props.title}</h3>
<nav>
<InlineCluster as="ul" gutter="sm" justify="end">
{childrenArray.map((child, i) => (
<MenuItem key={i}>{child}</MenuItem>
))}
</InlineCluster>
</nav>
</MenuBar>
);
},
);
Menu.displayName = "Menu";
+3 -3
View File
@@ -10,7 +10,7 @@ export const MenuBar = styled(InlineCluster).attrs(() => ({
align: "center",
}))`
background-image: linear-gradient(to right, #f0f0f0, #fff);
border-block-end: 1px solid #303030;
border-block-end: 1px solid ${p => p.theme.colors.darkGrey};
`;
type MenuItemProps = {
@@ -22,12 +22,12 @@ export const MenuItem = styled(PadBox).attrs(() => ({
})) <MenuItemProps>`
border-radius: 0.25rem;
> a {
color: #333;
color: ${p => p.theme.colors.darkGrey};
text-decoration: none;
font-weight: 900;
}
:hover {
background: #303030;
background: ${p => p.theme.colors.darkGrey};
> a {
color: white;
}