From 02132bdbe296f8087c3e8a529d3681c44428d7f9 Mon Sep 17 00:00:00 2001 From: Kyle Geib Date: Thu, 6 Jan 2022 18:40:59 -0500 Subject: [PATCH 1/6] ISSUE-005 - Initial work commit. Have some basic routing done and some mocked-up design of how the pay may look. Made improvements to the LayoutGrid component, supporting richer definition of grid columns and rows. --- package.json | 1 + .../Broadcast}/BroadcastRoute.tsx | 6 +-- src/components/Broadcast/Layout/Layout.tsx | 2 +- src/components/Broadcast/Layout/styles.ts | 31 ----------- .../Common/FullScreenContainer.styled.ts} | 4 +- src/components/Common/LayoutGrid.styled.ts | 53 +++++++++++++++++++ src/components/Menu/Menu.tsx | 1 + .../WorkspaceList/WorkspaceList.tsx | 10 ++++ .../Workspaces/WorkspaceList/index.ts | 1 + .../Workspaces/WorkspaceList/styles.ts | 11 ++++ src/components/Workspaces/WorkspacesRoute.tsx | 25 +++++++++ src/index.tsx | 9 +++- yarn.lock | 7 +++ 13 files changed, 122 insertions(+), 39 deletions(-) rename src/{routes => components/Broadcast}/BroadcastRoute.tsx (58%) delete mode 100644 src/components/Broadcast/Layout/styles.ts rename src/{routes/styles.ts => components/Common/FullScreenContainer.styled.ts} (98%) create mode 100644 src/components/Common/LayoutGrid.styled.ts create mode 100644 src/components/Workspaces/WorkspaceList/WorkspaceList.tsx create mode 100644 src/components/Workspaces/WorkspaceList/index.ts create mode 100644 src/components/Workspaces/WorkspaceList/styles.ts create mode 100644 src/components/Workspaces/WorkspacesRoute.tsx diff --git a/package.json b/package.json index 8dc2600..13b7adc 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "dependencies": { "@bedrock-layout/appboundary": "^2.2.4", "@bedrock-layout/columns": "^2.3.4", + "@bedrock-layout/cover": "^2.2.5", "@bedrock-layout/frame": "^2.2.4", "@bedrock-layout/inline": "^2.3.3", "@bedrock-layout/inline-cluster": "^2.4.2", diff --git a/src/routes/BroadcastRoute.tsx b/src/components/Broadcast/BroadcastRoute.tsx similarity index 58% rename from src/routes/BroadcastRoute.tsx rename to src/components/Broadcast/BroadcastRoute.tsx index dd6b436..1040288 100644 --- a/src/routes/BroadcastRoute.tsx +++ b/src/components/Broadcast/BroadcastRoute.tsx @@ -1,8 +1,8 @@ import { useSelector } from "react-redux"; -import { FullScreenContainer } from "./styles"; -import { Layout } from "../components/Broadcast/Layout"; -import { menuSelector } from "../features/pageDimensions/pageDimensionsSelector"; +import { FullScreenContainer } from "../Common/FullScreenContainer.styled"; +import { Layout } from "./Layout"; +import { menuSelector } from "../../features/pageDimensions/pageDimensionsSelector"; export default function Broadcast() { const { height } = useSelector(menuSelector); diff --git a/src/components/Broadcast/Layout/Layout.tsx b/src/components/Broadcast/Layout/Layout.tsx index daaaaed..1e1f818 100644 --- a/src/components/Broadcast/Layout/Layout.tsx +++ b/src/components/Broadcast/Layout/Layout.tsx @@ -1,6 +1,6 @@ import { MockupBlock } from "../../Common/MockupBlock.styled"; import VideoFeed from "../VideoFeed/VideoFeed"; -import { LayoutGrid, LayoutGridItem } from "./styles"; +import { LayoutGrid, LayoutGridItem } from "../../Common/LayoutGrid.styled"; type LayoutProps = { headerHeight?: number, diff --git a/src/components/Broadcast/Layout/styles.ts b/src/components/Broadcast/Layout/styles.ts deleted file mode 100644 index 8026b74..0000000 --- a/src/components/Broadcast/Layout/styles.ts +++ /dev/null @@ -1,31 +0,0 @@ -import styled from "styled-components"; - -type LayoutGridProps = { - columns?: number, - rows?: number, - headerOffset?: number, -}; -export const LayoutGrid = styled.div` - --columns: ${({ columns = 1 }) => columns}; - --rows: ${({ rows = 1 }) => rows}; - display: grid; - grid-template-columns: repeat(var(--columns), 1fr); - grid-template-rows: repeat(var(--rows), 1fr); - height: calc(100% - ${({ headerOffset = 0 }) => headerOffset}px); - width: 100%; -`; -LayoutGrid.displayName = "LayoutGrid"; - -type LayoutGridItemProps = { - column: number, - columnSpan?: number, - row: number, - rowSpan?: number, -}; -export const LayoutGridItem = styled.div` - grid-column: ${({ column }) => column} - / span ${({ columnSpan = 1 }) => columnSpan}; - grid-row: ${({ row }) => row} - / span ${({ rowSpan = 1 }) => rowSpan};; -`; -LayoutGridItem.displayName = "LayoutGridItem"; diff --git a/src/routes/styles.ts b/src/components/Common/FullScreenContainer.styled.ts similarity index 98% rename from src/routes/styles.ts rename to src/components/Common/FullScreenContainer.styled.ts index c81523a..0173b27 100644 --- a/src/routes/styles.ts +++ b/src/components/Common/FullScreenContainer.styled.ts @@ -10,8 +10,8 @@ type FullScreenContainerProps = { export const FullScreenContainer = styled.div` --minHeight: ${({ minHeight = 0 }) => `${minHeight}px`}; --minWidth: ${({ minWidth = 0 }) => `${minWidth}px`}; - --overflowY: ${({ minHeight }) => minHeight ? "scroll" : "hidden" }; - --overflowX: ${({ minWidth }) => minWidth ? "scroll" : "hidden" }; + --overflowY: ${({ minHeight }) => minHeight ? "scroll" : "hidden"}; + --overflowX: ${({ minWidth }) => minWidth ? "scroll" : "hidden"}; --heightCutoff: ${({ heightCutoff = 0 }) => `${heightCutoff}px`}; --widthCutoff: ${({ widthCutoff = 0 }) => `${widthCutoff}px`}; diff --git a/src/components/Common/LayoutGrid.styled.ts b/src/components/Common/LayoutGrid.styled.ts new file mode 100644 index 0000000..cc8bd40 --- /dev/null +++ b/src/components/Common/LayoutGrid.styled.ts @@ -0,0 +1,53 @@ +import styled from "styled-components"; + +type SizeProp = number | Array; + +/** + * Slickly handle different values + * @param prop a number will use 1fr repeated. An array will interpret numbers + * as fractions. Else you can define anything with strings (such as "100px"). + * @returns + */ +const parseSize = (prop: SizeProp): string => { + if (typeof prop === "number") { + return `repeat(${prop}, 1fr)`; + } + if (Array.isArray(prop)) { + return prop.map(value => { + if (typeof value === "number") { + return value + "fr"; + } else { + return value; + } + }).join(" "); + } + return "1"; +}; + +type LayoutGridProps = { + columns?: SizeProp, + rows?: SizeProp, + headerOffset?: number, +}; +export const LayoutGrid = styled.div` + display: grid; + grid-template-columns: ${({ columns = 1 }) => parseSize(columns)}; + grid-template-rows: ${({ rows = 1 }) => parseSize(rows)}; + height: calc(100% - ${({ headerOffset = 0 }) => headerOffset}px); + width: 100%; +`; +LayoutGrid.displayName = "LayoutGrid"; + +type LayoutGridItemProps = { + column: number, + columnSpan?: number, + row: number, + rowSpan?: number, +}; +export const LayoutGridItem = styled.div` + grid-column: ${({ column }) => column} + / span ${({ columnSpan = 1 }) => columnSpan}; + grid-row: ${({ row }) => row} + / span ${({ rowSpan = 1 }) => rowSpan};; +`; +LayoutGridItem.displayName = "LayoutGridItem"; diff --git a/src/components/Menu/Menu.tsx b/src/components/Menu/Menu.tsx index 5241e18..a18d375 100644 --- a/src/components/Menu/Menu.tsx +++ b/src/components/Menu/Menu.tsx @@ -15,6 +15,7 @@ export const MainMenu = React.forwardRef( links={[ { label: "Home", to: "/" }, { label: "Broadcast Page", to: "/broadcast" }, + { label: "Workspaces", to: "/workspaces" }, ]} /> ), diff --git a/src/components/Workspaces/WorkspaceList/WorkspaceList.tsx b/src/components/Workspaces/WorkspaceList/WorkspaceList.tsx new file mode 100644 index 0000000..84dc897 --- /dev/null +++ b/src/components/Workspaces/WorkspaceList/WorkspaceList.tsx @@ -0,0 +1,10 @@ +import { WorkspaceListBox } from "./styles"; + +export const WorkspaceList = () => ( + +
    +
  • what
  • +
  • what
  • +
+
+); diff --git a/src/components/Workspaces/WorkspaceList/index.ts b/src/components/Workspaces/WorkspaceList/index.ts new file mode 100644 index 0000000..3b1890b --- /dev/null +++ b/src/components/Workspaces/WorkspaceList/index.ts @@ -0,0 +1 @@ +export * from "./WorkspaceList"; diff --git a/src/components/Workspaces/WorkspaceList/styles.ts b/src/components/Workspaces/WorkspaceList/styles.ts new file mode 100644 index 0000000..c1491bb --- /dev/null +++ b/src/components/Workspaces/WorkspaceList/styles.ts @@ -0,0 +1,11 @@ +import styled from "styled-components"; +import { PadBox } from "@bedrock-layout/padbox"; + +export const WorkspaceListBox = styled(PadBox).attrs(() => ({ + padding: ["lg", "sm"], +}))` + height: 100%; + width: 100%; + background-image: linear-gradient(to bottom, #f0f0f0, #fff); + border-right: 1px solid ${p => p.theme.colors.darkGrey}; +`; diff --git a/src/components/Workspaces/WorkspacesRoute.tsx b/src/components/Workspaces/WorkspacesRoute.tsx new file mode 100644 index 0000000..669f109 --- /dev/null +++ b/src/components/Workspaces/WorkspacesRoute.tsx @@ -0,0 +1,25 @@ +import { useSelector } from "react-redux"; +import { Outlet } from "react-router-dom"; + +import { menuSelector } from "../../features/pageDimensions/pageDimensionsSelector"; + +import { FullScreenContainer } from "../Common/FullScreenContainer.styled"; +import { WorkspaceList } from "./WorkspaceList"; +import { LayoutGrid, LayoutGridItem } from "../Common/LayoutGrid.styled"; + +export default function Workspaces() { + const { height } = useSelector(menuSelector); + + return ( + + + + + + + + + + + ); +} diff --git a/src/index.tsx b/src/index.tsx index 20efb90..1468da0 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -7,7 +7,9 @@ import { ThemeProvider } from "styled-components"; import "./clear.css"; import App from "./App"; -import Broadcast from "./routes/BroadcastRoute"; +import Broadcast from "./components/Broadcast/BroadcastRoute"; +import Workspaces from "./components/Workspaces/WorkspacesRoute"; + import { GlobalStyle, theme } from "./shared/theme"; import { GlobalFonts } from "./fonts"; import { store } from "./store"; @@ -21,7 +23,10 @@ ReactDOM.render( } > - } /> + } /> + }> + What} /> + diff --git a/yarn.lock b/yarn.lock index da70954..1d64612 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1092,6 +1092,13 @@ "@bedrock-layout/use-container-query" "^1.2.14" "@bedrock-layout/use-forwarded-ref" "^1.1.11" +"@bedrock-layout/cover@^2.2.5": + version "2.2.5" + resolved "https://registry.yarnpkg.com/@bedrock-layout/cover/-/cover-2.2.5.tgz#281d90719924a3e7bfa6d228b0c44235fede57ca" + integrity sha512-M2r8aZE7dCvluaSCBQ8kGktZ4L00LlF2Uxp3kZA1lAO/Y3fAocqVnp4apxZW5Wvmh7QPDZb4Ll+qE+d9YlxcNQ== + dependencies: + "@bedrock-layout/spacing-constants" "^2.5.1" + "@bedrock-layout/frame@^2.2.4": version "2.2.4" resolved "https://registry.yarnpkg.com/@bedrock-layout/frame/-/frame-2.2.4.tgz#7c124718e0543ec1b53903788d040d05a9e8e1de" From 5dcc3f3940db17b3e5f14a76b03dd71683bc9250 Mon Sep 17 00:00:00 2001 From: Kyle Geib Date: Fri, 7 Jan 2022 12:47:12 -0500 Subject: [PATCH 2/6] ISSUE-005 - Further work on Workspaces. Re-using MenuItem component and figuring out a new method for hover-over highlighting using SASS & selection. --- src/components/Common/MenuItem.styled.ts | 37 +++++++++++++++++++ src/components/Menu/Menu.tsx | 3 +- src/components/Menu/styles.ts | 24 +----------- .../Workspaces/Workspace/Workspace.tsx | 7 ++++ src/components/Workspaces/Workspace/index.ts | 1 + .../WorkspaceList/WorkspaceList.tsx | 30 +++++++++++++-- .../Workspaces/WorkspaceList/styles.ts | 2 +- src/components/Workspaces/WorkspacesRoute.tsx | 2 +- src/index.tsx | 8 +++- src/shared/theme.ts | 5 +++ 10 files changed, 87 insertions(+), 32 deletions(-) create mode 100644 src/components/Common/MenuItem.styled.ts create mode 100644 src/components/Workspaces/Workspace/Workspace.tsx create mode 100644 src/components/Workspaces/Workspace/index.ts diff --git a/src/components/Common/MenuItem.styled.ts b/src/components/Common/MenuItem.styled.ts new file mode 100644 index 0000000..eb73e53 --- /dev/null +++ b/src/components/Common/MenuItem.styled.ts @@ -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"], +})) ` + 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; + } + }} +`; + diff --git a/src/components/Menu/Menu.tsx b/src/components/Menu/Menu.tsx index a18d375..d5c68f3 100644 --- a/src/components/Menu/Menu.tsx +++ b/src/components/Menu/Menu.tsx @@ -3,7 +3,8 @@ import { Link, NavLink } from "react-router-dom"; import { InlineCluster } from "@bedrock-layout/inline-cluster"; 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"; diff --git a/src/components/Menu/styles.ts b/src/components/Menu/styles.ts index ea35d5e..e095306 100644 --- a/src/components/Menu/styles.ts +++ b/src/components/Menu/styles.ts @@ -1,6 +1,6 @@ import { InlineCluster } from "@bedrock-layout/inline-cluster"; import { PadBox } from "@bedrock-layout/padbox"; -import styled, { css } from "styled-components"; +import styled from "styled-components"; export const Title = styled.h3` 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); 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"], -}))` - 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; - `} -`; diff --git a/src/components/Workspaces/Workspace/Workspace.tsx b/src/components/Workspaces/Workspace/Workspace.tsx new file mode 100644 index 0000000..d280c63 --- /dev/null +++ b/src/components/Workspaces/Workspace/Workspace.tsx @@ -0,0 +1,7 @@ +import { useParams } from "react-router-dom"; + +export const Workspace = () => { + const params = useParams(); + return

{params.workspaceName}

; + +}; diff --git a/src/components/Workspaces/Workspace/index.ts b/src/components/Workspaces/Workspace/index.ts new file mode 100644 index 0000000..4e8fed9 --- /dev/null +++ b/src/components/Workspaces/Workspace/index.ts @@ -0,0 +1 @@ +export * from "./Workspace"; diff --git a/src/components/Workspaces/WorkspaceList/WorkspaceList.tsx b/src/components/Workspaces/WorkspaceList/WorkspaceList.tsx index 84dc897..b3fb792 100644 --- a/src/components/Workspaces/WorkspaceList/WorkspaceList.tsx +++ b/src/components/Workspaces/WorkspaceList/WorkspaceList.tsx @@ -1,10 +1,32 @@ 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 = () => ( -
    -
  • what
  • -
  • what
  • -
+ + + + + + +
); + +type WorkspaceListNavLinkProps = { + to: string, + label: string, +}; +const WorkspaceListNavLink = ({ to, label }: WorkspaceListNavLinkProps) => ( +
  • + + {({ isActive }) => ( + + {label} + + )} + +
  • +); diff --git a/src/components/Workspaces/WorkspaceList/styles.ts b/src/components/Workspaces/WorkspaceList/styles.ts index c1491bb..b35772c 100644 --- a/src/components/Workspaces/WorkspaceList/styles.ts +++ b/src/components/Workspaces/WorkspaceList/styles.ts @@ -2,7 +2,7 @@ import styled from "styled-components"; import { PadBox } from "@bedrock-layout/padbox"; export const WorkspaceListBox = styled(PadBox).attrs(() => ({ - padding: ["lg", "sm"], + padding: ["lg", "md"], }))` height: 100%; width: 100%; diff --git a/src/components/Workspaces/WorkspacesRoute.tsx b/src/components/Workspaces/WorkspacesRoute.tsx index 669f109..6ae8376 100644 --- a/src/components/Workspaces/WorkspacesRoute.tsx +++ b/src/components/Workspaces/WorkspacesRoute.tsx @@ -12,7 +12,7 @@ export default function Workspaces() { return ( - + diff --git a/src/index.tsx b/src/index.tsx index 1468da0..e9cb396 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -9,6 +9,7 @@ import "./clear.css"; import App from "./App"; import Broadcast from "./components/Broadcast/BroadcastRoute"; import Workspaces from "./components/Workspaces/WorkspacesRoute"; +import { Workspace } from "./components/Workspaces/Workspace"; import { GlobalStyle, theme } from "./shared/theme"; import { GlobalFonts } from "./fonts"; @@ -22,12 +23,15 @@ ReactDOM.render( - } > + }> + Home} /> } /> }> - What} /> + Workspaces Home} /> + } /> + Page Not Found} /> diff --git a/src/shared/theme.ts b/src/shared/theme.ts index c1a0fb9..5197434 100644 --- a/src/shared/theme.ts +++ b/src/shared/theme.ts @@ -19,6 +19,11 @@ export const theme = { darkGrey: "#303030", videoFrameBG: "#333", }, + design: { + button: { + borderRadius: "0.25rem", + }, + }, }; export type MainThemeProps = ThemeProps; From ab4c8eefa62a5b88ab6a6ffd002e76e69a8fb22f Mon Sep 17 00:00:00 2001 From: Kyle Geib Date: Fri, 7 Jan 2022 18:03:27 -0500 Subject: [PATCH 3/6] ISSUE-005 - Implemented a PreviewWindow component. Improvements to the way that the workspaces are generated. Using mock components. --- package.json | 1 + .../Workspaces/Workspace/Workspace.tsx | 31 ++++++++++++++++-- .../Workspace/WorkspaceControls.tsx | 11 +++++++ src/components/Workspaces/Workspace/styles.ts | 29 ++++++++++++++++ .../WorkspaceList/WorkspaceList.tsx | 9 +++-- src/components/Workspaces/workspaces.ts | 28 ++++++++++++++++ src/index.tsx | 2 +- src/public/images/misc/checker-40x40.png | Bin 0 -> 2852 bytes yarn.lock | 7 ++++ 9 files changed, 109 insertions(+), 9 deletions(-) create mode 100644 src/components/Workspaces/Workspace/WorkspaceControls.tsx create mode 100644 src/components/Workspaces/Workspace/styles.ts create mode 100644 src/components/Workspaces/workspaces.ts create mode 100644 src/public/images/misc/checker-40x40.png diff --git a/package.json b/package.json index 13b7adc..057ca60 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "private": true, "dependencies": { "@bedrock-layout/appboundary": "^2.2.4", + "@bedrock-layout/center": "^2.2.5", "@bedrock-layout/columns": "^2.3.4", "@bedrock-layout/cover": "^2.2.5", "@bedrock-layout/frame": "^2.2.4", diff --git a/src/components/Workspaces/Workspace/Workspace.tsx b/src/components/Workspaces/Workspace/Workspace.tsx index d280c63..ff1a249 100644 --- a/src/components/Workspaces/Workspace/Workspace.tsx +++ b/src/components/Workspaces/Workspace/Workspace.tsx @@ -1,7 +1,32 @@ import { useParams } from "react-router-dom"; +import { Cover } from "@bedrock-layout/cover"; +import { Center } from "@bedrock-layout/center"; +import { Stack } from "@bedrock-layout/stack"; + +import { PreviewWindow, H2 } from "./styles"; +import { WorkspaceControls } from "./WorkspaceControls"; +import { MockupBlock } from "../../Common/MockupBlock.styled"; + +import { workspaceObject } from "../workspaces"; export const Workspace = () => { - const params = useParams(); - return

    {params.workspaceName}

    ; - + const { workspaceId } = useParams(); + return ( + +

    {workspaceId ? workspaceObject[workspaceId] : ""}

    + + Preview Item + + +
    + ); }; diff --git a/src/components/Workspaces/Workspace/WorkspaceControls.tsx b/src/components/Workspaces/Workspace/WorkspaceControls.tsx new file mode 100644 index 0000000..82aa46c --- /dev/null +++ b/src/components/Workspaces/Workspace/WorkspaceControls.tsx @@ -0,0 +1,11 @@ +import { MockupBlock } from "../../Common/MockupBlock.styled"; + +export const WorkspaceControls = () => ( + + WorkspaceControls + +); diff --git a/src/components/Workspaces/Workspace/styles.ts b/src/components/Workspaces/Workspace/styles.ts new file mode 100644 index 0000000..e4f3f3c --- /dev/null +++ b/src/components/Workspaces/Workspace/styles.ts @@ -0,0 +1,29 @@ +import styled from "styled-components"; +import { PadBox } from "@bedrock-layout/padbox"; + +import bg from "../../../public/images/misc/checker-40x40.png"; + +export type PreviewWindowProps = { + height: number, + width: number, +}; +export const PreviewWindow = styled(PadBox).attrs(() => ({ + padding: "lg", +}))` + display: flex; + justify-content: center; + align-items: center; + + height: ${({ height }) => height}px; + width: ${({ width }) => width}px; + + border-radius: 2em; + background-image: url("${bg}"); +`; + +export const H2 = styled.h2` + margin: 0.2em; + color: ${p => p.theme.colors.darkGrey}; + font-family: ${p => p.theme.fonts.f1Regular}; + max-inline-size: 600px; +`; diff --git a/src/components/Workspaces/WorkspaceList/WorkspaceList.tsx b/src/components/Workspaces/WorkspaceList/WorkspaceList.tsx index b3fb792..b620190 100644 --- a/src/components/Workspaces/WorkspaceList/WorkspaceList.tsx +++ b/src/components/Workspaces/WorkspaceList/WorkspaceList.tsx @@ -2,15 +2,14 @@ import { WorkspaceListBox } from "./styles"; import { Stack } from "@bedrock-layout/stack"; import { NavLink } from "react-router-dom"; import { MenuItem } from "../../Common/MenuItem.styled"; +import { workspaceList } from "../workspaces"; export const WorkspaceList = () => ( - - - - - + {workspaceList.map((workspace, i) => ( + + ))} ); diff --git a/src/components/Workspaces/workspaces.ts b/src/components/Workspaces/workspaces.ts new file mode 100644 index 0000000..4189823 --- /dev/null +++ b/src/components/Workspaces/workspaces.ts @@ -0,0 +1,28 @@ +export const workspaceList = [ + { + name: "Workspace 1", + id: "workspace1", + }, + { + name: "Workspace 2", + id: "workspace2", + }, + { + name: "Workspace 3", + id: "workspace3", + }, + { + name: "Workspace 4 has a longer name than the rest", + id: "workspace4", + }, +]; + +export const workspaceObject = ((list: typeof workspaceList) => { + const obj: {[key: string]: string} = {}; + list.forEach(item => { + obj[item.id] = item.name; + }); + console.log("workspaceObject", obj); + return obj; +})(workspaceList); +console.log(workspaceObject); diff --git a/src/index.tsx b/src/index.tsx index e9cb396..735b07f 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -28,7 +28,7 @@ ReactDOM.render( } /> }> Workspaces Home} /> - } /> + } /> Page Not Found} /> diff --git a/src/public/images/misc/checker-40x40.png b/src/public/images/misc/checker-40x40.png new file mode 100644 index 0000000000000000000000000000000000000000..1b213216f0da6e0dc8c2b6d2576bf1164507386e GIT binary patch literal 2852 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 Date: Fri, 7 Jan 2022 19:00:16 -0500 Subject: [PATCH 4/6] ISSUE-005 - Added a scrolling effect to the PreviewWindow. Added scroll functionality to overflow-y for the WorkspaceList box. --- .../Workspaces/Workspace/Workspace.tsx | 4 +-- src/components/Workspaces/Workspace/styles.ts | 17 ++++++++-- .../WorkspaceList/WorkspaceList.tsx | 7 ++-- .../Workspaces/WorkspaceList/styles.ts | 9 ++++-- src/components/Workspaces/WorkspacesRoute.tsx | 4 +-- src/components/Workspaces/workspaces.ts | 32 +++++++++++++++++-- 6 files changed, 61 insertions(+), 12 deletions(-) diff --git a/src/components/Workspaces/Workspace/Workspace.tsx b/src/components/Workspaces/Workspace/Workspace.tsx index ff1a249..3362b8c 100644 --- a/src/components/Workspaces/Workspace/Workspace.tsx +++ b/src/components/Workspaces/Workspace/Workspace.tsx @@ -18,8 +18,8 @@ export const Workspace = () => { maxWidth="80%" centerChildren > -

    {workspaceId ? workspaceObject[workspaceId] : ""}

    - +

    {workspaceId ? workspaceObject[workspaceId] : "Unknown"}

    + ({ padding: "lg", @@ -17,8 +23,15 @@ export const PreviewWindow = styled(PadBox).attrs(() => ({ height: ${({ height }) => height}px; width: ${({ width }) => width}px; - border-radius: 2em; + border-radius: 1em; + background-image: url("${bg}"); + background-position: 0px 0px; + background-repeat: repeat; + + ${({ animatedBG }) => animatedBG && css` + animation: ${scrollAnimation} 5s linear infinite; + `} `; export const H2 = styled.h2` diff --git a/src/components/Workspaces/WorkspaceList/WorkspaceList.tsx b/src/components/Workspaces/WorkspaceList/WorkspaceList.tsx index b620190..1c805d2 100644 --- a/src/components/Workspaces/WorkspaceList/WorkspaceList.tsx +++ b/src/components/Workspaces/WorkspaceList/WorkspaceList.tsx @@ -4,8 +4,11 @@ import { NavLink } from "react-router-dom"; import { MenuItem } from "../../Common/MenuItem.styled"; import { workspaceList } from "../workspaces"; -export const WorkspaceList = () => ( - +type WorkspaceListProps = { + headerOffset?: number, +}; +export const WorkspaceList = ({ headerOffset }: WorkspaceListProps) => ( + {workspaceList.map((workspace, i) => ( diff --git a/src/components/Workspaces/WorkspaceList/styles.ts b/src/components/Workspaces/WorkspaceList/styles.ts index b35772c..9e1f838 100644 --- a/src/components/Workspaces/WorkspaceList/styles.ts +++ b/src/components/Workspaces/WorkspaceList/styles.ts @@ -1,11 +1,16 @@ import styled from "styled-components"; import { PadBox } from "@bedrock-layout/padbox"; +type WorkspaceListBoxProps = { + headerOffset?: number, +}; export const WorkspaceListBox = styled(PadBox).attrs(() => ({ padding: ["lg", "md"], -}))` - height: 100%; +}))` + height: calc(100vh - ${({ headerOffset = 0 }) => `${headerOffset}px`}); width: 100%; background-image: linear-gradient(to bottom, #f0f0f0, #fff); border-right: 1px solid ${p => p.theme.colors.darkGrey}; + overflow-y: scroll; `; +WorkspaceListBox.displayName = "WorkspaceListBox"; diff --git a/src/components/Workspaces/WorkspacesRoute.tsx b/src/components/Workspaces/WorkspacesRoute.tsx index 6ae8376..0a5de85 100644 --- a/src/components/Workspaces/WorkspacesRoute.tsx +++ b/src/components/Workspaces/WorkspacesRoute.tsx @@ -12,9 +12,9 @@ export default function Workspaces() { return ( - + - + diff --git a/src/components/Workspaces/workspaces.ts b/src/components/Workspaces/workspaces.ts index 4189823..d10fb05 100644 --- a/src/components/Workspaces/workspaces.ts +++ b/src/components/Workspaces/workspaces.ts @@ -15,6 +15,36 @@ export const workspaceList = [ name: "Workspace 4 has a longer name than the rest", id: "workspace4", }, + { name: "blah", id: "blah0" }, + { name: "blah", id: "blah1" }, + { name: "blah", id: "blah2" }, + { name: "blah", id: "blah3" }, + { name: "blah", id: "blah4" }, + { name: "blah", id: "blah5" }, + { name: "blah", id: "blah6" }, + { name: "blah", id: "blah7" }, + { name: "blah", id: "blah8" }, + { name: "blah", id: "blah9" }, + { name: "blah", id: "blah10" }, + { name: "blah", id: "blah11" }, + { name: "blah", id: "blah12" }, + { name: "blah", id: "blah13" }, + { name: "blah", id: "blah14" }, + { name: "blah", id: "blah15" }, + { name: "blah", id: "blah16" }, + { name: "blah", id: "blah17" }, + { name: "blah", id: "blah18" }, + { name: "blah", id: "blah19" }, + { name: "blah", id: "blah20" }, + { name: "blah", id: "blah21" }, + { name: "blah", id: "blah22" }, + { name: "blah", id: "blah23" }, + { name: "blah", id: "blah24" }, + { name: "blah", id: "blah25" }, + { name: "blah", id: "blah26" }, + { name: "blah", id: "blah27" }, + { name: "blah", id: "blah28" }, + { name: "blah", id: "blah29" }, ]; export const workspaceObject = ((list: typeof workspaceList) => { @@ -22,7 +52,5 @@ export const workspaceObject = ((list: typeof workspaceList) => { list.forEach(item => { obj[item.id] = item.name; }); - console.log("workspaceObject", obj); return obj; })(workspaceList); -console.log(workspaceObject); From 3151c58d9d87411331e51c1942b93b55b7dde345 Mon Sep 17 00:00:00 2001 From: Kyle Geib Date: Mon, 10 Jan 2022 17:28:34 -0500 Subject: [PATCH 5/6] ISSUE-005 - Emulating an iOS toggle switch and hooked it all up. Good practice. Think there is some improvements I can make, though. The toggle circle on iOS has the drop shadow - not the body (with an inset shadow). But because I'm using absolute positioning the shadow overflows outside the the toggle body. So. I'll need to switch to using some other positioning rule --- package.json | 1 + .../Common/Inputs/Toggle/Toggle.tsx | 46 ++++++++++++ src/components/Common/Inputs/Toggle/index.ts | 1 + src/components/Common/Inputs/Toggle/styles.ts | 72 +++++++++++++++++++ src/components/Menu/styles.ts | 2 + .../Workspaces/Workspace/Workspace.tsx | 13 ++-- .../Workspace/WorkspaceControls.tsx | 33 ++++++--- src/components/Workspaces/Workspace/styles.ts | 10 +++ src/features/workspace/workspaceSelector.ts | 3 + src/features/workspace/workspaceSlice.ts | 23 ++++++ src/shared/theme.ts | 2 + src/store.ts | 2 + src/types/state.d.ts | 11 +++ yarn.lock | 7 ++ 14 files changed, 212 insertions(+), 14 deletions(-) create mode 100644 src/components/Common/Inputs/Toggle/Toggle.tsx create mode 100644 src/components/Common/Inputs/Toggle/index.ts create mode 100644 src/components/Common/Inputs/Toggle/styles.ts create mode 100644 src/features/workspace/workspaceSelector.ts create mode 100644 src/features/workspace/workspaceSlice.ts diff --git a/package.json b/package.json index 057ca60..df8943c 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "@bedrock-layout/columns": "^2.3.4", "@bedrock-layout/cover": "^2.2.5", "@bedrock-layout/frame": "^2.2.4", + "@bedrock-layout/grid": "^2.2.5", "@bedrock-layout/inline": "^2.3.3", "@bedrock-layout/inline-cluster": "^2.4.2", "@bedrock-layout/padbox": "^2.1.4", diff --git a/src/components/Common/Inputs/Toggle/Toggle.tsx b/src/components/Common/Inputs/Toggle/Toggle.tsx new file mode 100644 index 0000000..7325765 --- /dev/null +++ b/src/components/Common/Inputs/Toggle/Toggle.tsx @@ -0,0 +1,46 @@ +import { useState } from "react"; +import { AnimatedBG } from "../../../../types/state"; +import { + ToggleContainer, + ToggleBody, + ToggleInput, + ToggleLabel, + ToggleBackground, + ToggleCircle, +} from "./styles"; + +export type ToggleProps = { + label: string, + toggled: boolean, + onToggle: (value: AnimatedBG) => void, +}; +/** + * This is my attempt at making a iOS-style toggle switch. + * @param param0 + * @returns + */ +export const Toggle = ({ label, toggled, onToggle }: ToggleProps) => { + const [hovered, setHovered] = useState(false); + return ( + + {label}{" "} + + onToggle(e.target.checked)} + /> + setHovered(true)} + onMouseUp={() => setHovered(false)} + > + + + + + + ); +}; diff --git a/src/components/Common/Inputs/Toggle/index.ts b/src/components/Common/Inputs/Toggle/index.ts new file mode 100644 index 0000000..f99c198 --- /dev/null +++ b/src/components/Common/Inputs/Toggle/index.ts @@ -0,0 +1 @@ +export * from "./Toggle"; diff --git a/src/components/Common/Inputs/Toggle/styles.ts b/src/components/Common/Inputs/Toggle/styles.ts new file mode 100644 index 0000000..bcd8841 --- /dev/null +++ b/src/components/Common/Inputs/Toggle/styles.ts @@ -0,0 +1,72 @@ +import styled, { css } from "styled-components"; + +type ToggleContainerProps = { + fontSize?: string; +} +export const ToggleContainer = styled.div` + text-align: center; + font-size: ${({ fontSize = "inherit" }) => fontSize}; +`; +ToggleContainer.displayName = "ToggleContainer"; + +export const ToggleBody = styled.div` + position: relative; + display: inline-block; + text-align: left; + top: 0.5em; +`; +ToggleBody.displayName = "ToggleBody"; + +export const ToggleInput = styled.input` + display: none; +`; +ToggleInput.displayName = "ToggleInput"; + +export const ToggleLabel = styled.label` + display: block; + overflow: hidden; + border-radius: .75em; + height: 1.5em; + width: 2.7em; + cursor: pointer; +`; +ToggleLabel.displayName = "ToggleLabel"; + +type ToggleBackgroundProps = { + toggled: boolean, + toggledColor?: string, +}; +export const ToggleBackground = styled.div` + background-color: ${({ + toggledColor, + toggled, + }) => ( + toggled ? + (toggledColor ?? (p => p.theme.colors.activeGreen)) : + p => p.theme.colors.lightGrey + )}; + width: 100%; + height: 100%; + + ${({ toggled }) => toggled && css` + box-shadow: inset 0 0 24px -16px black; + `} +`; +ToggleBackground.displayName = "ToggleBackground"; + +type ToggleCircleProps = { + toggled: boolean, + stretched: boolean, +}; +export const ToggleCircle = styled.div` + position: absolute; + height: 1.3em; + width: ${({ stretched }) => stretched ? "1.6em": "1.3em"}; + border-radius: 0.65em; + margin: 0.1em; + background-color: white; + top: 0; + ${({ toggled }) => toggled ? css`right: 0;` : css`left: 0;`} +`; +ToggleCircle.displayName = "ToggleCircle"; + diff --git a/src/components/Menu/styles.ts b/src/components/Menu/styles.ts index e095306..5dee8cb 100644 --- a/src/components/Menu/styles.ts +++ b/src/components/Menu/styles.ts @@ -5,6 +5,7 @@ import styled from "styled-components"; export const Title = styled.h3` font-family: ${p => p.theme.fonts.f1Bold}; `; +Title.displayName = "Title"; export const MenuBar = styled(InlineCluster).attrs(() => ({ as: PadBox, @@ -16,3 +17,4 @@ export const MenuBar = styled(InlineCluster).attrs(() => ({ background-image: linear-gradient(to right, #f0f0f0, #fff); border-block-end: 1px solid ${p => p.theme.colors.darkGrey}; `; +MenuBar.displayName = "MenuBar"; diff --git a/src/components/Workspaces/Workspace/Workspace.tsx b/src/components/Workspaces/Workspace/Workspace.tsx index 3362b8c..398c8d7 100644 --- a/src/components/Workspaces/Workspace/Workspace.tsx +++ b/src/components/Workspaces/Workspace/Workspace.tsx @@ -1,9 +1,11 @@ import { useParams } from "react-router-dom"; -import { Cover } from "@bedrock-layout/cover"; +import { useSelector } from "react-redux"; import { Center } from "@bedrock-layout/center"; import { Stack } from "@bedrock-layout/stack"; -import { PreviewWindow, H2 } from "./styles"; +import { workspaceSelector } from "../../../features/workspace/workspaceSelector"; + +import { PreviewWindow, H2, ControlsContainer } from "./styles"; import { WorkspaceControls } from "./WorkspaceControls"; import { MockupBlock } from "../../Common/MockupBlock.styled"; @@ -11,6 +13,7 @@ import { workspaceObject } from "../workspaces"; export const Workspace = () => { const { workspaceId } = useParams(); + const { animatedBG } = useSelector(workspaceSelector); return ( { centerChildren >

    {workspaceId ? workspaceObject[workspaceId] : "Unknown"}

    - + Preview Item - + + +
    ); }; diff --git a/src/components/Workspaces/Workspace/WorkspaceControls.tsx b/src/components/Workspaces/Workspace/WorkspaceControls.tsx index 82aa46c..a88c1f9 100644 --- a/src/components/Workspaces/Workspace/WorkspaceControls.tsx +++ b/src/components/Workspaces/Workspace/WorkspaceControls.tsx @@ -1,11 +1,24 @@ -import { MockupBlock } from "../../Common/MockupBlock.styled"; +import { Grid } from "@bedrock-layout/grid"; +import { useDispatch, useSelector } from "react-redux"; -export const WorkspaceControls = () => ( - - WorkspaceControls - -); +import { workspaceSelector } from "../../../features/workspace/workspaceSelector"; +import { setAnimatedBG } from "../../../features/workspace/workspaceSlice"; +import { AnimatedBG } from "../../../types/state"; + +import { Toggle } from "../../Common/Inputs/Toggle"; + +export const WorkspaceControls = () => { + const dispatch = useDispatch(); + const { animatedBG } = useSelector(workspaceSelector); + + return( + + { + dispatch(setAnimatedBG(value)); + }} /> + + ); +}; diff --git a/src/components/Workspaces/Workspace/styles.ts b/src/components/Workspaces/Workspace/styles.ts index 2bada8a..17de027 100644 --- a/src/components/Workspaces/Workspace/styles.ts +++ b/src/components/Workspaces/Workspace/styles.ts @@ -33,6 +33,7 @@ export const PreviewWindow = styled(PadBox).attrs(() => ({ animation: ${scrollAnimation} 5s linear infinite; `} `; +PreviewWindow.displayName = "PreviewWindow"; export const H2 = styled.h2` margin: 0.2em; @@ -40,3 +41,12 @@ export const H2 = styled.h2` font-family: ${p => p.theme.fonts.f1Regular}; max-inline-size: 600px; `; +H2.displayName = "H2"; + +export const ControlsContainer = styled(PadBox).attrs(() => ({ + padding: "lg", +}))` + background-color: ${p => p.theme.colors.faintGrey}; + border-radius: 1em; +`; +ControlsContainer.displayName = "ControlsContainer"; diff --git a/src/features/workspace/workspaceSelector.ts b/src/features/workspace/workspaceSelector.ts new file mode 100644 index 0000000..2fcc78d --- /dev/null +++ b/src/features/workspace/workspaceSelector.ts @@ -0,0 +1,3 @@ +import { RootState } from "../../types/state"; + +export const workspaceSelector = (state: RootState) => state.workspace; diff --git a/src/features/workspace/workspaceSlice.ts b/src/features/workspace/workspaceSlice.ts new file mode 100644 index 0000000..eeb9e13 --- /dev/null +++ b/src/features/workspace/workspaceSlice.ts @@ -0,0 +1,23 @@ +import { createSlice, PayloadAction } from "@reduxjs/toolkit"; +import { RootState, WorkspaceId, AnimatedBG } from "../../types/state"; + +const initialState: RootState["workspace"] = { + workspaceId: "", + animatedBG: true, +}; + +export const workspaceSlice = createSlice({ + name: "workspace", + initialState, + reducers: { + setWorkspaceId: (state, action: PayloadAction) => { + state.workspaceId = action.payload; + }, + setAnimatedBG: (state, action: PayloadAction) => { + state.animatedBG = action.payload; + }, + }, +}); + +export const { setWorkspaceId, setAnimatedBG } = workspaceSlice.actions; +export default workspaceSlice.reducer; diff --git a/src/shared/theme.ts b/src/shared/theme.ts index 5197434..25d7408 100644 --- a/src/shared/theme.ts +++ b/src/shared/theme.ts @@ -14,8 +14,10 @@ export const theme = { orange: "#f4ae40", blue: "#387af5", pink: "#eb57a3", + activeGreen: "#65c466", grey: "#aaa", lightGrey: "#ddd", + faintGrey: "#eee", darkGrey: "#303030", videoFrameBG: "#333", }, diff --git a/src/store.ts b/src/store.ts index 862f533..ff421a5 100644 --- a/src/store.ts +++ b/src/store.ts @@ -1,9 +1,11 @@ import { configureStore, combineReducers } from "@reduxjs/toolkit"; import pageDimensions from "./features/pageDimensions/pageDimensionsSlice"; +import workspace from "./features/workspace/workspaceSlice"; export const store = configureStore({ reducer: combineReducers({ pageDimensions, + workspace, }), }); diff --git a/src/types/state.d.ts b/src/types/state.d.ts index 0dbc95b..07edffe 100644 --- a/src/types/state.d.ts +++ b/src/types/state.d.ts @@ -1,7 +1,9 @@ export type RootState = { pageDimensions: PageDimensions, + workspace: Workspace, }; +// Page Dimensions export type PageDimensions = { menu: MenuDimensions, }; @@ -9,3 +11,12 @@ export type PageDimensions = { export type MenuDimensions = { height: number, }; + +// Workspace +export type Workspace = { + workspaceId: WorkspaceId, + animatedBG: AnimatedBG, +}; + +export type WorkspaceId = string; +export type AnimatedBG = boolean; diff --git a/yarn.lock b/yarn.lock index f2d8572..a72fe20 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1113,6 +1113,13 @@ dependencies: "@bedrock-layout/spacing-constants" "^2.5.1" +"@bedrock-layout/grid@^2.2.5": + version "2.2.5" + resolved "https://registry.yarnpkg.com/@bedrock-layout/grid/-/grid-2.2.5.tgz#36b622481c5d8b3bfb5a0fd76e5e0986ed69b098" + integrity sha512-5HteSi7BEWU7RTEBG9dRanqsKxf18aOcFj0V12S1muGki6Xc1yxw1V4O/GH/wGppvU1NH5ICxGuUBBqmXMPoyQ== + dependencies: + "@bedrock-layout/spacing-constants" "^2.5.1" + "@bedrock-layout/inline-cluster@^2.4.2": version "2.4.2" resolved "https://registry.yarnpkg.com/@bedrock-layout/inline-cluster/-/inline-cluster-2.4.2.tgz#0019482153b61f63a85cc0c22133f3ecac1e2821" From dd4df61fec5bcda4d8ebdaeab2d9016773636ec7 Mon Sep 17 00:00:00 2001 From: Kyle Geib Date: Mon, 10 Jan 2022 18:11:54 -0500 Subject: [PATCH 6/6] ISSUE-005 - Added indicator "I" and "O", emulating an accessibility option found in iOS. Added a subtle background color transition. Gave up on the idea of giving the toggle circle a shadow (not worth the hassle). But if I did decide to do that, I'd be able to animate the toggle circle fairly easily, I think. --- .../Common/Inputs/Toggle/Toggle.tsx | 15 ++++++++----- src/components/Common/Inputs/Toggle/styles.ts | 22 +++++++++++++++++++ src/shared/theme.ts | 5 ----- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/components/Common/Inputs/Toggle/Toggle.tsx b/src/components/Common/Inputs/Toggle/Toggle.tsx index 7325765..8273ede 100644 --- a/src/components/Common/Inputs/Toggle/Toggle.tsx +++ b/src/components/Common/Inputs/Toggle/Toggle.tsx @@ -13,13 +13,17 @@ export type ToggleProps = { label: string, toggled: boolean, onToggle: (value: AnimatedBG) => void, + showIndicators?: boolean, }; /** * This is my attempt at making a iOS-style toggle switch. - * @param param0 - * @returns */ -export const Toggle = ({ label, toggled, onToggle }: ToggleProps) => { +export const Toggle = ({ + label, + toggled, + onToggle, + showIndicators = false, +}: ToggleProps) => { const [hovered, setHovered] = useState(false); return ( @@ -37,8 +41,9 @@ export const Toggle = ({ label, toggled, onToggle }: ToggleProps) => { onMouseDown={() => setHovered(true)} onMouseUp={() => setHovered(false)} > - - + + + diff --git a/src/components/Common/Inputs/Toggle/styles.ts b/src/components/Common/Inputs/Toggle/styles.ts index bcd8841..d706654 100644 --- a/src/components/Common/Inputs/Toggle/styles.ts +++ b/src/components/Common/Inputs/Toggle/styles.ts @@ -35,6 +35,7 @@ ToggleLabel.displayName = "ToggleLabel"; type ToggleBackgroundProps = { toggled: boolean, toggledColor?: string, + showIndicators?: boolean, }; export const ToggleBackground = styled.div` background-color: ${({ @@ -47,10 +48,31 @@ export const ToggleBackground = styled.div` )}; width: 100%; height: 100%; + transition: background-color 300ms; ${({ toggled }) => toggled && css` box-shadow: inset 0 0 24px -16px black; `} + + ${({ toggled, showIndicators }) => showIndicators && (toggled ? + css` + div:before { + position: absolute; + right: 26px; + bottom: -2px; + content: "I"; + color: ${p => p.theme.colors.darkGrey}; + } + ` : + css` + div:after { + position: absolute; + left: 23px; + bottom: -2px; + content: "O"; + color: ${p => p.theme.colors.grey}; + } + `)} `; ToggleBackground.displayName = "ToggleBackground"; diff --git a/src/shared/theme.ts b/src/shared/theme.ts index 25d7408..4ee114a 100644 --- a/src/shared/theme.ts +++ b/src/shared/theme.ts @@ -48,9 +48,4 @@ export const GlobalStyle = createGlobalStyle` button { font-family: ${p => p.theme.fonts.basic}; } - - .main { - padding: 70px 0 20px; - min-height: calc(100vh - 50px); - } `;