From ec456bf17b3424b41a29e4ecf95da2dccc5508d4 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 8 Jul 2026 11:03:14 +0000 Subject: [PATCH] refactor: Use spacing tokens in SplitButton, InputSelect, Drawer, Popover Pixel-identical substitution of hardcoded margin/padding values with spacing tokens from @shared/styles. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_014Hpjg2EbSwW1RTqkMdWQyT --- app/components/primitives/Drawer.tsx | 8 ++++---- app/components/primitives/InputSelect.tsx | 10 +++++----- app/components/primitives/Popover.tsx | 4 ++-- app/components/primitives/SplitButton.tsx | 14 +++++++------- .../primitives/components/InputSelect.tsx | 12 ++++++------ 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/app/components/primitives/Drawer.tsx b/app/components/primitives/Drawer.tsx index d556d400d3..d161a1b9b3 100644 --- a/app/components/primitives/Drawer.tsx +++ b/app/components/primitives/Drawer.tsx @@ -2,7 +2,7 @@ import * as VisuallyHidden from "@radix-ui/react-visually-hidden"; import * as React from "react"; import styled from "styled-components"; import { Drawer as DrawerPrimitive } from "vaul"; -import { depths, s } from "@shared/styles"; +import { depths, s, space, spacing } from "@shared/styles"; import Flex from "../Flex"; import Text from "../Text"; import { Overlay } from "./components/Overlay"; @@ -101,13 +101,13 @@ const StyledContent = styled(m.div)` `; const StyledInnerContent = styled(Flex)` - padding: 6px; - padding-bottom: calc(6px + var(--sab, 0px)); + padding: ${spacing.sm}px; + padding-bottom: calc(${spacing.sm}px + var(--sab, 0px)); height: 100%; `; const TitleWrapper = styled(Flex)` - padding: 8px 0; + padding: ${space("md", 0)}; `; export { Drawer, DrawerTrigger, DrawerHandle, DrawerContent, DrawerTitle }; diff --git a/app/components/primitives/InputSelect.tsx b/app/components/primitives/InputSelect.tsx index dbafe63786..6e74009a10 100644 --- a/app/components/primitives/InputSelect.tsx +++ b/app/components/primitives/InputSelect.tsx @@ -2,7 +2,7 @@ import * as InputSelectPrimitive from "@radix-ui/react-select"; import * as React from "react"; import styled from "styled-components"; import Text from "@shared/components/Text"; -import { depths, s } from "@shared/styles"; +import { depths, s, space, spacing } from "@shared/styles"; import type { Props as ButtonProps } from "~/components/Button"; import { fadeAndSlideDown, fadeAndSlideUp } from "~/styles/animations"; import { @@ -108,7 +108,7 @@ const InputSelectSeparator = React.forwardRef< InputSelectSeparator.displayName = InputSelectPrimitive.Separator.displayName; const Separator = styled.hr` - margin: 6px 0; + margin: ${space("sm", 0)}; `; /** Non-selectable heading rendered to group options in the menu. */ @@ -130,8 +130,8 @@ const Heading = styled(Text).attrs({ weight: "bold", })` display: block; - padding-block: 8px 4px; - padding-inline: 8px; + padding-block: ${spacing.md}px ${spacing.xs}px; + padding-inline: ${spacing.md}px; text-transform: uppercase; letter-spacing: 0.04em; `; @@ -144,7 +144,7 @@ const StyledContent = styled(InputSelectPrimitive.Content)` min-height: 44px; max-height: 350px; - padding: 4px; + padding: ${spacing.xs}px; border-radius: 6px; background: ${s("menuBackground")}; box-shadow: ${s("menuShadow")}; diff --git a/app/components/primitives/Popover.tsx b/app/components/primitives/Popover.tsx index c1b4510127..4713edfbff 100644 --- a/app/components/primitives/Popover.tsx +++ b/app/components/primitives/Popover.tsx @@ -2,7 +2,7 @@ import * as PopoverPrimitive from "@radix-ui/react-popover"; import * as React from "react"; import { mergeRefs } from "react-merge-refs"; import styled from "styled-components"; -import { depths, s } from "@shared/styles"; +import { depths, s, space } from "@shared/styles"; import { fadeAndScaleIn } from "~/styles/animations"; import { usePortalContext } from "../Portal"; @@ -113,7 +113,7 @@ const StyledContent = styled(PopoverPrimitive.Content)` border-radius: 6px; outline: none; - padding: ${({ $shrink }) => ($shrink ? "6px 0" : "12px 24px")}; + padding: ${({ $shrink }) => ($shrink ? space("sm", 0) : space("lg", "xxl"))}; ${({ $width }) => $width && `width: ${$width}px`}; ${({ $minWidth }) => $minWidth && `min-width: ${$minWidth}px`}; diff --git a/app/components/primitives/SplitButton.tsx b/app/components/primitives/SplitButton.tsx index 6e912ce146..6884e87a01 100644 --- a/app/components/primitives/SplitButton.tsx +++ b/app/components/primitives/SplitButton.tsx @@ -3,7 +3,7 @@ import { CheckmarkIcon, ExpandedIcon } from "outline-icons"; import { transparentize } from "polished"; import * as React from "react"; import styled, { css } from "styled-components"; -import { s } from "@shared/styles"; +import { s, space, spacing } from "@shared/styles"; import { fadeAndScaleIn } from "~/styles/animations"; import { undraggableOnDesktop } from "~/styles"; @@ -177,7 +177,7 @@ const MainButton = styled.button<{ $neutral?: boolean }>` ${buttonReset} display: flex; align-items: center; - padding: 0 8px; + padding: ${space(0, "md")}; border-radius: 6px 0 0 6px; white-space: nowrap; transition: background 200ms ease-out; @@ -196,7 +196,7 @@ const DisclosureButton = styled.button<{ $neutral?: boolean }>` display: flex; align-items: center; justify-content: center; - padding: 0 4px; + padding: ${space(0, "xs")}; border-radius: 0 6px 6px 0; transition: background 200ms ease-out; @@ -213,7 +213,7 @@ const DisclosureButton = styled.button<{ $neutral?: boolean }>` const Divider = styled.span<{ $neutral?: boolean }>` width: 1px; align-self: stretch; - margin: 6px 0; + margin: ${space("sm", 0)}; background: ${(props) => props.$neutral ? transparentize(0.7, props.theme.buttonNeutralText) @@ -231,7 +231,7 @@ const MenuContent = styled.div` background: ${s("menuBackground")}; box-shadow: ${s("menuShadow")}; border-radius: 6px; - padding: 6px; + padding: ${spacing.sm}px; outline: none; transform-origin: var(--radix-dropdown-menu-content-transform-origin); @@ -250,8 +250,8 @@ const MenuItem = styled.button` font-size: 14px; color: ${s("textSecondary")}; border-radius: 4px; - padding: 4px 12px; - gap: 8px; + padding: ${space("xs", "lg")}; + gap: ${spacing.md}px; user-select: none; &[data-highlighted] { diff --git a/app/components/primitives/components/InputSelect.tsx b/app/components/primitives/components/InputSelect.tsx index 9ec1afaf33..1b535c6c96 100644 --- a/app/components/primitives/components/InputSelect.tsx +++ b/app/components/primitives/components/InputSelect.tsx @@ -6,7 +6,7 @@ import { CheckmarkIcon } from "outline-icons"; import { forwardRef } from "react"; import styled, { css } from "styled-components"; import breakpoint from "styled-components-breakpoint"; -import { s } from "@shared/styles"; +import { s, spacing } from "@shared/styles"; import Button, { Inner } from "~/components/Button"; import Flex from "~/components/Flex"; import Text from "~/components/Text"; @@ -73,8 +73,8 @@ export const SelectButton = styled(Button)<{ $nude?: boolean }>` ${Inner} { line-height: 28px; - padding-inline-start: 12px; - padding-inline-end: 4px; + padding-inline-start: ${spacing.lg}px; + padding-inline-end: ${spacing.xs}px; } svg { @@ -95,7 +95,7 @@ const ItemContainer = styled(Flex)` color: ${s("textSecondary")}; background: none; margin: 0; - padding: 12px; + padding: ${spacing.lg}px; border: 0; border-radius: 4px; outline: 0; @@ -131,8 +131,8 @@ const ItemContainer = styled(Flex)` ${breakpoint("tablet")` font-size: 14px; - padding: 4px; - padding-inline-start: 8px; + padding: ${spacing.xs}px; + padding-inline-start: ${spacing.md}px; `} `;