From bc2c9ffd65ccf448c2c6e4b2f4ae761f50f1cba7 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 4 Aug 2026 23:12:39 -0400 Subject: [PATCH] Tighten header, remove keyboard shortcuts floating button (#13304) * Tighten header, remove keyboard shortcuts floating button * fix: Standardize heading height const --- app/components/Header.tsx | 5 +- app/components/Sidebar/Shared.tsx | 2 +- app/hooks/useKeyboardShortcutsQuery.tsx | 31 +++++++++ app/routes/authenticated.tsx | 2 + app/scenes/Document/components/Footer.tsx | 4 +- app/scenes/Document/components/Header.tsx | 3 +- .../components/KeyboardShortcutsButton.tsx | 64 ------------------- .../Document/components/SharedHeader.tsx | 3 +- .../Document/components/SidebarLayout.tsx | 5 +- shared/constants.ts | 3 + shared/editor/components/Styles.ts | 3 +- shared/editor/nodes/TableView.ts | 8 +-- 12 files changed, 54 insertions(+), 79 deletions(-) create mode 100644 app/hooks/useKeyboardShortcutsQuery.tsx delete mode 100644 app/scenes/Document/components/KeyboardShortcutsButton.tsx diff --git a/app/components/Header.tsx b/app/components/Header.tsx index a43bc4fd08..1d7ad66ce8 100644 --- a/app/components/Header.tsx +++ b/app/components/Header.tsx @@ -8,6 +8,7 @@ import { mergeRefs } from "react-merge-refs"; import styled from "styled-components"; import breakpoint from "styled-components-breakpoint"; import useMeasure from "react-use-measure"; +import { HEADER_HEIGHT } from "@shared/constants"; import { depths, s } from "@shared/styles"; import { supportsPassiveListener } from "@shared/utils/browser"; import Button from "~/components/Button"; @@ -24,7 +25,7 @@ import history from "~/utils/history"; import { closeSplitPane } from "~/utils/splitView"; import { TooltipProvider } from "./TooltipContext"; -export const HEADER_HEIGHT = 64; +export { HEADER_HEIGHT }; type Props = { left?: React.ReactNode; @@ -207,7 +208,7 @@ const Wrapper = styled(Flex)` } ${breakpoint("tablet")` - padding: 16px; + padding: 12px; ${(props: WrapperProps) => props.$insetTitleAdjust && `padding-left: 64px;`} `}; `; diff --git a/app/components/Sidebar/Shared.tsx b/app/components/Sidebar/Shared.tsx index 358d861f08..f15ba2fe8f 100644 --- a/app/components/Sidebar/Shared.tsx +++ b/app/components/Sidebar/Shared.tsx @@ -139,7 +139,7 @@ const SearchButton = styled.button` gap: 8px; width: 100%; padding: 6px 12px; - margin: 8px 0; + margin: 4px 0 12px; border: 1px solid ${s("inputBorder")}; border-radius: 16px; background: ${s("background")}; diff --git a/app/hooks/useKeyboardShortcutsQuery.tsx b/app/hooks/useKeyboardShortcutsQuery.tsx new file mode 100644 index 0000000000..f2384133b4 --- /dev/null +++ b/app/hooks/useKeyboardShortcutsQuery.tsx @@ -0,0 +1,31 @@ +import { useEffect } from "react"; +import { useTranslation } from "react-i18next"; +import KeyboardShortcuts from "~/scenes/KeyboardShortcuts"; +import useQuery from "./useQuery"; +import useStores from "./useStores"; + +/** + * Open the keyboard shortcuts guide when a "shortcuts" param is present in the + * query string, optionally filtered by the value of the param. This is used to + * deep link to the guide from external sources, such as emails. + */ +export default function useKeyboardShortcutsQuery() { + const { t } = useTranslation(); + const { dialogs } = useStores(); + const query = useQuery(); + const shortcutsQuery = query.get("shortcuts"); + + useEffect(() => { + if (shortcutsQuery === null) { + return; + } + + dialogs.openGuide({ + title: t("Keyboard shortcuts"), + content: , + }); + // Only the query param should open the guide, re-running when the other + // dependencies change would reopen an already dismissed dialog. + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [shortcutsQuery]); +} diff --git a/app/routes/authenticated.tsx b/app/routes/authenticated.tsx index 1291ac0ca4..f3b138bf99 100644 --- a/app/routes/authenticated.tsx +++ b/app/routes/authenticated.tsx @@ -13,6 +13,7 @@ import WebsocketProvider from "~/components/WebsocketProvider"; import useCurrentTeam from "~/hooks/useCurrentTeam"; import usePolicy from "~/hooks/usePolicy"; import useQueryNotices from "~/hooks/useQueryNotices"; +import useKeyboardShortcutsQuery from "~/hooks/useKeyboardShortcutsQuery"; import lazy from "~/utils/lazyWithRetry"; import * as Scenes from "./scenes"; import { @@ -50,6 +51,7 @@ const RedirectDocument = ({ */ function AuthenticatedRoutes() { useQueryNotices(); + useKeyboardShortcutsQuery(); const team = useCurrentTeam(); const can = usePolicy(team); diff --git a/app/scenes/Document/components/Footer.tsx b/app/scenes/Document/components/Footer.tsx index 9ba7134b8b..20eaa04120 100644 --- a/app/scenes/Document/components/Footer.tsx +++ b/app/scenes/Document/components/Footer.tsx @@ -1,6 +1,5 @@ import styled from "styled-components"; import type Document from "~/models/Document"; -import KeyboardShortcutsButton from "./KeyboardShortcutsButton"; import ConnectionStatus from "./ConnectionStatus"; import { SizeWarning } from "./SizeWarning"; @@ -12,14 +11,13 @@ export const Footer = ({ document }: Props) => ( - ); const FooterWrapper = styled.div` position: fixed; bottom: 12px; - right: 20px; + right: 12px; text-align: right; display: flex; justify-content: flex-end; diff --git a/app/scenes/Document/components/Header.tsx b/app/scenes/Document/components/Header.tsx index c387a3ab78..ec6975d75b 100644 --- a/app/scenes/Document/components/Header.tsx +++ b/app/scenes/Document/components/Header.tsx @@ -6,6 +6,7 @@ import { Link } from "react-router-dom"; import useMeasure from "react-use-measure"; import styled, { useTheme } from "styled-components"; import Icon from "@shared/components/Icon"; +import { HEADER_HEIGHT } from "@shared/constants"; import { s } from "@shared/styles"; import { altDisplay, metaDisplay } from "@shared/utils/keyboard"; import { publishDocument } from "~/actions/definitions/documents"; @@ -84,7 +85,7 @@ function DocumentHeader({ useEffect(() => { window.document.documentElement.style.setProperty( "--header-offset", - isEditingFocus ? "0px" : "64px" + isEditingFocus ? "0px" : `${HEADER_HEIGHT}px` ); }, [isEditingFocus]); diff --git a/app/scenes/Document/components/KeyboardShortcutsButton.tsx b/app/scenes/Document/components/KeyboardShortcutsButton.tsx deleted file mode 100644 index 4467b45b7b..0000000000 --- a/app/scenes/Document/components/KeyboardShortcutsButton.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import { observer } from "mobx-react"; -import { KeyboardIcon } from "outline-icons"; -import { useEffect } from "react"; -import { useTranslation } from "react-i18next"; -import styled from "styled-components"; -import breakpoint from "styled-components-breakpoint"; -import KeyboardShortcuts from "~/scenes/KeyboardShortcuts"; -import NudeButton from "~/components/NudeButton"; -import Tooltip from "~/components/Tooltip"; -import useEditingFocus from "~/hooks/useEditingFocus"; -import useQuery from "~/hooks/useQuery"; -import useStores from "~/hooks/useStores"; - -function KeyboardShortcutsButton() { - const { t } = useTranslation(); - const { dialogs } = useStores(); - const isEditingFocus = useEditingFocus(); - const query = useQuery(); - const shortcutsQuery = query.get("shortcuts"); - - const handleOpenKeyboardShortcuts = (defaultQuery?: string) => { - dialogs.openGuide({ - title: t("Keyboard shortcuts"), - content: , - }); - }; - - useEffect(() => { - if (shortcutsQuery !== null) { - handleOpenKeyboardShortcuts(shortcutsQuery); - } - // Only the query param should open the guide, re-running when the handler - // identity changes would reopen an already dismissed dialog. - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [shortcutsQuery]); - - return ( - - - - ); -} - -const Button = styled(NudeButton)<{ $hidden: boolean }>` - display: none; - transition: opacity 500ms ease-in-out; - ${(props) => props.$hidden && "opacity: 0;"} - - ${breakpoint("tablet")` - display: block; - `}; - - @media print { - display: none; - } -`; - -export default observer(KeyboardShortcutsButton); diff --git a/app/scenes/Document/components/SharedHeader.tsx b/app/scenes/Document/components/SharedHeader.tsx index dc797c5f59..df0b5028de 100644 --- a/app/scenes/Document/components/SharedHeader.tsx +++ b/app/scenes/Document/components/SharedHeader.tsx @@ -6,6 +6,7 @@ import { Link } from "react-router-dom"; import useMeasure from "react-use-measure"; import styled from "styled-components"; import Icon from "@shared/components/Icon"; +import { HEADER_HEIGHT } from "@shared/constants"; import useShare from "@shared/hooks/useShare"; import type { PublicTeam } from "@shared/types"; import { TOCPosition } from "@shared/types"; @@ -52,7 +53,7 @@ function SharedDocumentHeader({ document }: Props) { useEffect(() => { window.document.documentElement.style.setProperty( "--header-offset", - isEditingFocus ? "0px" : "64px" + isEditingFocus ? "0px" : `${HEADER_HEIGHT}px` ); }, [isEditingFocus]); diff --git a/app/scenes/Document/components/SidebarLayout.tsx b/app/scenes/Document/components/SidebarLayout.tsx index 37604f78c0..2a9306632a 100644 --- a/app/scenes/Document/components/SidebarLayout.tsx +++ b/app/scenes/Document/components/SidebarLayout.tsx @@ -6,6 +6,7 @@ import styled from "styled-components"; import { s, ellipsis } from "@shared/styles"; import Button from "~/components/Button"; import Flex from "~/components/Flex"; +import { HEADER_HEIGHT } from "~/components/Header"; import { PortalContext } from "~/components/Portal"; import { RightSidebarWrappedContext } from "~/components/RightSidebarContext"; import Scrollable from "~/components/Scrollable"; @@ -107,7 +108,9 @@ const Header = styled(Flex)` ${draggableOnDesktop()} align-items: center; position: relative; - padding: 16px 12px 16px 16px; + padding-block: 12px; + padding-inline: 16px 12px; + min-height: ${HEADER_HEIGHT}px; color: ${s("text")}; flex-shrink: 0; `; diff --git a/shared/constants.ts b/shared/constants.ts index efc526f8a1..4c88be4a5a 100644 --- a/shared/constants.ts +++ b/shared/constants.ts @@ -10,6 +10,9 @@ import { export const MAX_AVATAR_DISPLAY = 6; +/** Height of the app's fixed header in pixels. */ +export const HEADER_HEIGHT = 56; + /** Preset colors offered when choosing an icon color. */ export const colorPalette = [ "#4E5C6E", diff --git a/shared/editor/components/Styles.ts b/shared/editor/components/Styles.ts index 79242744fc..0f81446c78 100644 --- a/shared/editor/components/Styles.ts +++ b/shared/editor/components/Styles.ts @@ -2,6 +2,7 @@ import { lighten, transparentize } from "polished"; import type { DefaultTheme } from "styled-components"; import styled, { css, keyframes } from "styled-components"; +import { HEADER_HEIGHT } from "../../constants"; import { breakpoints, hover } from "../../styles"; import { EditorStyleHelper } from "../styles/EditorStyleHelper"; import { videoStyle } from "./Video"; @@ -2439,7 +2440,7 @@ table { } > .${EditorStyleHelper.tableScrollable} > table > tbody > tr:first-child > th { - transform: translateY(calc(var(--header-offset, 64px) + var(--sticky-scroll-offset, 0px))); + transform: translateY(calc(var(--header-offset, ${HEADER_HEIGHT}px) + var(--sticky-scroll-offset, 0px))); // Mask content scrolling past the top of the header (first shadow) and draw // the divider below it (second shadow). Using box-shadow rather than a real diff --git a/shared/editor/nodes/TableView.ts b/shared/editor/nodes/TableView.ts index e75c82e2f9..7694686eef 100644 --- a/shared/editor/nodes/TableView.ts +++ b/shared/editor/nodes/TableView.ts @@ -2,6 +2,7 @@ import type { Node } from "prosemirror-model"; import { TableView as ProsemirrorTableView } from "prosemirror-tables"; import { EditorStyleHelper } from "../styles/EditorStyleHelper"; import { TableLayout } from "../types"; +import { HEADER_HEIGHT } from "../../constants"; import { isBrowser } from "../../utils/browser"; export class TableView extends ProsemirrorTableView { @@ -110,9 +111,6 @@ export class TableView extends ProsemirrorTableView { private scrollHandler: (() => void) | null = null; - /** Default height of the app's fixed header */ - private static readonly HEADER_HEIGHT = 64; - /** * Sets up the scroll listener for sticky header behavior. Nested tables * (tables within another table) are excluded from sticky header behavior. @@ -207,12 +205,12 @@ export class TableView extends ProsemirrorTableView { */ private getHeaderOffset(): number { if (!isBrowser) { - return TableView.HEADER_HEIGHT; + return HEADER_HEIGHT; } const value = getComputedStyle(document.documentElement).getPropertyValue( "--header-offset" ); - return value ? parseFloat(value) : TableView.HEADER_HEIGHT; + return value ? parseFloat(value) : HEADER_HEIGHT; } }