diff --git a/app/components/Branding.tsx b/app/components/Branding.tsx index 9087de147..4f9635663 100644 --- a/app/components/Branding.tsx +++ b/app/components/Branding.tsx @@ -1,6 +1,7 @@ import * as React from "react"; import styled from "styled-components"; import breakpoint from "styled-components-breakpoint"; +import { depths } from "@shared/styles"; import env from "~/env"; import OutlineLogo from "./OutlineLogo"; @@ -38,7 +39,7 @@ const Link = styled.a` } ${breakpoint("tablet")` - z-index: ${(props: any) => props.theme.depths.sidebar + 1}; + z-index: ${depths.sidebar + 1}; position: fixed; bottom: 0; left: 0; diff --git a/app/components/CommandBar.tsx b/app/components/CommandBar.tsx index 5f4efc16d..9f76a1e21 100644 --- a/app/components/CommandBar.tsx +++ b/app/components/CommandBar.tsx @@ -6,6 +6,7 @@ import { useTranslation } from "react-i18next"; import { Portal } from "react-portal"; import styled from "styled-components"; import breakpoint from "styled-components-breakpoint"; +import { depths } from "@shared/styles"; import CommandBarResults from "~/components/CommandBarResults"; import SearchActions from "~/components/SearchActions"; import rootActions from "~/actions/root"; @@ -90,7 +91,7 @@ const Hint = styled(Text)` `; const Positioner = styled(KBarPositioner)` - z-index: ${(props) => props.theme.depths.commandBar}; + z-index: ${depths.commandBar}; `; const SearchInput = styled(KBarSearch)` diff --git a/app/components/ContextMenu/index.tsx b/app/components/ContextMenu/index.tsx index 893c638ea..512cc7677 100644 --- a/app/components/ContextMenu/index.tsx +++ b/app/components/ContextMenu/index.tsx @@ -4,6 +4,7 @@ import { Portal } from "react-portal"; import { Menu } from "reakit/Menu"; import styled from "styled-components"; import breakpoint from "styled-components-breakpoint"; +import { depths } from "@shared/styles"; import useMenuContext from "~/hooks/useMenuContext"; import useMenuHeight from "~/hooks/useMenuHeight"; import usePrevious from "~/hooks/usePrevious"; @@ -148,7 +149,7 @@ export const Backdrop = styled.div` right: 0; bottom: 0; background: ${(props) => props.theme.backdrop}; - z-index: ${(props) => props.theme.depths.menu - 1}; + z-index: ${depths.menu - 1}; ${breakpoint("tablet")` display: none; @@ -157,7 +158,7 @@ export const Backdrop = styled.div` export const Position = styled.div` position: absolute; - z-index: ${(props) => props.theme.depths.menu}; + z-index: ${depths.menu}; // overrides make mobile-first coding style challenging // so we explicitly define mobile breakpoint here diff --git a/app/components/Guide.tsx b/app/components/Guide.tsx index f945c1eaf..ab495e7ff 100644 --- a/app/components/Guide.tsx +++ b/app/components/Guide.tsx @@ -2,6 +2,7 @@ import { observer } from "mobx-react"; import * as React from "react"; import { Dialog, DialogBackdrop, useDialogState } from "reakit/Dialog"; import styled from "styled-components"; +import { depths } from "@shared/styles"; import Scrollable from "~/components/Scrollable"; import usePrevious from "~/hooks/usePrevious"; @@ -72,7 +73,7 @@ const Backdrop = styled.div` right: 0; bottom: 0; background-color: ${(props) => props.theme.backdrop} !important; - z-index: ${(props) => props.theme.depths.modalOverlay}; + z-index: ${depths.modalOverlay}; transition: opacity 200ms ease-in-out; opacity: 0; @@ -87,7 +88,7 @@ const Scene = styled.div` right: 0; bottom: 0; margin: 12px; - z-index: ${(props) => props.theme.depths.modal}; + z-index: ${depths.modal}; display: flex; justify-content: center; align-items: flex-start; diff --git a/app/components/Header.tsx b/app/components/Header.tsx index 4e980c0e2..a783675d5 100644 --- a/app/components/Header.tsx +++ b/app/components/Header.tsx @@ -5,6 +5,7 @@ import { transparentize } from "polished"; import * as React from "react"; import styled from "styled-components"; import breakpoint from "styled-components-breakpoint"; +import { depths } from "@shared/styles"; import Button from "~/components/Button"; import Fade from "~/components/Fade"; import Flex from "~/components/Flex"; @@ -100,7 +101,7 @@ const Actions = styled(Flex)` const Wrapper = styled(Flex)<{ $passThrough?: boolean }>` top: 0; - z-index: ${(props) => props.theme.depths.header}; + z-index: ${depths.header}; position: sticky; background: ${(props) => props.theme.background}; diff --git a/app/components/HoverPreview.tsx b/app/components/HoverPreview.tsx index ab49c1948..fc9237341 100644 --- a/app/components/HoverPreview.tsx +++ b/app/components/HoverPreview.tsx @@ -2,6 +2,7 @@ import { transparentize } from "polished"; import * as React from "react"; import { Portal } from "react-portal"; import styled from "styled-components"; +import { depths } from "@shared/styles"; import parseDocumentSlug from "@shared/utils/parseDocumentSlug"; import { isInternalUrl } from "@shared/utils/urls"; import HoverPreviewDocument from "~/components/HoverPreviewDocument"; @@ -195,7 +196,7 @@ const Card = styled.div` const Position = styled.div<{ fixed?: boolean; top?: number; left?: number }>` margin-top: 10px; position: ${({ fixed }) => (fixed ? "fixed" : "absolute")}; - z-index: ${(props) => props.theme.depths.hoverPreview}; + z-index: ${depths.hoverPreview}; display: flex; max-height: 75%; diff --git a/app/components/LoadingIndicator/LoadingIndicatorBar.tsx b/app/components/LoadingIndicator/LoadingIndicatorBar.tsx index 93f14d3f3..a3e01532c 100644 --- a/app/components/LoadingIndicator/LoadingIndicatorBar.tsx +++ b/app/components/LoadingIndicator/LoadingIndicatorBar.tsx @@ -1,5 +1,6 @@ import * as React from "react"; import styled, { keyframes } from "styled-components"; +import { depths } from "@shared/styles"; const LoadingIndicatorBar = () => { return ( @@ -17,7 +18,7 @@ const loadingFrame = keyframes` const Container = styled.div` position: fixed; top: 0; - z-index: ${(props) => props.theme.depths.loadingIndicatorBar}; + z-index: ${depths.loadingIndicatorBar}; width: 100%; animation: ${loadingFrame} 4s ease-in-out infinite; animation-delay: 250ms; diff --git a/app/components/Modal.tsx b/app/components/Modal.tsx index d78b56278..ae5889ec8 100644 --- a/app/components/Modal.tsx +++ b/app/components/Modal.tsx @@ -6,6 +6,7 @@ import { useTranslation } from "react-i18next"; import { Dialog, DialogBackdrop, useDialogState } from "reakit/Dialog"; import styled from "styled-components"; import breakpoint from "styled-components-breakpoint"; +import { depths } from "@shared/styles"; import Flex from "~/components/Flex"; import NudeButton from "~/components/NudeButton"; import Scrollable from "~/components/Scrollable"; @@ -133,7 +134,7 @@ const Backdrop = styled(Flex)<{ $isCentered?: boolean }>` props.$isCentered ? props.theme.modalBackdrop : transparentize(0.25, props.theme.background)} !important; - z-index: ${(props) => props.theme.depths.modalOverlay}; + z-index: ${depths.modalOverlay}; transition: opacity 50ms ease-in-out; opacity: 0; @@ -150,7 +151,7 @@ const Fullscreen = styled.div<{ $nested: boolean }>` left: 0; right: 0; bottom: 0; - z-index: ${(props) => props.theme.depths.modal}; + z-index: ${depths.modal}; display: flex; justify-content: center; align-items: flex-start; @@ -240,7 +241,7 @@ const Small = styled.div` margin: auto auto; min-width: 350px; max-width: 30vw; - z-index: ${(props) => props.theme.depths.modal}; + z-index: ${depths.modal}; display: flex; justify-content: center; align-items: flex-start; diff --git a/app/components/Sidebar/Sidebar.tsx b/app/components/Sidebar/Sidebar.tsx index 8c85c5a1f..ef84560de 100644 --- a/app/components/Sidebar/Sidebar.tsx +++ b/app/components/Sidebar/Sidebar.tsx @@ -5,6 +5,7 @@ import { Portal } from "react-portal"; import { useLocation } from "react-router-dom"; import styled, { useTheme } from "styled-components"; import breakpoint from "styled-components-breakpoint"; +import { depths } from "@shared/styles"; import Flex from "~/components/Flex"; import useMenuContext from "~/hooks/useMenuContext"; import usePrevious from "~/hooks/usePrevious"; @@ -224,7 +225,7 @@ const Backdrop = styled.a` bottom: 0; right: 0; cursor: default; - z-index: ${(props) => props.theme.depths.sidebar - 1}; + z-index: ${depths.sidebar - 1}; background: ${(props) => props.theme.backdrop}; `; @@ -246,7 +247,7 @@ const Container = styled(Flex)<{ transform: translateX( ${(props) => (props.$mobileSidebarVisible ? 0 : "-100%")} ); - z-index: ${(props) => props.theme.depths.sidebar}; + z-index: ${depths.sidebar}; max-width: 70%; min-width: 280px; diff --git a/app/components/SkipNavLink.tsx b/app/components/SkipNavLink.tsx index b67420937..bcd7df572 100644 --- a/app/components/SkipNavLink.tsx +++ b/app/components/SkipNavLink.tsx @@ -1,5 +1,6 @@ import * as React from "react"; import styled from "styled-components"; +import { depths } from "@shared/styles"; import { id } from "~/components/SkipNavContent"; export default function SkipNavLink() { @@ -25,7 +26,7 @@ const Anchor = styled.a` background: ${(props) => props.theme.background}; color: ${(props) => props.theme.text}; outline-color: ${(props) => props.theme.primary}; - z-index: ${(props) => props.theme.depths.popover}; + z-index: ${depths.popover}; width: auto; height: auto; clip: auto; diff --git a/app/components/Theme.tsx b/app/components/Theme.tsx index c434e1ee5..d71b1c9d7 100644 --- a/app/components/Theme.tsx +++ b/app/components/Theme.tsx @@ -1,7 +1,8 @@ import { observer } from "mobx-react"; import * as React from "react"; import { ThemeProvider } from "styled-components"; -import { dark, light, lightMobile, darkMobile } from "@shared/theme"; +import { breakpoints } from "@shared/styles"; +import { dark, light, lightMobile, darkMobile } from "@shared/styles/theme"; import useMediaQuery from "~/hooks/useMediaQuery"; import useStores from "~/hooks/useStores"; import GlobalStyles from "~/styles/globals"; @@ -11,9 +12,7 @@ const Theme: React.FC = ({ children }) => { const resolvedTheme = ui.resolvedTheme === "dark" ? dark : light; const resolvedMobileTheme = ui.resolvedTheme === "dark" ? darkMobile : lightMobile; - const isMobile = useMediaQuery( - `(max-width: ${resolvedTheme.breakpoints.tablet}px)` - ); + const isMobile = useMediaQuery(`(max-width: ${breakpoints.tablet}px)`); const isPrinting = useMediaQuery("print"); const theme = isPrinting ? light diff --git a/app/components/Toasts.tsx b/app/components/Toasts.tsx index aca0f00a6..b052a62de 100644 --- a/app/components/Toasts.tsx +++ b/app/components/Toasts.tsx @@ -1,6 +1,7 @@ import { observer } from "mobx-react"; import * as React from "react"; import styled from "styled-components"; +import { depths } from "@shared/styles"; import Toast from "~/components/Toast"; import useStores from "~/hooks/useStores"; import { Toast as TToast } from "~/types"; @@ -27,7 +28,7 @@ const List = styled.ol` list-style: none; margin: 0; padding: 0; - z-index: ${(props) => props.theme.depths.toasts}; + z-index: ${depths.toasts}; `; export default observer(Toasts); diff --git a/app/hooks/useMobile.ts b/app/hooks/useMobile.ts index a0d384bb4..d703dcdde 100644 --- a/app/hooks/useMobile.ts +++ b/app/hooks/useMobile.ts @@ -1,6 +1,6 @@ -import { base } from "@shared/theme"; +import { breakpoints } from "@shared/styles"; import useMediaQuery from "~/hooks/useMediaQuery"; export default function useMobile(): boolean { - return useMediaQuery(`(max-width: ${base.breakpoints.tablet - 1}px)`); + return useMediaQuery(`(max-width: ${breakpoints.tablet - 1}px)`); } diff --git a/app/scenes/Document/components/EditableTitle.tsx b/app/scenes/Document/components/EditableTitle.tsx index 70349b228..0fba68c11 100644 --- a/app/scenes/Document/components/EditableTitle.tsx +++ b/app/scenes/Document/components/EditableTitle.tsx @@ -3,7 +3,7 @@ import * as React from "react"; import styled from "styled-components"; import breakpoint from "styled-components-breakpoint"; import { MAX_TITLE_LENGTH } from "@shared/constants"; -import { light } from "@shared/theme"; +import { light } from "@shared/styles/theme"; import { getCurrentDateAsString, getCurrentDateTimeAsString, diff --git a/app/scenes/Document/components/ObservingBanner.tsx b/app/scenes/Document/components/ObservingBanner.tsx index 4bc3cab4c..b4529d148 100644 --- a/app/scenes/Document/components/ObservingBanner.tsx +++ b/app/scenes/Document/components/ObservingBanner.tsx @@ -3,6 +3,7 @@ import { observer } from "mobx-react"; import * as React from "react"; import { useTranslation } from "react-i18next"; import styled from "styled-components"; +import { depths } from "@shared/styles"; import useStores from "~/hooks/useStores"; const transition = { @@ -50,7 +51,7 @@ const Banner = styled(m.div)<{ $color: string }>` padding: 6px 6px 1px; font-size: 13px; font-weight: 500; - z-index: ${(props) => props.theme.depths.header + 1}; + z-index: ${depths.header + 1}; color: ${(props) => props.theme.white}; background: ${(props) => props.$color}; border-bottom-left-radius: 4px; diff --git a/app/stores/UiStore.ts b/app/stores/UiStore.ts index 79c1eedd1..bef203fa3 100644 --- a/app/stores/UiStore.ts +++ b/app/stores/UiStore.ts @@ -1,5 +1,5 @@ import { action, autorun, computed, observable } from "mobx"; -import { light as defaultTheme } from "@shared/theme"; +import { light as defaultTheme } from "@shared/styles/theme"; import Document from "~/models/Document"; import { ConnectionStatus } from "~/scenes/Document/components/MultiplayerEditor"; diff --git a/app/styles/globals.ts b/app/styles/globals.ts index deff6b275..878c4c337 100644 --- a/app/styles/globals.ts +++ b/app/styles/globals.ts @@ -1,5 +1,6 @@ import { createGlobalStyle } from "styled-components"; import styledNormalize from "styled-normalize"; +import { breakpoints, depths } from "@shared/styles"; export default createGlobalStyle` ${styledNormalize} @@ -36,8 +37,7 @@ export default createGlobalStyle` text-rendering: optimizeLegibility; } - @media (min-width: ${(props) => - props.theme.breakpoints.tablet}px) and (display-mode: standalone) { + @media (min-width: ${breakpoints.tablet}px) and (display-mode: standalone) { body:after { content: ""; display: block; @@ -47,7 +47,7 @@ export default createGlobalStyle` right: 0; height: 1px; background: ${(props) => props.theme.titleBarDivider}; - z-index: ${(props) => props.theme.depths.titleBarDivider}; + z-index: ${depths.titleBarDivider}; } } diff --git a/app/typings/styled-components.d.ts b/app/typings/styled-components.d.ts index 042a141de..9324c45bf 100644 --- a/app/typings/styled-components.d.ts +++ b/app/typings/styled-components.d.ts @@ -116,27 +116,6 @@ declare module "styled-components" { sidebarMaxWidth: number; } - interface Breakpoints { - mobile: number; - tablet: number; - desktop: number; - desktopLarge: number; - } - - interface Depths { - header: number; - sidebar: number; - hoverPreview: number; - modalOverlay: number; - modal: number; - menu: number; - toasts: number; - popover: number; - titleBarDivider: number; - loadingIndicatorBar: number; - commandBar: number; - } - export interface DefaultTheme extends Colors, Spacing, EditorTheme { background: string; backgroundTransition: string; @@ -183,8 +162,5 @@ declare module "styled-components" { progressBarBackground: string; scrollbarBackground: string; scrollbarThumb: string; - - breakpoints: Breakpoints; - depths: Depths; } } diff --git a/server/emails/components/EmailLayout.tsx b/server/emails/components/EmailLayout.tsx index bd21fb1fd..2f9934cad 100644 --- a/server/emails/components/EmailLayout.tsx +++ b/server/emails/components/EmailLayout.tsx @@ -1,6 +1,6 @@ import { Table, TBody, TR, TD } from "oy-vey"; import * as React from "react"; -import theme from "@shared/theme"; +import theme from "@shared/styles/theme"; const EmailLayout: React.FC = ({ children }) => (