ISSUE-005 - Further work on Workspaces. Re-using MenuItem component and figuring out a new method for hover-over highlighting using SASS & selection.
This commit is contained in:
1 parent
02132bdbe2
commit
5dcc3f3940
10 files changed
+86
-31
No files matched your search
@@ -0,0 +1,37 @@
|
|||||||
|
import styled, { css } from "styled-components";
|
||||||
|
import { PadBox } from "@bedrock-layout/padbox";
|
||||||
|
|
||||||
|
const hoverRules = css`
|
||||||
|
background: ${p => p.theme.colors.darkGrey};
|
||||||
|
color: white;
|
||||||
|
`;
|
||||||
|
|
||||||
|
export type MenuItemProps = {
|
||||||
|
isHovered?: boolean,
|
||||||
|
isActive?: boolean,
|
||||||
|
};
|
||||||
|
export const MenuItem = styled(PadBox).attrs(() => ({
|
||||||
|
padding: ["sm", "lg"],
|
||||||
|
})) <MenuItemProps>`
|
||||||
|
border-radius: ${p => p.theme.design.button.borderRadius};
|
||||||
|
color: ${p => p.theme.colors.darkGrey};
|
||||||
|
font-family: ${p => p.theme.fonts.f1Regular};
|
||||||
|
font-size: 0.8em;
|
||||||
|
|
||||||
|
${({ isActive }) => isActive && css`
|
||||||
|
background: ${p => p.theme.colors.lightGrey};
|
||||||
|
`}
|
||||||
|
${({ isHovered }) => {
|
||||||
|
// My cheap way of having uncontrolled hover behavior.
|
||||||
|
if (isHovered == null) {
|
||||||
|
return css`
|
||||||
|
&:hover {
|
||||||
|
${hoverRules}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
} else if (isHovered === true) {
|
||||||
|
return hoverRules;
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
`;
|
||||||
|
|
||||||
@@ -3,7 +3,8 @@ import { Link, NavLink } from "react-router-dom";
|
|||||||
import { InlineCluster } from "@bedrock-layout/inline-cluster";
|
import { InlineCluster } from "@bedrock-layout/inline-cluster";
|
||||||
import useForwardedRef from "@bedrock-layout/use-forwarded-ref";
|
import useForwardedRef from "@bedrock-layout/use-forwarded-ref";
|
||||||
|
|
||||||
import { MenuBar, MenuItem, Title } from "./styles";
|
import { MenuBar, Title } from "./styles";
|
||||||
|
import { MenuItem } from "../Common/MenuItem.styled";
|
||||||
|
|
||||||
import f1Logo from "../../public/images/logos/f1-logo-red.svg";
|
import f1Logo from "../../public/images/logos/f1-logo-red.svg";
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { InlineCluster } from "@bedrock-layout/inline-cluster";
|
import { InlineCluster } from "@bedrock-layout/inline-cluster";
|
||||||
import { PadBox } from "@bedrock-layout/padbox";
|
import { PadBox } from "@bedrock-layout/padbox";
|
||||||
import styled, { css } from "styled-components";
|
import styled from "styled-components";
|
||||||
|
|
||||||
export const Title = styled.h3`
|
export const Title = styled.h3`
|
||||||
font-family: ${p => p.theme.fonts.f1Bold};
|
font-family: ${p => p.theme.fonts.f1Bold};
|
||||||
@@ -16,25 +16,3 @@ export const MenuBar = styled(InlineCluster).attrs(() => ({
|
|||||||
background-image: linear-gradient(to right, #f0f0f0, #fff);
|
background-image: linear-gradient(to right, #f0f0f0, #fff);
|
||||||
border-block-end: 1px solid ${p => p.theme.colors.darkGrey};
|
border-block-end: 1px solid ${p => p.theme.colors.darkGrey};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
type MenuItemProps = {
|
|
||||||
isHovered?: boolean,
|
|
||||||
isActive?: boolean,
|
|
||||||
};
|
|
||||||
export const MenuItem = styled(PadBox).attrs(() => ({
|
|
||||||
padding: ["sm", "lg"],
|
|
||||||
}))<MenuItemProps>`
|
|
||||||
border-radius: 0.25rem;
|
|
||||||
color: ${p => p.theme.colors.darkGrey};
|
|
||||||
font-family: ${p => p.theme.fonts.f1Regular};
|
|
||||||
font-size: 0.8em;
|
|
||||||
|
|
||||||
${({ isActive }) => isActive && css`
|
|
||||||
background: ${p => p.theme.colors.lightGrey};
|
|
||||||
`}
|
|
||||||
|
|
||||||
${({ isHovered }) => isHovered && css`
|
|
||||||
background: ${p => p.theme.colors.darkGrey};
|
|
||||||
color: white;
|
|
||||||
`}
|
|
||||||
`;
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import { useParams } from "react-router-dom";
|
||||||
|
|
||||||
|
export const Workspace = () => {
|
||||||
|
const params = useParams();
|
||||||
|
return <h1>{params.workspaceName}</h1>;
|
||||||
|
|
||||||
|
};
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from "./Workspace";
|
||||||
@@ -1,10 +1,32 @@
|
|||||||
import { WorkspaceListBox } from "./styles";
|
import { WorkspaceListBox } from "./styles";
|
||||||
|
import { Stack } from "@bedrock-layout/stack";
|
||||||
|
import { NavLink } from "react-router-dom";
|
||||||
|
import { MenuItem } from "../../Common/MenuItem.styled";
|
||||||
|
|
||||||
export const WorkspaceList = () => (
|
export const WorkspaceList = () => (
|
||||||
<WorkspaceListBox>
|
<WorkspaceListBox>
|
||||||
<ul>
|
<Stack as="ul" gutter="md">
|
||||||
<li>what</li>
|
<WorkspaceListNavLink to="workspace1" label="Workspace 1" />
|
||||||
<li>what</li>
|
<WorkspaceListNavLink to="workspace2" label="Workspace 2" />
|
||||||
</ul>
|
<WorkspaceListNavLink to="workspace3" label="Workspace 3" />
|
||||||
|
<WorkspaceListNavLink to="workspace4" label="Workspace 4" />
|
||||||
|
<WorkspaceListNavLink to="workspace5" label="Workspace 5 is longer than the rest" />
|
||||||
|
</Stack>
|
||||||
</WorkspaceListBox>
|
</WorkspaceListBox>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
type WorkspaceListNavLinkProps = {
|
||||||
|
to: string,
|
||||||
|
label: string,
|
||||||
|
};
|
||||||
|
const WorkspaceListNavLink = ({ to, label }: WorkspaceListNavLinkProps) => (
|
||||||
|
<li>
|
||||||
|
<NavLink to={to} style={{ textDecoration: "none" }}>
|
||||||
|
{({ isActive }) => (
|
||||||
|
<MenuItem isActive={isActive}>
|
||||||
|
{label}
|
||||||
|
</MenuItem>
|
||||||
|
)}
|
||||||
|
</NavLink>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
@@ -2,7 +2,7 @@ import styled from "styled-components";
|
|||||||
import { PadBox } from "@bedrock-layout/padbox";
|
import { PadBox } from "@bedrock-layout/padbox";
|
||||||
|
|
||||||
export const WorkspaceListBox = styled(PadBox).attrs(() => ({
|
export const WorkspaceListBox = styled(PadBox).attrs(() => ({
|
||||||
padding: ["lg", "sm"],
|
padding: ["lg", "md"],
|
||||||
}))`
|
}))`
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export default function Workspaces() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<FullScreenContainer minHeight={700} minWidth={900} heightCutoff={height}>
|
<FullScreenContainer minHeight={700} minWidth={900} heightCutoff={height}>
|
||||||
<LayoutGrid columns={[1, 5]} rows={1}>
|
<LayoutGrid columns={["180px", 5]} rows={1}>
|
||||||
<LayoutGridItem column={1} row={1}>
|
<LayoutGridItem column={1} row={1}>
|
||||||
<WorkspaceList />
|
<WorkspaceList />
|
||||||
</LayoutGridItem>
|
</LayoutGridItem>
|
||||||
|
|||||||
+5
-1
@@ -9,6 +9,7 @@ import "./clear.css";
|
|||||||
import App from "./App";
|
import App from "./App";
|
||||||
import Broadcast from "./components/Broadcast/BroadcastRoute";
|
import Broadcast from "./components/Broadcast/BroadcastRoute";
|
||||||
import Workspaces from "./components/Workspaces/WorkspacesRoute";
|
import Workspaces from "./components/Workspaces/WorkspacesRoute";
|
||||||
|
import { Workspace } from "./components/Workspaces/Workspace";
|
||||||
|
|
||||||
import { GlobalStyle, theme } from "./shared/theme";
|
import { GlobalStyle, theme } from "./shared/theme";
|
||||||
import { GlobalFonts } from "./fonts";
|
import { GlobalFonts } from "./fonts";
|
||||||
@@ -23,11 +24,14 @@ ReactDOM.render(
|
|||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/" element={<App />}>
|
<Route path="/" element={<App />}>
|
||||||
|
<Route index element={<h1>Home</h1>} />
|
||||||
<Route path="broadcast" element={<Broadcast />} />
|
<Route path="broadcast" element={<Broadcast />} />
|
||||||
<Route path="workspaces" element={<Workspaces />}>
|
<Route path="workspaces" element={<Workspaces />}>
|
||||||
<Route path=":workspaceName" element={<div>What</div>} />
|
<Route index element={<h1>Workspaces Home</h1>} />
|
||||||
|
<Route path=":workspaceName" element={<Workspace />} />
|
||||||
</Route>
|
</Route>
|
||||||
</Route>
|
</Route>
|
||||||
|
<Route path="*" element={<h1>Page Not Found</h1>} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ export const theme = {
|
|||||||
darkGrey: "#303030",
|
darkGrey: "#303030",
|
||||||
videoFrameBG: "#333",
|
videoFrameBG: "#333",
|
||||||
},
|
},
|
||||||
|
design: {
|
||||||
|
button: {
|
||||||
|
borderRadius: "0.25rem",
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export type MainThemeProps = ThemeProps<typeof theme>;
|
export type MainThemeProps = ThemeProps<typeof theme>;
|
||||||
|
|||||||
Reference in new issue
Block a user