From d142bf1f44a0954feac2ff9c97df312d79cc647b Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 22 Oct 2026 20:51:54 -0400 Subject: [PATCH] feat: Increase small text sizes on mobile (#14255) --- app/components/HeaderMeta.tsx | 3 +- app/components/Notice.tsx | 3 +- .../components/Comments/HighlightText.ts | 3 +- app/scenes/Document/components/Editor.tsx | 4 +- .../Document/components/PresentationMode.tsx | 3 +- app/scenes/Login/Login.tsx | 3 +- app/scenes/Login/components/SigningIn.tsx | 3 +- app/scenes/Shared/Collection.tsx | 4 +- shared/components/Text.tsx | 60 +++++++++++++++---- 9 files changed, 58 insertions(+), 28 deletions(-) diff --git a/app/components/HeaderMeta.tsx b/app/components/HeaderMeta.tsx index 7adc09fcc3..06400216eb 100644 --- a/app/components/HeaderMeta.tsx +++ b/app/components/HeaderMeta.tsx @@ -1,4 +1,5 @@ import styled, { css } from "styled-components"; +import { textSizeStyles } from "@shared/components/Text"; import { breakpoint } from "@shared/styles/breakpoint"; import { s } from "@shared/styles"; import Flex from "~/components/Flex"; @@ -47,7 +48,7 @@ export const metaStyles = css<{ $rtl?: boolean }>` */ export const headerMetaStyles = css` margin: -12px 0 2em 0; - font-size: 14px; + ${textSizeStyles("small")} position: relative; user-select: none; z-index: 1; diff --git a/app/components/Notice.tsx b/app/components/Notice.tsx index f94da2eef4..4d1da0aa76 100644 --- a/app/components/Notice.tsx +++ b/app/components/Notice.tsx @@ -39,13 +39,12 @@ const Title = styled.span` font-size: 16px; `; -const Container = styled(Text)` +const Container = styled(Text).attrs({ size: "small" })` background: ${s("sidebarBackground")}; color: ${s("textTertiary")}; padding: 10px 12px; border-radius: 4px; position: relative; - font-size: 14px; margin: 1em 0; svg { diff --git a/app/scenes/Document/components/Comments/HighlightText.ts b/app/scenes/Document/components/Comments/HighlightText.ts index b2ae52984a..9dac580ccd 100644 --- a/app/scenes/Document/components/Comments/HighlightText.ts +++ b/app/scenes/Document/components/Comments/HighlightText.ts @@ -5,10 +5,9 @@ import Text from "~/components/Text"; /** * Highlighted text associated with a comment. */ -export const HighlightedText = styled(Text)` +export const HighlightedText = styled(Text).attrs({ size: "small" })` position: relative; color: ${s("textSecondary")}; - font-size: 14px; padding: 0 8px; margin: 4px 0; display: inline-block; diff --git a/app/scenes/Document/components/Editor.tsx b/app/scenes/Document/components/Editor.tsx index a557f23b80..453e305fa5 100644 --- a/app/scenes/Document/components/Editor.tsx +++ b/app/scenes/Document/components/Editor.tsx @@ -20,6 +20,7 @@ import Editor from "~/components/Editor"; import { useSplitView } from "~/components/SplitView/context"; import type { Editor as SharedEditor } from "~/editor"; import Flex from "~/components/Flex"; +import { headerMetaStyles } from "~/components/HeaderMeta"; import PlaceholderDocument from "~/components/PlaceholderDocument"; import Time from "~/components/Time"; import { withUIExtensions } from "~/editor/extensions"; @@ -304,8 +305,7 @@ function DocumentEditor(props: Props) { } const SharedMeta = styled(Text)` - margin: -12px 0 2em 0; - font-size: 14px; + ${headerMetaStyles} `; export default observer(DocumentEditor); diff --git a/app/scenes/Document/components/PresentationMode.tsx b/app/scenes/Document/components/PresentationMode.tsx index 9f8c54febc..398dd465d2 100644 --- a/app/scenes/Document/components/PresentationMode.tsx +++ b/app/scenes/Document/components/PresentationMode.tsx @@ -479,10 +479,9 @@ const TopBar = styled.div<{ $idle: boolean }>` transition: opacity 300ms ease; `; -const SlideCounter = styled(Text)` +const SlideCounter = styled(Text).attrs({ size: "small" })` font-variant-numeric: tabular-nums; color: ${s("textTertiary")}; - font-size: 14px; min-width: 60px; text-align: center; `; diff --git a/app/scenes/Login/Login.tsx b/app/scenes/Login/Login.tsx index bb657f8cc1..77f7b5f7f0 100644 --- a/app/scenes/Login/Login.tsx +++ b/app/scenes/Login/Login.tsx @@ -445,10 +445,9 @@ const Content = styled(Text)` margin-top: -8px; `; -const Note = styled(Text)` +const Note = styled(Text).attrs({ size: "small" })` color: ${s("textTertiary")}; text-align: center; - font-size: 14px; margin-top: 8px; em { diff --git a/app/scenes/Login/components/SigningIn.tsx b/app/scenes/Login/components/SigningIn.tsx index cf16eb3fe0..22675fd02a 100644 --- a/app/scenes/Login/components/SigningIn.tsx +++ b/app/scenes/Login/components/SigningIn.tsx @@ -29,10 +29,9 @@ export function SigningIn() { ); } -const Note = styled(Text)` +const Note = styled(Text).attrs({ size: "small" })` color: ${s("textTertiary")}; text-align: center; - font-size: 14px; margin-top: 8px; em { diff --git a/app/scenes/Shared/Collection.tsx b/app/scenes/Shared/Collection.tsx index 11b591b2f1..e9cf4b32c9 100644 --- a/app/scenes/Shared/Collection.tsx +++ b/app/scenes/Shared/Collection.tsx @@ -11,6 +11,7 @@ import { Action } from "~/components/Actions"; import Button from "~/components/Button"; import CenteredContent from "~/components/CenteredContent"; import Flex from "~/components/Flex"; +import { headerMetaStyles } from "~/components/HeaderMeta"; import Heading from "~/components/Heading"; import CollectionIcon from "~/components/Icons/CollectionIcon"; import Scene from "~/components/Scene"; @@ -102,8 +103,7 @@ const CollectionHeading = styled(Heading)` `; const SharedMeta = styled(Text)` - margin: -12px 0 2em 0; - font-size: 14px; + ${headerMetaStyles} `; export const Collection = observer(SharedCollection); diff --git a/shared/components/Text.tsx b/shared/components/Text.tsx index b3562d7a48..3622f8974f 100644 --- a/shared/components/Text.tsx +++ b/shared/components/Text.tsx @@ -1,11 +1,56 @@ import styled, { css } from "styled-components"; import { ellipsis } from "../styles"; +import { breakpoint } from "../styles/breakpoint"; + +type TextSize = "xlarge" | "large" | "medium" | "small" | "xsmall"; + +const fontSizes: Record = { + xlarge: 26, + large: 18, + medium: 16, + small: 14, + xsmall: 13, +}; + +const mobileSizes: Partial> = { + medium: "large", + small: "medium", + xsmall: "small", +}; + +/** + * Returns the font-size styles for a text size variant. Smaller variants are + * bumped up to the next size on mobile. + * + * @param size the size variant, or undefined to inherit. + * @returns the font-size styles. + */ +export const textSizeStyles = (size?: TextSize) => { + if (!size) { + return css` + font-size: inherit; + `; + } + + const mobileSize = mobileSizes[size]; + + return css` + font-size: ${fontSizes[size]}px; + + ${ + mobileSize && + breakpoint("mobile", "tablet")` + font-size: ${fontSizes[mobileSize]}px; + ` + } + `; +}; type Props = { /** The type of text to render */ type?: "secondary" | "tertiary" | "danger"; /** The size of the text */ - size?: "xlarge" | "large" | "medium" | "small" | "xsmall"; + size?: TextSize; /** The direction of the text (defaults to ltr) */ dir?: "ltr" | "rtl" | "auto"; /** Whether the text should be selectable (defaults to false) */ @@ -35,18 +80,7 @@ const Text = styled.span` : props.type === "danger" ? props.theme.brand.red : props.theme.text}; - font-size: ${(props) => - props.size === "xlarge" - ? "26px" - : props.size === "large" - ? "18px" - : props.size === "medium" - ? "16px" - : props.size === "small" - ? "14px" - : props.size === "xsmall" - ? "13px" - : "inherit"}; + ${(props) => textSizeStyles(props.size)} ${(props) => props.weight &&