Skip to content

Commit 4be1a86

Browse files
authored
refactor(opal): finish the padding migration and close the scales (#13919)
1 parent fe0961b commit 4be1a86

52 files changed

Lines changed: 139 additions & 115 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

web/lib/opal/src/components/buttons/line-item-button/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ A composite component that wraps `Interactive.Stateful > Interactive.Container >
99
```
1010
Interactive.Stateful <- selectVariant, state, interaction, onClick, href, ref
1111
└─ Interactive.Container <- width, rounding
12-
└─ ContentAction <- withInteractive, padding="lg"
12+
└─ ContentAction <- withInteractive, padding={2}
1313
├─ Content <- icon, title, description, sizePreset, variant, ...
1414
└─ rightChildren
1515
```
@@ -18,7 +18,7 @@ The row renders as a focusable `<div role="button">` (with Enter/Space activatio
1818
native `<button>`, so interactive `rightChildren` such as action buttons don't produce invalid
1919
button-in-button nesting. With `href` it renders an anchor instead.
2020

21-
`padding` is hardcoded to `"lg"` and `withInteractive` is always `true`. These are not exposed as props.
21+
`padding` is hardcoded to `2` and `withInteractive` is always `true`. These are not exposed as props.
2222

2323
## Props
2424

web/lib/opal/src/components/buttons/line-item-button/components.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function LineItemButton({
132132
<ContentAction
133133
color="interactive"
134134
{...(contentActionProps as ContentActionProps)}
135-
padding="fit"
135+
padding={0}
136136
/>
137137
</div>
138138
</Interactive.Container>

web/lib/opal/src/components/buttons/sidebar-tab/components.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ function SidebarTab({
212212
variant="body"
213213
color="interactive"
214214
width="full"
215-
padding="fit"
215+
padding={0}
216216
rightChildren={truncationSpacer}
217217
titleMaxLines={1}
218218
/>

web/lib/opal/src/components/cards/empty-message-card/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ A pre-configured Card for empty states. Renders a transparent card with a dashed
1313
| `sizePreset` | `"secondary" \| "main-ui"` | `"secondary"` | Controls layout and text sizing |
1414
| `icon` | `IconFunctionComponent` | `SvgEmpty` | Icon displayed alongside the title |
1515
| `title` | `string \| RichStr` || Primary message text (required) |
16-
| `padding` | `Spacing` | `4` | Padding, as a spacing step (`N / 4` rem) |
16+
| `padding` | `0 \| 0.5 \| 1 \| 2 \| 4 \| 6` | `4` | Padding, as a spacing step (`N / 4` rem). Closed set. |
1717
| `ref` | `React.Ref<HTMLDivElement>` || Ref forwarded to the root div |
1818

1919
### `sizePreset="main-ui"` only

web/lib/opal/src/components/cards/empty-message-card/components.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Card } from "@opal/components/cards/card/components";
22
import { Content } from "@opal/layouts";
33
import { SvgEmpty } from "@opal/icons";
4-
import type { IconFunctionComponent, Spacing, RichStr } from "@opal/types";
4+
import type { IconFunctionComponent, RichStr } from "@opal/types";
55

66
// ---------------------------------------------------------------------------
77
// Types
@@ -14,8 +14,16 @@ type EmptyMessageCardBaseProps = {
1414
/** Primary message text. */
1515
title: string | RichStr;
1616

17-
/** Padding preset for the card. @default "md" */
18-
padding?: Spacing;
17+
/**
18+
* Padding around the card, as a spacing step (`N / 4` rem).
19+
*
20+
* A closed set: an empty state is a fixed presentation, not a surface callers
21+
* lay out themselves, so it offers the densities the named scale did and no
22+
* more. `Card` stays open — it is the general-purpose container.
23+
*
24+
* @default 4
25+
*/
26+
padding?: 0 | 0.5 | 1 | 2 | 4 | 6;
1927

2028
/** Ref forwarded to the root Card div. */
2129
ref?: React.Ref<HTMLDivElement>;

web/lib/opal/src/components/cards/message-card/components.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ function MessageCard({
175175
titleMaxLines={titleMaxLines}
176176
sizePreset="main-ui"
177177
variant="section"
178-
padding="md"
178+
padding={1}
179179
rightChildren={right}
180180
/>
181181
</div>

web/lib/opal/src/components/divider/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ A plain line with no title or description.
1515
| Prop | Type | Default | Description |
1616
|---|---|---|---|
1717
| `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | Direction of the line |
18-
| `paddingParallel` | `Spacing` | `2` | Padding along the line direction (0.5rem) |
19-
| `paddingPerpendicular` | `Spacing` | `1` | Padding perpendicular to the line (0.25rem) |
18+
| `paddingParallel` | `0 \| 0.5 \| 1 \| 2 \| 4 \| 6` | `2` | Inset along the line direction, as a spacing step (`N / 4` rem) |
19+
| `paddingPerpendicular` | `0 \| 0.5 \| 1 \| 2 \| 4 \| 6` | `1` | Inset perpendicular to the line, as a spacing step (`N / 4` rem) |
2020

2121
### Titled divider
2222

web/lib/opal/src/components/divider/components.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import "@opal/components/divider/styles.css";
44
import { useState, useCallback } from "react";
5-
import type { OrientationVariants, Spacing, RichStr } from "@opal/types";
5+
import type { OrientationVariants, RichStr } from "@opal/types";
66
import { Button, Text } from "@opal/components";
77
import { SvgChevronRight } from "@opal/icons";
88
import { Interactive } from "@opal/core";
@@ -27,6 +27,15 @@ interface DividerSharedProps {
2727
children?: never;
2828
}
2929

30+
/**
31+
* The insets a divider offers, as spacing steps (`N / 4` rem).
32+
*
33+
* A closed set rather than an open number: a divider's inset is a shared rhythm
34+
* across the surfaces it separates, so an arbitrary step would only ever put one
35+
* divider out of step with the rest.
36+
*/
37+
type DividerSpacing = 0 | 0.5 | 1 | 2 | 4 | 6;
38+
3039
/** Plain line — no title, no description. */
3140
type DividerBareProps = Omit<
3241
DividerSharedProps,
@@ -35,9 +44,9 @@ type DividerBareProps = Omit<
3544
/** Orientation of the line. Default: `"horizontal"`. */
3645
orientation?: OrientationVariants;
3746
/** Padding along the line direction, as a spacing step. Default: `2` (0.5rem). */
38-
paddingParallel?: Spacing;
47+
paddingParallel?: DividerSpacing;
3948
/** Padding perpendicular to the line, as a spacing step. Default: `1` (0.25rem). */
40-
paddingPerpendicular?: Spacing;
49+
paddingPerpendicular?: DividerSpacing;
4150
};
4251

4352
/** Line with a title to the left. */
@@ -192,4 +201,4 @@ function FoldableDivider({
192201
);
193202
}
194203

195-
export { Divider, type DividerProps };
204+
export { Divider, type DividerProps, type DividerSpacing };

web/lib/opal/src/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export {
7979
export {
8080
Divider,
8181
type DividerProps,
82+
type DividerSpacing,
8283
} from "@opal/components/divider/components";
8384

8485
/* IconContainer */

web/lib/opal/src/components/inputs/input-select/components.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ import { cn } from "@opal/utils";
88
import type {
99
IconFunctionComponent,
1010
InputVariants,
11-
Spacing,
1211
RichStr,
1312
WithoutStyles,
1413
} from "@opal/types";
15-
import { Divider, InputTypeIn, Text, Tooltip } from "@opal/components";
14+
import {
15+
Divider,
16+
type DividerSpacing,
17+
InputTypeIn,
18+
Text,
19+
Tooltip,
20+
} from "@opal/components";
1621
import { toPlainString } from "@opal/components/text/InlineMarkdown";
1722
import { ContentAction } from "@opal/layouts";
1823
import { SvgChevronDownSmall } from "@opal/icons";
@@ -398,7 +403,7 @@ function InputSelectItem({
398403
titleMaxLines={1}
399404
description={description}
400405
descriptionMaxLines={wrapDescription ? undefined : 1}
401-
padding="fit"
406+
padding={0}
402407
width="full"
403408
/>
404409
</div>
@@ -434,8 +439,8 @@ function InputSelectLabel({
434439
}
435440

436441
interface InputSelectSeparatorProps {
437-
paddingParallel?: Spacing;
438-
paddingPerpendicular?: Spacing;
442+
paddingParallel?: DividerSpacing;
443+
paddingPerpendicular?: DividerSpacing;
439444
}
440445

441446
function InputSelectSeparator({

0 commit comments

Comments
 (0)