mirror of
https://github.com/outline/outline.git
synced 2026-12-01 09:22:14 +03:00
Tighten header, remove keyboard shortcuts floating button (#13304)
* Tighten header, remove keyboard shortcuts floating button * fix: Standardize heading height const
This commit is contained in:
1 parent
d18783c43f
commit
bc2c9ffd65
12 files changed
+54
-79
No files matched your search
@@ -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)<WrapperProps>`
|
||||
}
|
||||
|
||||
${breakpoint("tablet")`
|
||||
padding: 16px;
|
||||
padding: 12px;
|
||||
${(props: WrapperProps) => props.$insetTitleAdjust && `padding-left: 64px;`}
|
||||
`};
|
||||
`;
|
||||
|
||||
@@ -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")};
|
||||
|
||||
@@ -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: <KeyboardShortcuts defaultQuery={shortcutsQuery} />,
|
||||
});
|
||||
// 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]);
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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) => (
|
||||
<FooterWrapper>
|
||||
<ConnectionStatus />
|
||||
<SizeWarning document={document} />
|
||||
<KeyboardShortcutsButton />
|
||||
</FooterWrapper>
|
||||
);
|
||||
|
||||
const FooterWrapper = styled.div`
|
||||
position: fixed;
|
||||
bottom: 12px;
|
||||
right: 20px;
|
||||
right: 12px;
|
||||
text-align: right;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
|
||||
@@ -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]);
|
||||
|
||||
|
||||
@@ -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: <KeyboardShortcuts defaultQuery={defaultQuery} />,
|
||||
});
|
||||
};
|
||||
|
||||
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 (
|
||||
<Tooltip content={t("Keyboard shortcuts")} shortcut="?">
|
||||
<Button
|
||||
onClick={() => handleOpenKeyboardShortcuts()}
|
||||
$hidden={isEditingFocus}
|
||||
aria-label={t("Keyboard shortcuts")}
|
||||
>
|
||||
<KeyboardIcon />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -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]);
|
||||
|
||||
|
||||
@@ -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;
|
||||
`;
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user