diff --git a/app/components/Sidebar/components/SidebarButton.tsx b/app/components/Sidebar/components/SidebarButton.tsx index c0856ad7d8..c50b62d3c8 100644 --- a/app/components/Sidebar/components/SidebarButton.tsx +++ b/app/components/Sidebar/components/SidebarButton.tsx @@ -1,7 +1,8 @@ import { MoreIcon } from "outline-icons"; import * as React from "react"; import styled from "styled-components"; -import { extraArea, s } from "@shared/styles"; +import { extraArea, hover, s } from "@shared/styles"; +import { isMobile } from "@shared/utils/browser"; import Flex from "~/components/Flex"; import Text from "~/components/Text"; import { draggableOnDesktop, undraggableOnDesktop } from "~/styles"; @@ -82,12 +83,12 @@ const Button = styled(Flex)<{ flex: 1; color: ${s("textTertiary")}; align-items: center; - padding: 4px; + padding: ${isMobile() ? 12 : 4}px 4px; font-size: 15px; font-weight: 500; border-radius: 4px; border: 0; - margin: ${(props) => (props.$position === "top" ? 16 : 8)}px 0; + margin: ${(props) => (!isMobile() && props.$position === "top" ? 16 : 8)}px 0; background: none; flex-shrink: 0; @@ -102,7 +103,7 @@ const Button = styled(Flex)<{ ${extraArea(4)} &:active, - &:hover, + &:${hover}, &[aria-expanded="true"] { color: ${s("sidebarText")}; background: ${s("sidebarActiveBackground")}; diff --git a/app/components/Sidebar/components/SidebarLink.tsx b/app/components/Sidebar/components/SidebarLink.tsx index 350a07a649..01ecbfc966 100644 --- a/app/components/Sidebar/components/SidebarLink.tsx +++ b/app/components/Sidebar/components/SidebarLink.tsx @@ -4,6 +4,7 @@ import styled, { useTheme, css } from "styled-components"; import breakpoint from "styled-components-breakpoint"; import EventBoundary from "@shared/components/EventBoundary"; import { s } from "@shared/styles"; +import { isMobile } from "@shared/utils/browser"; import NudeButton from "~/components/NudeButton"; import { UnreadBadge } from "~/components/UnreadBadge"; import useUnmount from "~/hooks/useUnmount"; @@ -196,7 +197,7 @@ const Link = styled(NavLink)<{ position: relative; text-overflow: ellipsis; font-weight: 475; - padding: 6px 16px; + padding: ${isMobile() ? 12 : 6}px 16px; border-radius: 4px; min-height: 32px; user-select: none; diff --git a/app/editor/components/FloatingToolbar.tsx b/app/editor/components/FloatingToolbar.tsx index cfcbe77d46..f05e44663e 100644 --- a/app/editor/components/FloatingToolbar.tsx +++ b/app/editor/components/FloatingToolbar.tsx @@ -240,7 +240,7 @@ const FloatingToolbar = React.forwardRef(function FloatingToolbar_( return null; } - if (props.active) { + if (props.active && position.visible) { const rect = document.body.getBoundingClientRect(); const safeAreaInsets = getSafeAreaInsets(); diff --git a/shared/utils/browser.ts b/shared/utils/browser.ts index 578669141a..bdd6729af7 100644 --- a/shared/utils/browser.ts +++ b/shared/utils/browser.ts @@ -11,7 +11,8 @@ export const isPWA = window.matchMedia?.("(display-mode: standalone)").matches; /** - * Returns true if the client is a touch device. + * Returns true if the client is a touch device. Note that laptops with touch screens are + * considered touch devices. */ export function isTouchDevice(): boolean { if (!isBrowser) { @@ -20,6 +21,18 @@ export function isTouchDevice(): boolean { return window.matchMedia?.("(hover: none) and (pointer: coarse)")?.matches; } +/** + * Returns true if the client is a mobile device. + */ +export function isMobile(): boolean { + if (!isBrowser) { + return false; + } + + // Matches breakpoints.tablet - 1 but not imported to avoid circular dependency + return window.matchMedia?.(`(max-width: ${736}px)`)?.matches; +} + /** * Returns the safe area insets for the current device. */