shelving 1.304.1 → 1.306.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/ui/style/TINT_CLASS.md +17 -0
- package/ui/style/Tint.d.ts +2 -1
- package/ui/style/Tint.js +3 -2
- package/ui/style/Tint.tsx +3 -2
- package/ui/table/Cell.d.ts +5 -2
- package/ui/table/Cell.js +5 -2
- package/ui/table/Cell.tsx +8 -3
- package/ui/table/Table.d.ts +3 -1
- package/ui/table/Table.js +3 -2
- package/ui/table/Table.md +19 -2
- package/ui/table/Table.module.css +156 -0
- package/ui/table/Table.tsx +5 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shelving",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.306.0",
|
|
4
4
|
"author": "Dave Houlbrooke <dave@shax.com>",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@biomejs/biome": "^2.5.15",
|
|
13
13
|
"@heroicons/react": "^2.2.0",
|
|
14
|
-
"@types/bun": "^1.4.
|
|
14
|
+
"@types/bun": "^1.4.3",
|
|
15
15
|
"@types/react": "^19.3.0",
|
|
16
16
|
"@types/react-dom": "^19.3.0",
|
|
17
17
|
"stylelint": "^17.16.0",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"type": "module",
|
|
83
83
|
"types": "./index.d.ts",
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"react": "^19.3.
|
|
86
|
-
"react-dom": "^19.3.
|
|
85
|
+
"react": "^19.3.1",
|
|
86
|
+
"react-dom": "^19.3.1"
|
|
87
87
|
}
|
|
88
88
|
}
|
package/ui/style/TINT_CLASS.md
CHANGED
|
@@ -48,4 +48,21 @@ A theme is a CSS file of custom-property overrides at `:root`, imported after th
|
|
|
48
48
|
2. **Retint a region.** Apply `color=` / `status=` to a container — `<Card color="purple">`, or a `<Panel color="purple">` wrapping a whole section — and everything inside re-tints, with text, border, surface, and hover shades all derived for free. Components don't expose a per-component `--x-tint` hook; the variant moves the anchor, not a bespoke variable.
|
|
49
49
|
3. **Override one property.** Per-property hooks are the scalpel: `--button-radius: 999px`, `--card-radius: 0`, `--tag-case: none`.
|
|
50
50
|
|
|
51
|
+
**Overrides that use ladder steps go on `:root, .tint`.** A `var()` inside a custom property resolves where the property is declared. So an override at `:root` alone locks in the `:root` ladder, and stays grey inside a `<Card color="red">`:
|
|
52
|
+
|
|
53
|
+
```css
|
|
54
|
+
/* Wrong: `--tint-95` resolves once, at `:root`. */
|
|
55
|
+
:root {
|
|
56
|
+
--table-border: 2px solid var(--tint-95);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* Right: the value resolves again in every scope that rebuilds the ladder. */
|
|
60
|
+
:root,
|
|
61
|
+
.tint {
|
|
62
|
+
--table-border: 2px solid var(--tint-95);
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`TINT_CLASS` adds a plain global `tint` class (as well as its hashed module class) for this purpose, so `tint` is a reserved class name. Do not use `* { … }` for this: it declares the variable on every element, which adds style-recalc cost on large pages.
|
|
67
|
+
|
|
51
68
|
**Don't override individual ladder steps (`--tint-90`, etc.) at `:root`.** The ladder is *recomputed* from the anchor inside every `TINT_CLASS` scope — which includes every component that accepts `color=` or `status=` — so a step override at `:root` only reaches untinted regions and produces inconsistent surfaces. Move the anchor (option 1 or 2) instead, and the steps follow.
|
package/ui/style/Tint.d.ts
CHANGED
|
@@ -10,7 +10,8 @@ export type TintVariant = "00" | "05" | "10" | "15" | "20" | "25" | "30" | "35"
|
|
|
10
10
|
* CSS class that (re)calculates the full ladder of tint shades from the current global tint colour.
|
|
11
11
|
*
|
|
12
12
|
* - Applied by colour/status helpers so an element can compose shades like `--tint-20` and `--tint-95` of the selected hue.
|
|
13
|
+
* - Also adds the plain global `tint` class, so theme files can target the recompute scope with `:root, .tint { … }`.
|
|
13
14
|
*
|
|
14
15
|
* @see https://shelving.cc/ui/TINT_CLASS
|
|
15
16
|
*/
|
|
16
|
-
export declare const TINT_CLASS: string
|
|
17
|
+
export declare const TINT_CLASS: string;
|
package/ui/style/Tint.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { getModuleClass } from "../util/css.js";
|
|
1
|
+
import { getClass, getModuleClass } from "../util/css.js";
|
|
2
2
|
import THEME_CSS from "./Tint.module.css";
|
|
3
3
|
/**
|
|
4
4
|
* CSS class that (re)calculates the full ladder of tint shades from the current global tint colour.
|
|
5
5
|
*
|
|
6
6
|
* - Applied by colour/status helpers so an element can compose shades like `--tint-20` and `--tint-95` of the selected hue.
|
|
7
|
+
* - Also adds the plain global `tint` class, so theme files can target the recompute scope with `:root, .tint { … }`.
|
|
7
8
|
*
|
|
8
9
|
* @see https://shelving.cc/ui/TINT_CLASS
|
|
9
10
|
*/
|
|
10
|
-
export const TINT_CLASS = getModuleClass(THEME_CSS, "tint");
|
|
11
|
+
export const TINT_CLASS = getClass("tint", getModuleClass(THEME_CSS, "tint"));
|
package/ui/style/Tint.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getModuleClass } from "../util/css.js";
|
|
1
|
+
import { getClass, getModuleClass } from "../util/css.js";
|
|
2
2
|
import THEME_CSS from "./Tint.module.css";
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -36,7 +36,8 @@ export type TintVariant =
|
|
|
36
36
|
* CSS class that (re)calculates the full ladder of tint shades from the current global tint colour.
|
|
37
37
|
*
|
|
38
38
|
* - Applied by colour/status helpers so an element can compose shades like `--tint-20` and `--tint-95` of the selected hue.
|
|
39
|
+
* - Also adds the plain global `tint` class, so theme files can target the recompute scope with `:root, .tint { … }`.
|
|
39
40
|
*
|
|
40
41
|
* @see https://shelving.cc/ui/TINT_CLASS
|
|
41
42
|
*/
|
|
42
|
-
export const TINT_CLASS = getModuleClass(THEME_CSS, "tint");
|
|
43
|
+
export const TINT_CLASS = getClass("tint", getModuleClass(THEME_CSS, "tint"));
|
package/ui/table/Cell.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
|
+
import { type IndentVariants } from "../style/Indent.js";
|
|
3
|
+
import { type PaddingVariants } from "../style/Padding.js";
|
|
2
4
|
import { type TypographyVariants } from "../style/Typography.js";
|
|
3
5
|
import { type WidthVariants } from "../style/Width.js";
|
|
4
6
|
import type { ClassProps, OptionalChildProps } from "../util/index.js";
|
|
5
7
|
/**
|
|
6
|
-
* Props for `Cell` — width and typography variants plus `children`.
|
|
8
|
+
* Props for `Cell` — padding, indent, width, and typography variants plus `children`.
|
|
7
9
|
*
|
|
8
10
|
* @see https://shelving.cc/ui/CellProps
|
|
9
11
|
*/
|
|
10
|
-
export interface CellProps extends WidthVariants, TypographyVariants, OptionalChildProps, ClassProps {
|
|
12
|
+
export interface CellProps extends PaddingVariants, IndentVariants, WidthVariants, TypographyVariants, OptionalChildProps, ClassProps {
|
|
11
13
|
header?: boolean | undefined;
|
|
12
14
|
}
|
|
13
15
|
/**
|
|
@@ -15,6 +17,7 @@ export interface CellProps extends WidthVariants, TypographyVariants, OptionalCh
|
|
|
15
17
|
* - Rendered as `<td>` (or a `<th>` using `<Cell header>`).
|
|
16
18
|
* - Sets its column's width via the `width` variant. Unlike a `<col>`, a cell honours `min-width`, so `width="12x" grow` gives the column a hard minimum that fills the remaining space and keeps the table from collapsing the column on a narrow viewport.
|
|
17
19
|
* - A column's width is the widest of its cells, so use this to size a column that has no header to set the width on.
|
|
20
|
+
* - `padding` sets the cell's top and bottom padding, and `indent` its left and right. Both override the table's `padding` / `indent`, and `indent` also overrides the zero outer padding of the first and last cells.
|
|
18
21
|
*
|
|
19
22
|
* @kind component
|
|
20
23
|
* @see https://shelving.cc/ui/Cell
|
package/ui/table/Cell.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { getIndentClass } from "../style/Indent.js";
|
|
3
|
+
import { getPaddingClass } from "../style/Padding.js";
|
|
2
4
|
import { getTypographyClass } from "../style/Typography.js";
|
|
3
5
|
import { getWidthClass } from "../style/Width.js";
|
|
4
6
|
import { getClass } from "../util/css.js";
|
|
@@ -7,12 +9,13 @@ import { getClass } from "../util/css.js";
|
|
|
7
9
|
* - Rendered as `<td>` (or a `<th>` using `<Cell header>`).
|
|
8
10
|
* - Sets its column's width via the `width` variant. Unlike a `<col>`, a cell honours `min-width`, so `width="12x" grow` gives the column a hard minimum that fills the remaining space and keeps the table from collapsing the column on a narrow viewport.
|
|
9
11
|
* - A column's width is the widest of its cells, so use this to size a column that has no header to set the width on.
|
|
12
|
+
* - `padding` sets the cell's top and bottom padding, and `indent` its left and right. Both override the table's `padding` / `indent`, and `indent` also overrides the zero outer padding of the first and last cells.
|
|
10
13
|
*
|
|
11
14
|
* @kind component
|
|
12
15
|
* @see https://shelving.cc/ui/Cell
|
|
13
16
|
*/
|
|
14
17
|
export function Cell({ header = false, children, className, ...props }) {
|
|
15
18
|
const Component = header ? "th" : "td";
|
|
16
|
-
return (_jsx(Component, { className: getClass(
|
|
17
|
-
getTypographyClass(props), className), children: children }));
|
|
19
|
+
return (_jsx(Component, { className: getClass(getPaddingClass(props), //
|
|
20
|
+
getIndentClass(props), getWidthClass(props), getTypographyClass(props), className), children: children }));
|
|
18
21
|
}
|
package/ui/table/Cell.tsx
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
|
+
import { getIndentClass, type IndentVariants } from "../style/Indent.js";
|
|
3
|
+
import { getPaddingClass, type PaddingVariants } from "../style/Padding.js";
|
|
2
4
|
import { getTypographyClass, type TypographyVariants } from "../style/Typography.js";
|
|
3
5
|
import { getWidthClass, type WidthVariants } from "../style/Width.js";
|
|
4
6
|
import { getClass } from "../util/css.js";
|
|
5
7
|
import type { ClassProps, OptionalChildProps } from "../util/index.js";
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
|
-
* Props for `Cell` — width and typography variants plus `children`.
|
|
10
|
+
* Props for `Cell` — padding, indent, width, and typography variants plus `children`.
|
|
9
11
|
*
|
|
10
12
|
* @see https://shelving.cc/ui/CellProps
|
|
11
13
|
*/
|
|
12
|
-
export interface CellProps extends WidthVariants, TypographyVariants, OptionalChildProps, ClassProps {
|
|
14
|
+
export interface CellProps extends PaddingVariants, IndentVariants, WidthVariants, TypographyVariants, OptionalChildProps, ClassProps {
|
|
13
15
|
header?: boolean | undefined;
|
|
14
16
|
}
|
|
15
17
|
|
|
@@ -18,6 +20,7 @@ export interface CellProps extends WidthVariants, TypographyVariants, OptionalCh
|
|
|
18
20
|
* - Rendered as `<td>` (or a `<th>` using `<Cell header>`).
|
|
19
21
|
* - Sets its column's width via the `width` variant. Unlike a `<col>`, a cell honours `min-width`, so `width="12x" grow` gives the column a hard minimum that fills the remaining space and keeps the table from collapsing the column on a narrow viewport.
|
|
20
22
|
* - A column's width is the widest of its cells, so use this to size a column that has no header to set the width on.
|
|
23
|
+
* - `padding` sets the cell's top and bottom padding, and `indent` its left and right. Both override the table's `padding` / `indent`, and `indent` also overrides the zero outer padding of the first and last cells.
|
|
21
24
|
*
|
|
22
25
|
* @kind component
|
|
23
26
|
* @see https://shelving.cc/ui/Cell
|
|
@@ -27,7 +30,9 @@ export function Cell({ header = false, children, className, ...props }: CellProp
|
|
|
27
30
|
return (
|
|
28
31
|
<Component
|
|
29
32
|
className={getClass(
|
|
30
|
-
|
|
33
|
+
getPaddingClass(props), //
|
|
34
|
+
getIndentClass(props),
|
|
35
|
+
getWidthClass(props),
|
|
31
36
|
getTypographyClass(props),
|
|
32
37
|
className,
|
|
33
38
|
)}
|
package/ui/table/Table.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { type BlockVariants } from "../style/Block.js";
|
|
|
3
3
|
import type { ChildProps, ClassProps } from "../util/props.js";
|
|
4
4
|
/**
|
|
5
5
|
* Props for `Table` — colour, space, typography, and width variants plus `children`.
|
|
6
|
+
* - `padding` and `indent` set the padding of every cell, not of the `<table>` itself.
|
|
6
7
|
*
|
|
7
8
|
* @see https://shelving.cc/ui/TableProps
|
|
8
9
|
*/
|
|
@@ -12,8 +13,9 @@ export interface TableProps extends BlockVariants, ChildProps, ClassProps {
|
|
|
12
13
|
* Table block — rendered as `<table>`.
|
|
13
14
|
* - Wrap in a `<Scroll horizontal>` if the table may exceed the container width on small screens.
|
|
14
15
|
* - `<th>` / `<td>` cells draw the borders (the `<table>` element itself has none); override their weight via the `--table-border` / `--table-stroke` hooks.
|
|
16
|
+
* - `padding` sets the top and bottom padding of every cell, and `indent` the left and right. A `<Cell>` with its own `padding` or `indent` overrides them.
|
|
15
17
|
*
|
|
16
18
|
* @kind component
|
|
17
19
|
* @see https://shelving.cc/ui/Table
|
|
18
20
|
*/
|
|
19
|
-
export declare function Table({ children, className, ...props }: TableProps): ReactElement;
|
|
21
|
+
export declare function Table({ padding, indent, children, className, ...props }: TableProps): ReactElement;
|
package/ui/table/Table.js
CHANGED
|
@@ -7,11 +7,12 @@ const TABLE_CLASS = getModuleClass(TABLE_CSS, "table");
|
|
|
7
7
|
* Table block — rendered as `<table>`.
|
|
8
8
|
* - Wrap in a `<Scroll horizontal>` if the table may exceed the container width on small screens.
|
|
9
9
|
* - `<th>` / `<td>` cells draw the borders (the `<table>` element itself has none); override their weight via the `--table-border` / `--table-stroke` hooks.
|
|
10
|
+
* - `padding` sets the top and bottom padding of every cell, and `indent` the left and right. A `<Cell>` with its own `padding` or `indent` overrides them.
|
|
10
11
|
*
|
|
11
12
|
* @kind component
|
|
12
13
|
* @see https://shelving.cc/ui/Table
|
|
13
14
|
*/
|
|
14
|
-
export function Table({ children, className, ...props }) {
|
|
15
|
+
export function Table({ padding, indent, children, className, ...props }) {
|
|
15
16
|
return (_jsx("table", { className: getClass(TABLE_CLASS, //
|
|
16
|
-
getBlockClass(props), className), children: children }));
|
|
17
|
+
padding && getModuleClass(TABLE_CSS, `padding-${padding}`), indent && getModuleClass(TABLE_CSS, `indent-${indent}`), getBlockClass(props), className), children: children }));
|
|
17
18
|
}
|
package/ui/table/Table.md
CHANGED
|
@@ -10,6 +10,8 @@ A data table — renders a `<table>`. Compose the usual `<thead>` / `<tbody>` /
|
|
|
10
10
|
- Like the other block components it collapses its outer block margin when it is the first or last child.
|
|
11
11
|
- Spans the full width of its container by default; set the `width` variant (`narrow` / `normal` / `wide` / `full` / `fit`) to constrain it.
|
|
12
12
|
- Size columns with `<Cell>` and the `width` variant — `width="fit"` hugs the content, and `width="12x" grow` gives a column a hard minimum it can grow past (cells honour `min-width`, so the table scrolls rather than collapsing the column on a narrow screen). A column's width is the widest of its cells.
|
|
13
|
+
- Set cell padding for the whole table with the `padding` (top and bottom) and `indent` (left and right) variants — `<Table padding="small" indent="normal">`. These pad every cell, not the `<table>` itself.
|
|
14
|
+
- A `<Cell>` takes the same `padding` and `indent` variants, which override the table's values for that cell — for example `<Cell width="fit" padding="none">` around a button that already has its own padding.
|
|
13
15
|
- Inside `<Prose>` a raw `<table>` picks up the same styling, so Markdown-rendered tables match component ones.
|
|
14
16
|
|
|
15
17
|
## Usage
|
|
@@ -30,11 +32,26 @@ import { Table } from "shelving/ui";
|
|
|
30
32
|
</Table>
|
|
31
33
|
```
|
|
32
34
|
|
|
35
|
+
### Cell padding
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import { Button, Cell, Table } from "shelving/ui";
|
|
39
|
+
|
|
40
|
+
<Table padding="small">
|
|
41
|
+
<tbody>
|
|
42
|
+
<tr>
|
|
43
|
+
<Cell width="full">Alice</Cell>
|
|
44
|
+
<Cell width="fit" padding="none"><Button small>Remove</Button></Cell>
|
|
45
|
+
</tr>
|
|
46
|
+
</tbody>
|
|
47
|
+
</Table>
|
|
48
|
+
```
|
|
49
|
+
|
|
33
50
|
## Styling
|
|
34
51
|
|
|
35
52
|
`Table` exposes hooks for its rhythm, cell padding, and border; it paints no surface of its own, so it inherits the surrounding tint.
|
|
36
53
|
|
|
37
|
-
`--table-padding` sets the top and bottom padding of each cell, and `--table-indent` the left and right. Each takes one length. The outermost columns still drop their outer inline padding, and `<thead>` / `<tfoot>` their outer block padding, so the table stays flush with its container.
|
|
54
|
+
`--table-padding` sets the top and bottom padding of each cell, and `--table-indent` the left and right. Each takes one length. The table's `padding` and `indent` variants set these hooks. The outermost columns still drop their outer inline padding, and `<thead>` / `<tfoot>` their outer block padding, so the table stays flush with its container.
|
|
38
55
|
|
|
39
56
|
| Variable | Styles | Default |
|
|
40
57
|
|---|---|---|
|
|
@@ -56,7 +73,7 @@ import { Table } from "shelving/ui";
|
|
|
56
73
|
|
|
57
74
|
Defining contents for the `<Table>` is done with standard `<tr>`, `<th>`, `<td>`, `<thead>`, `<tbody>`, `<tfoot>` elements.
|
|
58
75
|
|
|
59
|
-
The `<Cell>` element can be used to define a `<td>` or `<th>`, and supports `WidthVariants` and `TypographyVariants` for styling.
|
|
76
|
+
The `<Cell>` element can be used to define a `<td>` or `<th>`, and supports `PaddingVariants`, `IndentVariants`, `WidthVariants` and `TypographyVariants` for styling.
|
|
60
77
|
|
|
61
78
|
## Column widths
|
|
62
79
|
|
|
@@ -63,3 +63,159 @@
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
+
|
|
67
|
+
@layer variants {
|
|
68
|
+
/* Cell padding (top and bottom) for every cell in the table, from the `padding` variant. */
|
|
69
|
+
.padding-none {
|
|
70
|
+
--table-padding: 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.padding-paragraph {
|
|
74
|
+
--table-padding: var(--space-paragraph);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.padding-section {
|
|
78
|
+
--table-padding: var(--space-section);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.padding-xxsmall {
|
|
82
|
+
--table-padding: var(--space-xxsmall);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.padding-xsmall {
|
|
86
|
+
--table-padding: var(--space-xsmall);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.padding-small {
|
|
90
|
+
--table-padding: var(--space-small);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.padding-normal {
|
|
94
|
+
--table-padding: var(--space-normal);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.padding-large {
|
|
98
|
+
--table-padding: var(--space-large);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.padding-xlarge {
|
|
102
|
+
--table-padding: var(--space-xlarge);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.padding-xxlarge {
|
|
106
|
+
--table-padding: var(--space-xxlarge);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.padding-1x {
|
|
110
|
+
--table-padding: calc(var(--space-normal) * 1);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.padding-2x {
|
|
114
|
+
--table-padding: calc(var(--space-normal) * 2);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.padding-3x {
|
|
118
|
+
--table-padding: calc(var(--space-normal) * 3);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.padding-4x {
|
|
122
|
+
--table-padding: calc(var(--space-normal) * 4);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.padding-5x {
|
|
126
|
+
--table-padding: calc(var(--space-normal) * 5);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.padding-6x {
|
|
130
|
+
--table-padding: calc(var(--space-normal) * 6);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.padding-7x {
|
|
134
|
+
--table-padding: calc(var(--space-normal) * 7);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.padding-8x {
|
|
138
|
+
--table-padding: calc(var(--space-normal) * 8);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.padding-9x {
|
|
142
|
+
--table-padding: calc(var(--space-normal) * 9);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.padding-10x {
|
|
146
|
+
--table-padding: calc(var(--space-normal) * 10);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/* Cell indent (left and right) for every cell in the table, from the `indent` variant. */
|
|
150
|
+
.indent-none {
|
|
151
|
+
--table-indent: 0;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.indent-xxsmall {
|
|
155
|
+
--table-indent: var(--space-xxsmall);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.indent-xsmall {
|
|
159
|
+
--table-indent: var(--space-xsmall);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.indent-small {
|
|
163
|
+
--table-indent: var(--space-small);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.indent-normal {
|
|
167
|
+
--table-indent: var(--space-normal);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.indent-large {
|
|
171
|
+
--table-indent: var(--space-large);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.indent-xlarge {
|
|
175
|
+
--table-indent: var(--space-xlarge);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.indent-xxlarge {
|
|
179
|
+
--table-indent: var(--space-xxlarge);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.indent-1x {
|
|
183
|
+
--table-indent: calc(var(--space-normal) * 1);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.indent-2x {
|
|
187
|
+
--table-indent: calc(var(--space-normal) * 2);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.indent-3x {
|
|
191
|
+
--table-indent: calc(var(--space-normal) * 3);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.indent-4x {
|
|
195
|
+
--table-indent: calc(var(--space-normal) * 4);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.indent-5x {
|
|
199
|
+
--table-indent: calc(var(--space-normal) * 5);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.indent-6x {
|
|
203
|
+
--table-indent: calc(var(--space-normal) * 6);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.indent-7x {
|
|
207
|
+
--table-indent: calc(var(--space-normal) * 7);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.indent-8x {
|
|
211
|
+
--table-indent: calc(var(--space-normal) * 8);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.indent-9x {
|
|
215
|
+
--table-indent: calc(var(--space-normal) * 9);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.indent-10x {
|
|
219
|
+
--table-indent: calc(var(--space-normal) * 10);
|
|
220
|
+
}
|
|
221
|
+
}
|
package/ui/table/Table.tsx
CHANGED
|
@@ -8,6 +8,7 @@ const TABLE_CLASS = getModuleClass(TABLE_CSS, "table");
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Props for `Table` — colour, space, typography, and width variants plus `children`.
|
|
11
|
+
* - `padding` and `indent` set the padding of every cell, not of the `<table>` itself.
|
|
11
12
|
*
|
|
12
13
|
* @see https://shelving.cc/ui/TableProps
|
|
13
14
|
*/
|
|
@@ -17,15 +18,18 @@ export interface TableProps extends BlockVariants, ChildProps, ClassProps {}
|
|
|
17
18
|
* Table block — rendered as `<table>`.
|
|
18
19
|
* - Wrap in a `<Scroll horizontal>` if the table may exceed the container width on small screens.
|
|
19
20
|
* - `<th>` / `<td>` cells draw the borders (the `<table>` element itself has none); override their weight via the `--table-border` / `--table-stroke` hooks.
|
|
21
|
+
* - `padding` sets the top and bottom padding of every cell, and `indent` the left and right. A `<Cell>` with its own `padding` or `indent` overrides them.
|
|
20
22
|
*
|
|
21
23
|
* @kind component
|
|
22
24
|
* @see https://shelving.cc/ui/Table
|
|
23
25
|
*/
|
|
24
|
-
export function Table({ children, className, ...props }: TableProps): ReactElement {
|
|
26
|
+
export function Table({ padding, indent, children, className, ...props }: TableProps): ReactElement {
|
|
25
27
|
return (
|
|
26
28
|
<table
|
|
27
29
|
className={getClass(
|
|
28
30
|
TABLE_CLASS, //
|
|
31
|
+
padding && getModuleClass(TABLE_CSS, `padding-${padding}`),
|
|
32
|
+
indent && getModuleClass(TABLE_CSS, `indent-${indent}`),
|
|
29
33
|
getBlockClass(props),
|
|
30
34
|
className,
|
|
31
35
|
)}
|