From 0842aba57cf565c64a68e9eb0e0e89bc00a12c03 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Thu, 14 Apr 2022 15:53:51 -0700 Subject: [PATCH] Always display the article actions toolbar on top for PDFs Because we dont have margin space on PDFs we want to always display this on top. --- .../web/components/patterns/PrimaryHeader.tsx | 5 +- .../components/templates/PrimaryLayout.tsx | 4 +- .../templates/article/ArticleActionsMenu.tsx | 66 ++++++++++--------- .../web/pages/[username]/[slug]/index.tsx | 7 +- 4 files changed, 46 insertions(+), 36 deletions(-) diff --git a/packages/web/components/patterns/PrimaryHeader.tsx b/packages/web/components/patterns/PrimaryHeader.tsx index 79294d02f..12c7e4754 100644 --- a/packages/web/components/patterns/PrimaryHeader.tsx +++ b/packages/web/components/patterns/PrimaryHeader.tsx @@ -26,6 +26,7 @@ type HeaderProps = { isFixedPosition: boolean scrollElementRef?: React.RefObject toolbarControl?: JSX.Element + alwaysDisplayToolbar?: boolean setShowLogoutConfirmation: (showShareModal: boolean) => void setShowKeyboardCommandsModal: (showShareModal: boolean) => void } @@ -128,6 +129,7 @@ export function PrimaryHeader(props: HeaderProps): JSX.Element { isVisible={true} isFixedPosition={true} toolbarControl={props.toolbarControl} + alwaysDisplayToolbar={props.alwaysDisplayToolbar} /> ) @@ -143,6 +145,7 @@ type NavHeaderProps = { isVisible?: boolean isFixedPosition: boolean toolbarControl?: JSX.Element + alwaysDisplayToolbar?: boolean } function NavHeader(props: NavHeaderProps): JSX.Element { @@ -187,7 +190,7 @@ function NavHeader(props: NavHeaderProps): JSX.Element { headerToolbarControl?: JSX.Element + alwaysDisplayToolbar?: boolean } export function PrimaryLayout(props: PrimaryLayoutProps): JSX.Element { @@ -75,8 +76,9 @@ export function PrimaryLayout(props: PrimaryLayoutProps): JSX.Element { userInitials={viewerData?.me?.name.charAt(0) ?? ''} profileImageURL={viewerData?.me?.profile.pictureUrl} isFixedPosition={true} - toolbarControl={props.headerToolbarControl} scrollElementRef={props.scrollElementRef} + toolbarControl={props.headerToolbarControl} + alwaysDisplayToolbar={props.alwaysDisplayToolbar} setShowLogoutConfirmation={setShowLogoutConfirmation} setShowKeyboardCommandsModal={setShowKeyboardCommandsModal} /> diff --git a/packages/web/components/templates/article/ArticleActionsMenu.tsx b/packages/web/components/templates/article/ArticleActionsMenu.tsx index 880cfea9a..9b82691f0 100644 --- a/packages/web/components/templates/article/ArticleActionsMenu.tsx +++ b/packages/web/components/templates/article/ArticleActionsMenu.tsx @@ -1,7 +1,6 @@ import { Separator } from "@radix-ui/react-separator" import { ArchiveBox, DotsThree, HighlighterCircle, TagSimple, TextAa } from "phosphor-react" import { ArticleAttributes } from "../../../lib/networking/queries/useGetArticleQuery" -import { useGetUserPreferences } from "../../../lib/networking/queries/useGetUserPreferences" import { Button } from "../../elements/Button" import { Dropdown } from "../../elements/DropdownElements" import { Box, SpanBox } from "../../elements/LayoutPrimitives" @@ -9,15 +8,15 @@ import { TooltipWrapped } from "../../elements/Tooltip" import { styled, theme } from "../../tokens/stitches.config" import { SetLabelsControl } from "./SetLabelsControl" import { ReaderSettingsControl } from "./ReaderSettingsControl" -import { usePersistedState } from "../../../lib/hooks/usePersistedState" -export type ArticleActionsMenuLayout = 'horizontal' | 'vertical' +export type ArticleActionsMenuLayout = 'top' | 'side' type ArticleActionsMenuProps = { article: ArticleAttributes layout: ArticleActionsMenuLayout lineHeight: number marginWidth: number + showReaderDisplaySettings?: boolean articleActionHandler: (action: string, arg?: unknown) => void } @@ -32,7 +31,7 @@ const MenuSeparator = (props: MenuSeparatorProps): JSX.Element => { borderBottom: `1px solid ${theme.colors.grayLine.toString()}`, my: '8px', }) - return (props.layout == 'vertical' ? : <>) + return (props.layout == 'side' ? : <>) } type ActionDropdownProps = { @@ -45,10 +44,10 @@ const ActionDropdown = (props: ActionDropdownProps): JSX.Element => { return {props.children} @@ -62,32 +61,35 @@ export function ArticleActionsMenu(props: ArticleActionsMenuProps): JSX.Element css={{ display: 'flex', alignItems: 'center', - flexDirection: props.layout == 'vertical' ? 'column' : 'row', - justifyContent: props.layout == 'vertical' ? 'center' : 'flex-end', - gap: props.layout == 'vertical' ? '8px' : '24px', + flexDirection: props.layout == 'side' ? 'column' : 'row', + justifyContent: props.layout == 'side' ? 'center' : 'flex-end', + gap: props.layout == 'side' ? '8px' : '24px', paddingTop: '6px', }} > - - + + + + } > - - - } - > - - + + - + + + )} @@ -127,7 +129,7 @@ export function ArticleActionsMenu(props: ArticleActionsMenuProps): JSX.Element