baseline-kit 5.0.0 → 5.2.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/CHANGELOG.md +243 -0
- package/README.md +227 -353
- package/dist/baseline-kit.css +5 -2
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +25 -9
- package/dist/core.mjs +1 -1
- package/dist/guide.cjs +1 -1
- package/dist/guide.cjs.map +1 -1
- package/dist/guide.css +1 -1
- package/dist/guide.d.ts +16 -16
- package/dist/guide.mjs +147 -150
- package/dist/guide.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +22 -12
- package/dist/index.mjs +169 -158
- package/dist/index.mjs.map +1 -1
- package/dist/remix-server.d.ts +8 -0
- package/dist/remix-server.mjs +15 -0
- package/dist/remix-server.mjs.map +1 -0
- package/dist/remix.css +2 -0
- package/dist/remix.d.ts +191 -0
- package/dist/remix.mjs +984 -0
- package/dist/remix.mjs.map +1 -0
- package/dist/{src-QHaSfgVe.js → src-D0nL1BwZ.js} +96 -165
- package/dist/src-D0nL1BwZ.js.map +1 -0
- package/dist/src-R5usYJol.cjs +2 -0
- package/dist/src-R5usYJol.cjs.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/theme/default.css +0 -1
- package/dist/theme/tokens.css +0 -1
- package/dist/theme.css +4 -1
- package/package.json +86 -37
- package/dist/README.md +0 -468
- package/dist/core/src/config/defaults.d.ts +0 -2
- package/dist/core/src/config/index.d.ts +0 -3
- package/dist/core/src/config/merge.d.ts +0 -21
- package/dist/core/src/config/schema.d.ts +0 -33
- package/dist/core/src/descriptors/baseline.d.ts +0 -26
- package/dist/core/src/descriptors/box.d.ts +0 -20
- package/dist/core/src/descriptors/guide.d.ts +0 -44
- package/dist/core/src/descriptors/index.d.ts +0 -5
- package/dist/core/src/descriptors/padder.d.ts +0 -19
- package/dist/core/src/descriptors/spacer.d.ts +0 -24
- package/dist/core/src/index.d.ts +0 -10
- package/dist/core/src/types.d.ts +0 -62
- package/dist/core/src/utils/convert.d.ts +0 -10
- package/dist/core/src/utils/grid.d.ts +0 -18
- package/dist/core/src/utils/index.d.ts +0 -8
- package/dist/core/src/utils/math.d.ts +0 -9
- package/dist/core/src/utils/merge.d.ts +0 -28
- package/dist/core/src/utils/normalize.d.ts +0 -13
- package/dist/core/src/utils/padding.d.ts +0 -2
- package/dist/core/src/utils/parse.d.ts +0 -5
- package/dist/core/src/utils/snapping.d.ts +0 -2
- package/dist/core/src/validation/guide.d.ts +0 -3
- package/dist/core/src/validation/index.d.ts +0 -1
- package/dist/dom/src/index.d.ts +0 -11
- package/dist/dom/src/measure.d.ts +0 -18
- package/dist/dom/src/observers.d.ts +0 -5
- package/dist/dom/src/ssr.d.ts +0 -20
- package/dist/dom/src/timing.d.ts +0 -2
- package/dist/dom/src/viewport.d.ts +0 -7
- package/dist/dom/src/virtual.d.ts +0 -23
- package/dist/react/src/components/Baseline/Baseline.d.ts +0 -13
- package/dist/react/src/components/Baseline/index.d.ts +0 -1
- package/dist/react/src/components/Box/Box.d.ts +0 -26
- package/dist/react/src/components/Box/index.d.ts +0 -1
- package/dist/react/src/components/Config/Config.d.ts +0 -20
- package/dist/react/src/components/Config/index.d.ts +0 -2
- package/dist/react/src/components/Guide/Guide.d.ts +0 -16
- package/dist/react/src/components/Guide/index.d.ts +0 -1
- package/dist/react/src/components/Padder/Padder.d.ts +0 -20
- package/dist/react/src/components/Padder/index.d.ts +0 -1
- package/dist/react/src/components/Spacer/Spacer.d.ts +0 -14
- package/dist/react/src/components/Spacer/index.d.ts +0 -1
- package/dist/react/src/components/index.d.ts +0 -12
- package/dist/react/src/components/types.d.ts +0 -29
- package/dist/react/src/guide.d.ts +0 -10
- package/dist/react/src/hooks/index.d.ts +0 -10
- package/dist/react/src/hooks/useBaseline.d.ts +0 -26
- package/dist/react/src/hooks/useConfig.d.ts +0 -9
- package/dist/react/src/hooks/useDebug.d.ts +0 -6
- package/dist/react/src/hooks/useGuide.d.ts +0 -7
- package/dist/react/src/hooks/useIsClient.d.ts +0 -4
- package/dist/react/src/hooks/useMeasure.d.ts +0 -10
- package/dist/react/src/hooks/useVirtual.d.ts +0 -14
- package/dist/react/src/index.d.ts +0 -21
- package/dist/react/src/utils/index.d.ts +0 -9
- package/dist/react/src/utils/merge.d.ts +0 -10
- package/dist/react/src/utils/ssr.d.ts +0 -1
- package/dist/src-CMjyHjX5.cjs +0 -2
- package/dist/src-CMjyHjX5.cjs.map +0 -1
- package/dist/src-QHaSfgVe.js.map +0 -1
package/README.md
CHANGED
|
@@ -4,464 +4,338 @@
|
|
|
4
4
|

|
|
5
5
|

|
|
6
6
|
|
|
7
|
-
Baseline Kit is a
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
- [Config](#config)
|
|
25
|
-
- [Baseline](#baseline)
|
|
26
|
-
- [Guide](#guide)
|
|
27
|
-
- [Box](#box)
|
|
28
|
-
- [Theme System](#theme-system)
|
|
29
|
-
- [CSS Import Options](#css-import-options)
|
|
30
|
-
- [Theme Options](#theme-options)
|
|
31
|
-
- [Theme Variables Reference](#theme-variables-reference)
|
|
32
|
-
- [Browser Support](#browser-support)
|
|
33
|
-
- [React 19 Features](#react-19-features)
|
|
34
|
-
- [Server-Side Rendering (SSR)](#server-side-rendering-ssr)
|
|
35
|
-
- [SSR-Friendly Design](#ssr-friendly-design)
|
|
36
|
-
- [SSR Mode Prop](#ssr-mode-prop)
|
|
37
|
-
- [Development](#development)
|
|
38
|
-
- [Performance Features](#performance-features)
|
|
39
|
-
- [Contributing](#contributing)
|
|
40
|
-
- [License](#license)
|
|
41
|
-
|
|
42
|
-
## Features
|
|
43
|
-
|
|
44
|
-
- 📏 **Baseline Grid:** Core system for maintaining vertical rhythm and consistent spacing across your layouts
|
|
45
|
-
- 🎯 **Column Grid Guide:** Customizable overlay system for visualizing column-based layouts and alignment
|
|
46
|
-
- 📦 **Box Component:** Basic container with configurable spacing that snaps to the baseline grid
|
|
47
|
-
- 🧱 **Padder & Spacer:** Spacing primitives with optional baseline snapping
|
|
48
|
-
- 🎨 **Theme System:** Customizable colors and debug visuals through a centralized configuration
|
|
7
|
+
Baseline Kit is a development overlay and spacing toolkit for React 19. It
|
|
8
|
+
provides baseline and column grids, spacing primitives, scoped configuration,
|
|
9
|
+
and themeable debug visuals. It also ships a React-free adapter for the Remix 3
|
|
10
|
+
UI runtime.
|
|
11
|
+
|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
## What it includes
|
|
15
|
+
|
|
16
|
+
- **`Baseline`** — a horizontal baseline-grid overlay.
|
|
17
|
+
- **`Guide`** — a column-grid overlay with line, pattern, fixed, and auto modes.
|
|
18
|
+
- **`Box`**, **`Padder`**, and **`Spacer`** — spacing primitives that can align
|
|
19
|
+
content to the baseline grid.
|
|
20
|
+
- **`Config`** — scoped defaults for the base unit, colors, variants, and
|
|
21
|
+
debugging visibility.
|
|
22
|
+
- **React-free Remix support** — native `remix/ui` components with SSR,
|
|
23
|
+
hydration, measurement, and cleanup support.
|
|
49
24
|
|
|
50
25
|
## Requirements
|
|
51
26
|
|
|
52
|
-
-
|
|
53
|
-
-
|
|
27
|
+
- React 19 for the default and `baseline-kit/guide` entries.
|
|
28
|
+
- The React/core package declares Node.js 18+; native Remix requires
|
|
29
|
+
`remix@3.0.0-rc.2` and its Node.js 24.3+ runtime. Other Remix versions need
|
|
30
|
+
a compatibility check. Repository development requires Node.js 24.15+.
|
|
31
|
+
- TypeScript 5.8+, 6, or 7 when using TypeScript.
|
|
32
|
+
- A modern browser with CSS Grid and CSS custom property support.
|
|
54
33
|
|
|
55
34
|
## Installation
|
|
56
35
|
|
|
57
36
|
```shell
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
# Using yarn
|
|
62
|
-
yarn add baseline-kit
|
|
63
|
-
|
|
64
|
-
# Using pnpm
|
|
65
|
-
pnpm add baseline-kit
|
|
37
|
+
npm install baseline-kit react@19 react-dom@19
|
|
38
|
+
# or
|
|
39
|
+
bun add baseline-kit react@19 react-dom@19
|
|
66
40
|
```
|
|
67
41
|
|
|
68
|
-
|
|
69
|
-
For a development grid overlay, use the guide-only React and CSS subpaths:
|
|
70
|
-
|
|
71
|
-
```tsx
|
|
72
|
-
import 'baseline-kit/styles/guide'
|
|
73
|
-
import { Config, Guide } from 'baseline-kit/guide'
|
|
74
|
-
```
|
|
42
|
+
Choose the smallest entry point that matches the application:
|
|
75
43
|
|
|
76
|
-
|
|
44
|
+
| Use case | JavaScript entry | CSS entry |
|
|
45
|
+
| ------------------------------- | -------------------- | --------------------------------------------------- |
|
|
46
|
+
| React components | `baseline-kit` | `baseline-kit/styles` plus `baseline-kit/theme` |
|
|
47
|
+
| React guide only | `baseline-kit/guide` | `baseline-kit/styles/guide` |
|
|
48
|
+
| React-free Remix 3 UI | `baseline-kit/remix` | `baseline-kit/styles/remix` |
|
|
49
|
+
| Framework-independent utilities | `baseline-kit/core` | None |
|
|
50
|
+
| All React styles and theme | — | `baseline-kit/styles/full` |
|
|
51
|
+
| Optional reset | — | `baseline-kit/reset` or `baseline-kit/styles/reset` |
|
|
77
52
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
]
|
|
82
|
-
```
|
|
53
|
+
Baseline Kit includes its own TypeScript declarations. React and Remix remain
|
|
54
|
+
optional peer dependencies, so an application only installs the runtime it
|
|
55
|
+
uses.
|
|
83
56
|
|
|
84
|
-
|
|
57
|
+
## Quick start
|
|
85
58
|
|
|
86
59
|
```tsx
|
|
87
60
|
import 'baseline-kit/styles'
|
|
88
61
|
import 'baseline-kit/theme'
|
|
89
|
-
import {
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
If you prefer a single CSS file for every component plus the theme:
|
|
93
|
-
|
|
94
|
-
```tsx
|
|
95
|
-
import 'baseline-kit/styles/full'
|
|
96
|
-
|
|
97
|
-
// For Remix:
|
|
98
|
-
export const links = () => [
|
|
99
|
-
{ rel: 'stylesheet', href: 'baseline-kit/styles/full' },
|
|
100
|
-
]
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
The browser reset is not included by default. Import `baseline-kit/reset` or
|
|
104
|
-
`baseline-kit/styles/reset` only when you want Baseline Kit to provide one.
|
|
105
|
-
|
|
106
|
-
Baseline Kit is written in TypeScript and includes built-in type definitions—no additional packages required.
|
|
107
|
-
|
|
108
|
-
## Quick Start
|
|
109
|
-
|
|
110
|
-
```tsx
|
|
111
|
-
import React from 'react'
|
|
112
|
-
import { Config, Guide, Baseline, Box } from 'baseline-kit'
|
|
113
|
-
|
|
114
|
-
function App() {
|
|
115
|
-
const isDev = process.env.NODE_ENV === 'development'
|
|
116
|
-
const debugging = isDev ? 'visible' : 'hidden'
|
|
62
|
+
import { Baseline, Box, Config, Guide } from 'baseline-kit'
|
|
117
63
|
|
|
64
|
+
export function App() {
|
|
118
65
|
return (
|
|
119
66
|
<Config
|
|
120
67
|
base={8}
|
|
121
|
-
baseline={{ debugging }}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
spacer={{ debugging }}
|
|
68
|
+
baseline={{ debugging: 'visible' }}
|
|
69
|
+
guide={{ debugging: 'visible' }}
|
|
70
|
+
box={{ debugging: 'visible' }}
|
|
125
71
|
>
|
|
126
|
-
{
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
<Guide
|
|
134
|
-
variant="pattern"
|
|
135
|
-
columns={['100px', '200px', '100px']}
|
|
136
|
-
gap={16}
|
|
137
|
-
align="center"
|
|
138
|
-
width="1200px"
|
|
139
|
-
/>
|
|
140
|
-
|
|
141
|
-
{/* Box with baseline alignment */}
|
|
142
|
-
<Box
|
|
143
|
-
block={[2, 5]}
|
|
144
|
-
debugging="visible"
|
|
145
|
-
>
|
|
146
|
-
<h1>Content Aligned to the Grid</h1>
|
|
147
|
-
</Box>
|
|
148
|
-
|
|
149
|
-
<main>Your main content goes here...</main>
|
|
72
|
+
<main style={{ position: 'relative', height: '100vh' }}>
|
|
73
|
+
<Baseline height="100%" />
|
|
74
|
+
<Guide variant="fixed" columns={12} width="100%" />
|
|
75
|
+
<Box block={[16, 24]} snapping="height">
|
|
76
|
+
Content aligned to the grid
|
|
77
|
+
</Box>
|
|
78
|
+
</main>
|
|
150
79
|
</Config>
|
|
151
80
|
)
|
|
152
81
|
}
|
|
153
82
|
```
|
|
154
83
|
|
|
155
|
-
## Core
|
|
84
|
+
## Core concepts
|
|
156
85
|
|
|
157
|
-
### Base
|
|
86
|
+
### Base unit and sizing
|
|
158
87
|
|
|
159
|
-
|
|
160
|
-
|
|
88
|
+
`base` is the baseline interval in CSS pixels; it defaults to `8`. Numeric
|
|
89
|
+
spacing values are CSS pixel values, not multipliers. CSS dimensions such as
|
|
90
|
+
`100vh`, `50%`, `1rem`, and `calc(...)` on Baseline dimensions remain relative
|
|
91
|
+
and are resolved by the browser. Overlays are absolutely positioned: give their
|
|
92
|
+
parent `position: relative` and a definite height for percentage heights.
|
|
161
93
|
|
|
162
94
|
```tsx
|
|
163
|
-
<Config base={8}>
|
|
164
|
-
<Padder
|
|
165
|
-
|
|
166
|
-
inline={22} // Will be rounded to 24px (3 * base)
|
|
167
|
-
>
|
|
168
|
-
{/* Content automatically aligned to the 8px grid */}
|
|
95
|
+
<Config base={8}>
|
|
96
|
+
<Padder block={[16, 24]} inline={{ start: 8, end: 16 }}>
|
|
97
|
+
Content
|
|
169
98
|
</Padder>
|
|
170
99
|
</Config>
|
|
171
100
|
```
|
|
172
101
|
|
|
173
|
-
|
|
102
|
+
Spacing props accept the following shapes:
|
|
174
103
|
|
|
175
|
-
|
|
104
|
+
- `padding={16}` — all four sides.
|
|
105
|
+
- `padding={[8, 16]}` — 8px top/bottom and 16px left/right; three- and
|
|
106
|
+
four-value arrays follow CSS padding shorthand.
|
|
107
|
+
- `block={[16, 24]}` — block-start and block-end.
|
|
108
|
+
- `inline={{ start: 8, end: 16 }}` — inline-start and inline-end.
|
|
176
109
|
|
|
177
|
-
|
|
178
|
-
// Single number (applies to both sides)
|
|
179
|
-
block={16} // 16px top and bottom
|
|
180
|
-
|
|
181
|
-
// Array [start, end]
|
|
182
|
-
block={[2, 3]} // 2px top, 3px bottom
|
|
110
|
+
### Grid snapping
|
|
183
111
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
112
|
+
`Box` defaults to `snapping="clamp"`. `height` adds spacing to round the measured
|
|
113
|
+
height up to the next base interval; it adds that correction to the bottom by
|
|
114
|
+
default. Use `snapEdge="top"` with `snapping="height"` when the text's trimmed
|
|
115
|
+
alphabetic edge should stay anchored while the top padding absorbs the
|
|
116
|
+
correction. `snapEdge="bottom"` is the explicit equivalent of the default.
|
|
117
|
+
`clamp` reduces the top and bottom spacing modulo the base, and
|
|
118
|
+
`snapping="none"` keeps explicit spacing. Snapping happens once after the first
|
|
119
|
+
nonzero measurement, not continuously on resize. `Padder` uses height snapping
|
|
120
|
+
with bottom correction in both adapters. Set `ssrMode` on Padder to retain
|
|
121
|
+
explicit padding without applying its measured snap.
|
|
187
122
|
|
|
188
|
-
###
|
|
123
|
+
### Debugging modes
|
|
189
124
|
|
|
190
|
-
|
|
125
|
+
Every visual component supports one of these modes:
|
|
191
126
|
|
|
192
|
-
-
|
|
193
|
-
-
|
|
127
|
+
- `visible` — render and show the debug visual.
|
|
128
|
+
- `hidden` — hide debug paint while preserving content and spacing.
|
|
129
|
+
- `none` — disable debug paint and use ordinary padding instead of debug spacers.
|
|
194
130
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
Three modes are available for development and testing:
|
|
198
|
-
|
|
199
|
-
```tsx
|
|
200
|
-
debugging = "visible" // Shows all grid lines and measurements
|
|
201
|
-
debugging = "hidden" // Elements exist but are invisible
|
|
202
|
-
debugging = "none" // Removes debug elements entirely
|
|
203
|
-
```
|
|
131
|
+
Baseline and Guide keep an empty host in both hidden modes. They are debug
|
|
132
|
+
overlays marked `aria-hidden`; keep meaningful application content outside them.
|
|
204
133
|
|
|
205
134
|
## Components
|
|
206
135
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
#### 2. Debug overlays
|
|
216
|
-
|
|
217
|
-
- **`Baseline`** Horizontal baseline-grid overlay
|
|
218
|
-
- **`Guide`** Column-grid overlay (line / pattern / fixed / auto variants)
|
|
219
|
-
|
|
220
|
-
#### 3. Configuration
|
|
221
|
-
|
|
222
|
-
- **`Config`** Theme and settings provider (base unit, colors, debug modes)
|
|
223
|
-
|
|
224
|
-
### Key Components
|
|
225
|
-
|
|
226
|
-
#### Config
|
|
227
|
-
|
|
228
|
-
```tsx
|
|
229
|
-
<Config
|
|
230
|
-
base={8} // Base unit for calculations
|
|
231
|
-
baseline={{ debugging }} // Baseline grid visibility
|
|
232
|
-
guide={{ debugging }} // Guide customization
|
|
233
|
-
>
|
|
234
|
-
{children}
|
|
235
|
-
</Config>
|
|
236
|
-
```
|
|
136
|
+
| Component | Purpose |
|
|
137
|
+
| ---------- | ------------------------------------------------------------- |
|
|
138
|
+
| `Config` | Supplies scoped base, variant, color, and debugging defaults. |
|
|
139
|
+
| `Baseline` | Renders horizontal baseline rows. |
|
|
140
|
+
| `Guide` | Renders a responsive or fixed column guide. |
|
|
141
|
+
| `Box` | Wraps content and optionally snaps its measured height. |
|
|
142
|
+
| `Padder` | Adds baseline-aware padding and optional measurement spacers. |
|
|
143
|
+
| `Spacer` | Adds a fixed-size spacer with an optional debug indicator. |
|
|
237
144
|
|
|
238
|
-
|
|
145
|
+
`Box` and `Padder` use `text-box-trim: trim-both` and
|
|
146
|
+
`text-box-edge: ex alphabetic` where the browser supports them, keeping text
|
|
147
|
+
edges aligned to the x-height and alphabetic baseline. Unsupported browsers
|
|
148
|
+
retain normal text layout. Trimming does not remove child margins or change a
|
|
149
|
+
nested heading's own line-box rules.
|
|
150
|
+
For nested text, set the same properties on its text container. See the
|
|
151
|
+
[CSS text-box-edge reference](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/text-box-edge)
|
|
152
|
+
for browser compatibility and alternative metrics such as `ex alphabetic`.
|
|
239
153
|
|
|
240
|
-
|
|
241
|
-
<Baseline
|
|
242
|
-
height="100vh" // Overlay height
|
|
243
|
-
variant="line" // "line" or "flat"
|
|
244
|
-
debugging="visible" // Show the grid overlay
|
|
245
|
-
/>
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
#### Guide
|
|
249
|
-
|
|
250
|
-
```tsx
|
|
251
|
-
<Guide
|
|
252
|
-
variant="pattern" // "line", "pattern", "fixed", or "auto"
|
|
253
|
-
columns={['100px', '1fr', '100px']} // Column definition
|
|
254
|
-
gap={8} // Gap value
|
|
255
|
-
width="1200px" // Container width
|
|
256
|
-
/>
|
|
257
|
-
```
|
|
154
|
+
## Styles and themes
|
|
258
155
|
|
|
259
|
-
|
|
156
|
+
Import styles explicitly so applications control their CSS footprint:
|
|
260
157
|
|
|
261
158
|
```tsx
|
|
262
|
-
|
|
263
|
-
block={[2, 5]} // Vertical padding in base units
|
|
264
|
-
span={2} // Grid column span when placed in a CSS grid parent
|
|
265
|
-
snapping="height" // "none", "height", or "clamp"
|
|
266
|
-
>
|
|
267
|
-
<p>Content aligned to baseline grid</p>
|
|
268
|
-
</Box>
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
## Theme System
|
|
272
|
-
|
|
273
|
-
Baseline Kit comes with a flexible CSS structure and theming system:
|
|
274
|
-
|
|
275
|
-
1. `guide.css` - Guide-only overlay styles (imported via `baseline-kit/styles/guide`)
|
|
276
|
-
2. `styles.css` - Root component styles and base variables (imported via `baseline-kit/styles`)
|
|
277
|
-
3. `theme.css` - Color variables and theming with automatic dark mode support (imported via `baseline-kit/theme`)
|
|
278
|
-
4. `reset.css` - Optional browser reset (imported via `baseline-kit/reset` or `baseline-kit/styles/reset`)
|
|
279
|
-
5. `baseline-kit.css` - Combined root component styles and theme (imported via `baseline-kit/styles/full`)
|
|
280
|
-
|
|
281
|
-
### CSS Import Options
|
|
282
|
-
|
|
283
|
-
Baseline Kit gives you flexibility in how you include the styles:
|
|
284
|
-
|
|
285
|
-
```tsx
|
|
286
|
-
// Guide-only overlay styles
|
|
287
|
-
import 'baseline-kit/styles/guide'
|
|
288
|
-
|
|
289
|
-
// Root component styles and theme separately
|
|
159
|
+
// React component styles and the default light/dark theme
|
|
290
160
|
import 'baseline-kit/styles'
|
|
291
161
|
import 'baseline-kit/theme'
|
|
292
162
|
|
|
293
|
-
//
|
|
163
|
+
// Or one combined file
|
|
294
164
|
import 'baseline-kit/styles/full'
|
|
295
165
|
|
|
166
|
+
// Guide-only styles
|
|
167
|
+
import 'baseline-kit/styles/guide'
|
|
168
|
+
|
|
296
169
|
// Optional reset
|
|
297
170
|
import 'baseline-kit/reset'
|
|
298
171
|
```
|
|
299
172
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
173
|
+
The built-in theme follows `prefers-color-scheme`. For a fixed theme, import
|
|
174
|
+
`baseline-kit/theme/default` or `baseline-kit/theme/dark`. For a custom theme,
|
|
175
|
+
copy the token template from `baseline-kit/theme/tokens` and define the CSS
|
|
176
|
+
variables your application needs.
|
|
303
177
|
|
|
304
|
-
|
|
178
|
+
Use `Config` for scoped overrides:
|
|
305
179
|
|
|
306
180
|
```tsx
|
|
307
|
-
|
|
181
|
+
<Config
|
|
182
|
+
base={8}
|
|
183
|
+
baseline={{
|
|
184
|
+
colors: {
|
|
185
|
+
line: 'rgba(255, 0, 0, 0.1)',
|
|
186
|
+
flat: 'rgba(255, 0, 0, 0.05)',
|
|
187
|
+
},
|
|
188
|
+
}}
|
|
189
|
+
>
|
|
190
|
+
{children}
|
|
191
|
+
</Config>
|
|
308
192
|
```
|
|
309
193
|
|
|
310
|
-
|
|
194
|
+
Theme variables are grouped by component:
|
|
311
195
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
196
|
+
| Component | Variable prefix |
|
|
197
|
+
| --------- | ----------------------- |
|
|
198
|
+
| Baseline | `--bk-baseline-color-*` |
|
|
199
|
+
| Guide | `--bk-guide-color-*` |
|
|
200
|
+
| Box | `--bk-box-color-*` |
|
|
201
|
+
| Spacer | `--bk-spacer-color-*` |
|
|
202
|
+
| Padder | `--bk-padder-color-*` |
|
|
315
203
|
|
|
316
|
-
|
|
317
|
-
|
|
204
|
+
See the [token template](https://github.com/dnvt/baseline-kit/blob/main/packages/react/src/components/styles/theme/tokens.css)
|
|
205
|
+
for the complete list.
|
|
318
206
|
|
|
319
|
-
|
|
320
|
-
import 'baseline-kit/styles'
|
|
321
|
-
import 'baseline-kit/theme/dark'
|
|
322
|
-
```
|
|
207
|
+
## Remix 3 UI runtime
|
|
323
208
|
|
|
324
|
-
|
|
209
|
+
For Node SSR, use **`baseline-kit/remix/server`**, not `remix/ui/server`.
|
|
210
|
+
The pinned Remix RC loses provider context while serializing component-valued
|
|
211
|
+
children. This server entry corrects that traversal in an isolated renderer,
|
|
212
|
+
preserving nested `Config` scopes even when app or library entries hydrate late.
|
|
213
|
+
It does not change files in `node_modules` or install process-wide module hooks.
|
|
325
214
|
|
|
326
|
-
|
|
215
|
+
This is a Node-only compatibility entry, not an edge/browser renderer. It loads
|
|
216
|
+
the installed `@remix-run/ui@0.9.0` server implementation and verifies its exact
|
|
217
|
+
SHA-256 before applying the correction in memory. Keep the installed Remix
|
|
218
|
+
runtime files available in production; do not use a standalone bundle that
|
|
219
|
+
omits them. Modified or upgraded implementations fail with an explicit error
|
|
220
|
+
until compatibility is revalidated. Import `ImportMap` from this same entry if
|
|
221
|
+
used; `Frame` and client components still come from `remix/ui`.
|
|
327
222
|
|
|
328
223
|
```tsx
|
|
329
|
-
|
|
330
|
-
import 'baseline-kit/theme/tokens' // Just for reference (contains no values)
|
|
331
|
-
```
|
|
224
|
+
import { renderToStream, ImportMap } from 'baseline-kit/remix/server'
|
|
332
225
|
|
|
333
|
-
|
|
226
|
+
// If app contains an ImportMap component, use the export above.
|
|
227
|
+
const stream = renderToStream(app, { resolveClientEntry })
|
|
228
|
+
return new Response(stream, { headers: { 'Content-Type': 'text/html' } })
|
|
229
|
+
```
|
|
334
230
|
|
|
335
|
-
|
|
336
|
-
/* yourCustomTheme.css */
|
|
337
|
-
:root {
|
|
338
|
-
/* Component-specific colors */
|
|
339
|
-
--bk-baseline-color-line-theme: hsla(210, 100%, 50%, 0.15);
|
|
340
|
-
--bk-baseline-color-flat-theme: hsla(270, 100%, 60%, 0.2);
|
|
341
|
-
/* Add other component colors as needed */
|
|
342
|
-
}
|
|
231
|
+
The React-free adapter uses `remix/ui` and does not import React or React DOM:
|
|
343
232
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
:root {
|
|
347
|
-
--bk-baseline-color-line-theme: hsla(210, 100%, 50%, 0.2);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
233
|
+
```shell
|
|
234
|
+
npm install baseline-kit remix@3.0.0-rc.2
|
|
350
235
|
```
|
|
351
236
|
|
|
352
|
-
Then import your custom theme:
|
|
353
|
-
|
|
354
237
|
```tsx
|
|
355
|
-
import 'baseline-kit/styles'
|
|
356
|
-
import
|
|
238
|
+
import 'baseline-kit/styles/remix'
|
|
239
|
+
import { Baseline, Box, Config, Guide, Spacer } from 'baseline-kit/remix'
|
|
240
|
+
import { jsx } from 'remix/ui/jsx-runtime'
|
|
241
|
+
|
|
242
|
+
export function App() {
|
|
243
|
+
return jsx(Config, {
|
|
244
|
+
base: 8,
|
|
245
|
+
baseline: { debugging: 'visible' },
|
|
246
|
+
children: [
|
|
247
|
+
jsx(Baseline, { height: '100vh' }),
|
|
248
|
+
jsx(Guide, { variant: 'fixed', columns: 12 }),
|
|
249
|
+
jsx(Box, { children: 'Native Remix content' }),
|
|
250
|
+
jsx(Spacer, { height: 16, variant: 'flat' }),
|
|
251
|
+
],
|
|
252
|
+
})
|
|
253
|
+
}
|
|
357
254
|
```
|
|
358
255
|
|
|
359
|
-
|
|
256
|
+
The `resolveClientEntry` callback needs an app-owned mapping from each entry to a **browser-served
|
|
257
|
+
JavaScript asset**. A server filesystem URL or bare npm specifier is not a
|
|
258
|
+
browser asset. The mapping must handle the app's own client entries as well.
|
|
259
|
+
See the runnable [server resolver](https://github.com/dnvt/baseline-kit/blob/main/tests/browser/remix-ssr.ts)
|
|
260
|
+
and [asset-serving fixture](https://github.com/dnvt/baseline-kit/blob/main/tests/browser/vite.config.ts).
|
|
360
261
|
|
|
361
|
-
|
|
262
|
+
Once the server supplies public URLs, load the actual module and named export:
|
|
362
263
|
|
|
363
264
|
```tsx
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
</Config>
|
|
265
|
+
import { run } from 'remix/ui'
|
|
266
|
+
run({
|
|
267
|
+
loadModule: async (moduleUrl, exportName) => {
|
|
268
|
+
const module = await import(
|
|
269
|
+
/* @vite-ignore */ new URL(moduleUrl, document.baseURI).href
|
|
270
|
+
)
|
|
271
|
+
return module[exportName]
|
|
272
|
+
},
|
|
273
|
+
})
|
|
374
274
|
```
|
|
375
275
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
| Guide | `--bk-guide-color-[line/pattern/auto/fixed]-theme` | Colors for different guide variants |
|
|
382
|
-
| Box | `--bk-box-color-[line/flat/text]-theme` | Colors for borders, backgrounds and text |
|
|
383
|
-
| Spacer | `--bk-spacer-color-[line/flat/text]-theme` | Colors for borders, backgrounds and text |
|
|
384
|
-
| Padder | `--bk-padder-color-theme` | Padder edge color |
|
|
385
|
-
|
|
386
|
-
See the [tokens file](https://github.com/dnvt/baseline-kit/blob/main/dist/theme/tokens.css) for a complete list of available variables.
|
|
387
|
-
|
|
388
|
-
## Browser Support
|
|
276
|
+
Callbacks such as `indicatorNode` must be created inside the hydrated module;
|
|
277
|
+
functions cannot cross an SSR client-entry boundary. Keep `Config` and its
|
|
278
|
+
consumers within an app-owned hydrated component for interactive config updates.
|
|
279
|
+
This adapter is separate from React-based Remix/React Router applications,
|
|
280
|
+
which use the regular React entry.
|
|
389
281
|
|
|
390
|
-
-
|
|
391
|
-
|
|
392
|
-
- Falls back gracefully in unsupported browsers
|
|
282
|
+
In a Vite-based React application with a `links()` function, import the CSS as a
|
|
283
|
+
URL; a bare package specifier in `href` will not resolve:
|
|
393
284
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
Baseline Kit leverages React 19's latest features:
|
|
397
|
-
- **`use` Hook**: Replaces `useContext` for better performance and cleaner code
|
|
398
|
-
- **Streamlined Context API**: Uses the simplified Context Provider syntax
|
|
399
|
-
- **JSX Transform**: Takes advantage of the mandatory JSX transform in React 19
|
|
400
|
-
|
|
401
|
-
These modern features allow for cleaner code and better performance, but require React 19.
|
|
402
|
-
|
|
403
|
-
## Server-Side Rendering (SSR)
|
|
404
|
-
|
|
405
|
-
Baseline Kit is fully compatible with React's Server-Side Rendering in frameworks like Next.js, Remix, and other React Router-based applications.
|
|
285
|
+
```tsx
|
|
286
|
+
import stylesheetUrl from 'baseline-kit/styles?url'
|
|
406
287
|
|
|
407
|
-
|
|
288
|
+
export const links = () => [{ rel: 'stylesheet', href: stylesheetUrl }]
|
|
289
|
+
```
|
|
408
290
|
|
|
409
|
-
|
|
410
|
-
- Provide consistent rendering between server and client
|
|
411
|
-
- Avoid hydration mismatches by using deterministic initial values
|
|
412
|
-
- Progressively enhance with client-side measurements after hydration
|
|
413
|
-
- Work with frameworks that use streaming SSR
|
|
291
|
+
See [Vite's explicit URL imports](https://vite.dev/guide/assets.html#explicit-url-imports).
|
|
414
292
|
|
|
415
|
-
|
|
293
|
+
## Server-side rendering
|
|
416
294
|
|
|
417
|
-
|
|
295
|
+
React Baseline/Guide begin with a hidden fallback, then measure and paint after
|
|
296
|
+
hydration. Native Remix uses client-entry SSR and hydration through the resolver
|
|
297
|
+
above. `ssrMode` on Baseline/Guide **keeps the hidden fallback permanently** while
|
|
298
|
+
true: it disables client measurement and rows/columns. Leave it false (the
|
|
299
|
+
default) for visible, interactive overlays:
|
|
418
300
|
|
|
419
301
|
```tsx
|
|
420
|
-
<Baseline
|
|
421
|
-
height="100vh"
|
|
422
|
-
ssrMode={true}
|
|
423
|
-
debugging="visible"
|
|
424
|
-
/>
|
|
302
|
+
<Baseline height="100vh" ssrMode debugging="visible" />
|
|
425
303
|
```
|
|
426
304
|
|
|
427
|
-
With `ssrMode` enabled, components use simplified rendering during SSR and initial hydration, then enhance with full features after client-side hydration completes.
|
|
428
|
-
For debug overlays such as `Guide` and `Baseline`, `ssrMode` keeps the simplified fallback markup to avoid client measurement and row/column rendering in SSR-sensitive paths.
|
|
429
|
-
|
|
430
305
|
## Development
|
|
431
306
|
|
|
432
307
|
```shell
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
bun
|
|
308
|
+
git clone https://github.com/dnvt/baseline-kit.git
|
|
309
|
+
cd baseline-kit
|
|
310
|
+
bun install --frozen-lockfile
|
|
311
|
+
|
|
312
|
+
bun run typecheck
|
|
313
|
+
bun run lint:check
|
|
314
|
+
bun run test:unit
|
|
315
|
+
bun run build
|
|
316
|
+
bun run test:integration:remix
|
|
317
|
+
```
|
|
441
318
|
|
|
442
|
-
|
|
443
|
-
bun run dev
|
|
319
|
+
Run the Chromium and WebKit browser regressions locally with:
|
|
444
320
|
|
|
445
|
-
|
|
446
|
-
bun run test
|
|
321
|
+
```shell
|
|
322
|
+
bun run test:browser -- --project=chromium --project=webkit
|
|
447
323
|
```
|
|
448
324
|
|
|
449
|
-
|
|
450
|
-
workflow surfaces such as `.claude/`, `maestro/`, `progress/`, and `plans/` are
|
|
451
|
-
ignored. Do not run the Maestro layout migration until the submodule source is
|
|
452
|
-
mounted at `.maestro/source` and the migration plan has been reviewed.
|
|
325
|
+
For the release-equivalent browser gate, use three zero-retry passes:
|
|
453
326
|
|
|
454
|
-
|
|
327
|
+
```shell
|
|
328
|
+
bun run test:browser:repeat
|
|
329
|
+
```
|
|
455
330
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
- Optimizes re-renders using React.memo and useMemo
|
|
460
|
-
- Supports tree-shaking for minimal bundle size
|
|
331
|
+
The release workflow runs that gate across Chromium, Firefox, and WebKit,
|
|
332
|
+
builds the package, verifies the packed Remix fixture three times, and
|
|
333
|
+
publishes through Changesets after all verification gates pass.
|
|
461
334
|
|
|
462
335
|
## Contributing
|
|
463
336
|
|
|
464
|
-
|
|
337
|
+
See [CONTRIBUTING.md](https://github.com/dnvt/baseline-kit/blob/main/CONTRIBUTING.md) for contribution and pull-request
|
|
338
|
+
guidelines.
|
|
465
339
|
|
|
466
340
|
## License
|
|
467
341
|
|