baseline-kit 3.0.1 → 5.0.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/README.md +99 -63
- package/dist/README.md +99 -63
- package/dist/baseline-kit.css +3 -21
- package/dist/core/src/config/defaults.d.ts +2 -0
- package/dist/core/src/config/index.d.ts +3 -0
- package/dist/core/src/config/merge.d.ts +21 -0
- package/dist/core/src/config/schema.d.ts +33 -0
- package/dist/core/src/descriptors/baseline.d.ts +26 -0
- package/dist/core/src/descriptors/box.d.ts +20 -0
- package/dist/core/src/descriptors/guide.d.ts +44 -0
- package/dist/core/src/descriptors/index.d.ts +5 -0
- package/dist/core/src/descriptors/padder.d.ts +19 -0
- package/dist/core/src/descriptors/spacer.d.ts +24 -0
- package/dist/core/src/index.d.ts +10 -0
- package/dist/core/src/types.d.ts +62 -0
- package/dist/core/src/utils/convert.d.ts +10 -0
- package/dist/core/src/utils/grid.d.ts +18 -0
- package/dist/{utils → core/src/utils}/index.d.ts +2 -9
- package/dist/core/src/utils/math.d.ts +9 -0
- package/dist/core/src/utils/merge.d.ts +28 -0
- package/dist/core/src/utils/normalize.d.ts +13 -0
- package/dist/core/src/utils/padding.d.ts +2 -0
- package/dist/core/src/utils/parse.d.ts +5 -0
- package/dist/core/src/utils/snapping.d.ts +2 -0
- package/dist/core/src/validation/guide.d.ts +3 -0
- package/dist/core/src/validation/index.d.ts +1 -0
- package/dist/core.cjs +1 -0
- package/dist/core.d.ts +344 -0
- package/dist/core.mjs +2 -0
- package/dist/dom/src/index.d.ts +11 -0
- package/dist/dom/src/measure.d.ts +18 -0
- package/dist/dom/src/observers.d.ts +5 -0
- package/dist/{utils → dom/src}/ssr.d.ts +0 -6
- package/dist/dom/src/timing.d.ts +2 -0
- package/dist/dom/src/viewport.d.ts +7 -0
- package/dist/dom/src/virtual.d.ts +23 -0
- package/dist/guide.cjs +2 -0
- package/dist/guide.cjs.map +1 -0
- package/dist/guide.css +2 -0
- package/dist/guide.d.ts +146 -0
- package/dist/guide.mjs +589 -0
- package/dist/guide.mjs.map +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +197 -30
- package/dist/index.mjs +614 -1747
- package/dist/index.mjs.map +1 -1
- package/dist/react/src/components/Baseline/Baseline.d.ts +13 -0
- package/dist/react/src/components/Baseline/index.d.ts +1 -0
- package/dist/react/src/components/Box/Box.d.ts +26 -0
- package/dist/react/src/components/Box/index.d.ts +1 -0
- package/dist/react/src/components/Config/Config.d.ts +20 -0
- package/dist/react/src/components/Config/index.d.ts +2 -0
- package/dist/react/src/components/Guide/Guide.d.ts +16 -0
- package/dist/react/src/components/Guide/index.d.ts +1 -0
- package/dist/react/src/components/Padder/Padder.d.ts +20 -0
- package/dist/react/src/components/Padder/index.d.ts +1 -0
- package/dist/react/src/components/Spacer/Spacer.d.ts +14 -0
- package/dist/react/src/components/Spacer/index.d.ts +1 -0
- package/dist/{components → react/src/components}/index.d.ts +1 -5
- package/dist/react/src/components/types.d.ts +29 -0
- package/dist/react/src/guide.d.ts +10 -0
- package/dist/{hooks → react/src/hooks}/index.d.ts +2 -3
- package/dist/react/src/hooks/useBaseline.d.ts +26 -0
- package/dist/react/src/hooks/useConfig.d.ts +9 -0
- package/dist/react/src/hooks/useDebug.d.ts +6 -0
- package/dist/react/src/hooks/useGuide.d.ts +7 -0
- package/dist/{hooks → react/src/hooks}/useIsClient.d.ts +0 -2
- package/dist/react/src/hooks/useMeasure.d.ts +10 -0
- package/dist/react/src/hooks/useVirtual.d.ts +14 -0
- package/dist/react/src/index.d.ts +21 -0
- package/dist/react/src/utils/index.d.ts +9 -0
- package/dist/react/src/utils/merge.d.ts +10 -0
- package/dist/react/src/utils/ssr.d.ts +1 -0
- package/dist/reset.css +43 -0
- package/dist/src-CMjyHjX5.cjs +2 -0
- package/dist/src-CMjyHjX5.cjs.map +1 -0
- package/dist/src-QHaSfgVe.js +619 -0
- package/dist/src-QHaSfgVe.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/theme/dark.css +0 -8
- package/dist/theme/default.css +0 -9
- package/dist/theme/tokens.css +1 -10
- package/dist/theme.css +0 -18
- package/package.json +82 -42
- package/dist/components/Baseline/Baseline.d.ts +0 -48
- package/dist/components/Baseline/index.d.ts +0 -6
- package/dist/components/Box/Box.d.ts +0 -73
- package/dist/components/Box/index.d.ts +0 -6
- package/dist/components/Config/Config.d.ts +0 -179
- package/dist/components/Config/defaults.d.ts +0 -25
- package/dist/components/Config/index.d.ts +0 -11
- package/dist/components/Guide/Guide.d.ts +0 -70
- package/dist/components/Guide/index.d.ts +0 -6
- package/dist/components/Guide/types.d.ts +0 -144
- package/dist/components/Guide/validation.d.ts +0 -82
- package/dist/components/Layout/Layout.d.ts +0 -73
- package/dist/components/Layout/index.d.ts +0 -10
- package/dist/components/Padder/Padder.d.ts +0 -67
- package/dist/components/Padder/index.d.ts +0 -10
- package/dist/components/Spacer/Spacer.d.ts +0 -48
- package/dist/components/Spacer/index.d.ts +0 -10
- package/dist/components/Stack/Stack.d.ts +0 -84
- package/dist/components/Stack/index.d.ts +0 -10
- package/dist/components/styles/index.d.ts +0 -11
- package/dist/components/types.d.ts +0 -102
- package/dist/hooks/useBaseline.d.ts +0 -55
- package/dist/hooks/useConfig.d.ts +0 -41
- package/dist/hooks/useDebug.d.ts +0 -49
- package/dist/hooks/useGuide.d.ts +0 -61
- package/dist/hooks/useMeasure.d.ts +0 -35
- package/dist/hooks/useVirtual.d.ts +0 -60
- package/dist/styles.d.ts +0 -6
- package/dist/theme.d.ts +0 -6
- package/dist/utils/convert.d.ts +0 -24
- package/dist/utils/grid.d.ts +0 -22
- package/dist/utils/math.d.ts +0 -48
- package/dist/utils/merge.d.ts +0 -117
- package/dist/utils/normalize.d.ts +0 -30
- package/dist/utils/padding.d.ts +0 -11
- package/dist/utils/parse.d.ts +0 -18
- package/dist/utils/snapping.d.ts +0 -28
- package/dist/utils/timing.d.ts +0 -45
package/README.md
CHANGED
|
@@ -4,34 +4,47 @@
|
|
|
4
4
|

|
|
5
5
|

|
|
6
6
|
|
|
7
|
-
Baseline Kit is a lightweight development tool for visualizing and debugging grid systems and spacing in React
|
|
7
|
+
Baseline Kit is a lightweight development tool for visualizing and debugging grid systems and spacing in React applications. It provides configurable overlays for both column-based and baseline grids, spacing primitives, and theme-aware configuration—all optimized for performance and built with TypeScript. The library is based on the "Padded Grid" concept, originally explored in [this article](http://medium.com/design-bootcamp/the-padded-grid-a-designers-hack-to-achieve-baseline-fit-fc40d022bc84) on achieving perfect baseline alignment in digital layouts.
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
|
|
11
11
|
## Table of Contents
|
|
12
|
-
- [
|
|
13
|
-
- [
|
|
14
|
-
- [
|
|
15
|
-
- [
|
|
16
|
-
- [
|
|
17
|
-
|
|
18
|
-
- [
|
|
19
|
-
- [
|
|
20
|
-
- [
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
12
|
+
- [Features](#features)
|
|
13
|
+
- [Requirements](#requirements)
|
|
14
|
+
- [Installation](#installation)
|
|
15
|
+
- [Quick Start](#quick-start)
|
|
16
|
+
- [Core Concepts](#core-concepts)
|
|
17
|
+
- [Base Unit](#base-unit)
|
|
18
|
+
- [Spacing Values](#spacing-values)
|
|
19
|
+
- [Grid Snapping](#grid-snapping)
|
|
20
|
+
- [Debugging Modes](#debugging-modes)
|
|
21
|
+
- [Components](#components)
|
|
22
|
+
- [Component Hierarchy](#component-hierarchy)
|
|
23
|
+
- [Key Components](#key-components)
|
|
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)
|
|
27
41
|
|
|
28
42
|
## Features
|
|
29
43
|
|
|
30
44
|
- 📏 **Baseline Grid:** Core system for maintaining vertical rhythm and consistent spacing across your layouts
|
|
31
45
|
- 🎯 **Column Grid Guide:** Customizable overlay system for visualizing column-based layouts and alignment
|
|
32
46
|
- 📦 **Box Component:** Basic container with configurable spacing that snaps to the baseline grid
|
|
33
|
-
-
|
|
34
|
-
- 📐 **Stack Component:** Flex-based container that maintains consistent spacing and baseline alignment
|
|
47
|
+
- 🧱 **Padder & Spacer:** Spacing primitives with optional baseline snapping
|
|
35
48
|
- 🎨 **Theme System:** Customizable colors and debug visuals through a centralized configuration
|
|
36
49
|
|
|
37
50
|
## Requirements
|
|
@@ -52,35 +65,44 @@ yarn add baseline-kit
|
|
|
52
65
|
pnpm add baseline-kit
|
|
53
66
|
```
|
|
54
67
|
|
|
55
|
-
After installation, import
|
|
68
|
+
After installation, import the smallest entry point that matches your use case.
|
|
69
|
+
For a development grid overlay, use the guide-only React and CSS subpaths:
|
|
56
70
|
|
|
57
71
|
```tsx
|
|
58
|
-
|
|
59
|
-
import 'baseline-kit/
|
|
60
|
-
import 'baseline-kit/theme'; // Recommended theme (or use your own)
|
|
72
|
+
import 'baseline-kit/styles/guide'
|
|
73
|
+
import { Config, Guide } from 'baseline-kit/guide'
|
|
61
74
|
```
|
|
62
75
|
|
|
63
76
|
For frameworks like Remix that use URL imports in a links function:
|
|
64
77
|
|
|
65
78
|
```tsx
|
|
66
79
|
export const links = () => [
|
|
67
|
-
{ rel:
|
|
68
|
-
|
|
69
|
-
];
|
|
80
|
+
{ rel: 'stylesheet', href: 'baseline-kit/styles/guide' },
|
|
81
|
+
]
|
|
70
82
|
```
|
|
71
83
|
|
|
72
|
-
|
|
84
|
+
For the full component set, import the root package and root component styles:
|
|
73
85
|
|
|
74
86
|
```tsx
|
|
75
|
-
|
|
76
|
-
import 'baseline-kit/
|
|
87
|
+
import 'baseline-kit/styles'
|
|
88
|
+
import 'baseline-kit/theme'
|
|
89
|
+
import { Config, Guide, Baseline, Box } from 'baseline-kit'
|
|
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'
|
|
77
96
|
|
|
78
97
|
// For Remix:
|
|
79
98
|
export const links = () => [
|
|
80
|
-
{ rel:
|
|
81
|
-
]
|
|
99
|
+
{ rel: 'stylesheet', href: 'baseline-kit/styles/full' },
|
|
100
|
+
]
|
|
82
101
|
```
|
|
83
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
|
+
|
|
84
106
|
Baseline Kit is written in TypeScript and includes built-in type definitions—no additional packages required.
|
|
85
107
|
|
|
86
108
|
## Quick Start
|
|
@@ -139,12 +161,12 @@ unit:
|
|
|
139
161
|
|
|
140
162
|
```tsx
|
|
141
163
|
<Config base={8}> // Sets 8px as the base unit
|
|
142
|
-
<
|
|
164
|
+
<Padder
|
|
143
165
|
block={17} // Will be rounded to 16px (2 * base)
|
|
144
166
|
inline={22} // Will be rounded to 24px (3 * base)
|
|
145
167
|
>
|
|
146
168
|
{/* Content automatically aligned to the 8px grid */}
|
|
147
|
-
</
|
|
169
|
+
</Padder>
|
|
148
170
|
</Config>
|
|
149
171
|
```
|
|
150
172
|
|
|
@@ -168,8 +190,7 @@ block={{ start: 2, end: 3 }} // Same as above
|
|
|
168
190
|
Components automatically adjust their spacing to maintain baseline grid alignment:
|
|
169
191
|
|
|
170
192
|
- **Box**: Adjusts bottom padding to ensure total height aligns with base unit
|
|
171
|
-
- **
|
|
172
|
-
- **Layout**: Ensures grid cells align with baseline
|
|
193
|
+
- **Padder**: Snaps padded content to baseline-aligned multiples of the base unit
|
|
173
194
|
|
|
174
195
|
### Debugging Modes
|
|
175
196
|
|
|
@@ -185,21 +206,20 @@ debugging = "none" // Removes debug elements entirely
|
|
|
185
206
|
|
|
186
207
|
### Component Hierarchy
|
|
187
208
|
|
|
188
|
-
#### 1.
|
|
209
|
+
#### 1. Spacing primitives
|
|
189
210
|
|
|
190
|
-
- **`Box`** Basic container
|
|
191
|
-
- **`
|
|
192
|
-
- **`
|
|
211
|
+
- **`Box`** Basic container that snaps its height to the baseline grid
|
|
212
|
+
- **`Padder`** Padding wrapper that snaps padded content to baseline multiples
|
|
213
|
+
- **`Spacer`** Fixed-size spacer with optional measurement indicator overlay
|
|
193
214
|
|
|
194
|
-
#### 2.
|
|
215
|
+
#### 2. Debug overlays
|
|
195
216
|
|
|
196
|
-
- **`Baseline`** Horizontal grid overlay
|
|
197
|
-
- **`Guide`**
|
|
198
|
-
- **`Spacer`** Precise spacing measurement
|
|
217
|
+
- **`Baseline`** Horizontal baseline-grid overlay
|
|
218
|
+
- **`Guide`** Column-grid overlay (line / pattern / fixed / auto variants)
|
|
199
219
|
|
|
200
220
|
#### 3. Configuration
|
|
201
221
|
|
|
202
|
-
- **`Config`** Theme and settings provider
|
|
222
|
+
- **`Config`** Theme and settings provider (base unit, colors, debug modes)
|
|
203
223
|
|
|
204
224
|
### Key Components
|
|
205
225
|
|
|
@@ -241,7 +261,7 @@ debugging = "none" // Removes debug elements entirely
|
|
|
241
261
|
```tsx
|
|
242
262
|
<Box
|
|
243
263
|
block={[2, 5]} // Vertical padding in base units
|
|
244
|
-
span={2} // Grid column span when
|
|
264
|
+
span={2} // Grid column span when placed in a CSS grid parent
|
|
245
265
|
snapping="height" // "none", "height", or "clamp"
|
|
246
266
|
>
|
|
247
267
|
<p>Content aligned to baseline grid</p>
|
|
@@ -252,21 +272,29 @@ debugging = "none" // Removes debug elements entirely
|
|
|
252
272
|
|
|
253
273
|
Baseline Kit comes with a flexible CSS structure and theming system:
|
|
254
274
|
|
|
255
|
-
1. `
|
|
256
|
-
2. `
|
|
257
|
-
3. `
|
|
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`)
|
|
258
280
|
|
|
259
281
|
### CSS Import Options
|
|
260
282
|
|
|
261
283
|
Baseline Kit gives you flexibility in how you include the styles:
|
|
262
284
|
|
|
263
285
|
```tsx
|
|
264
|
-
//
|
|
265
|
-
import 'baseline-kit/styles'
|
|
266
|
-
|
|
286
|
+
// Guide-only overlay styles
|
|
287
|
+
import 'baseline-kit/styles/guide'
|
|
288
|
+
|
|
289
|
+
// Root component styles and theme separately
|
|
290
|
+
import 'baseline-kit/styles'
|
|
291
|
+
import 'baseline-kit/theme'
|
|
292
|
+
|
|
293
|
+
// Root component styles and theme in one file
|
|
294
|
+
import 'baseline-kit/styles/full'
|
|
267
295
|
|
|
268
|
-
//
|
|
269
|
-
import 'baseline-kit/
|
|
296
|
+
// Optional reset
|
|
297
|
+
import 'baseline-kit/reset'
|
|
270
298
|
```
|
|
271
299
|
|
|
272
300
|
### Theme Options
|
|
@@ -276,21 +304,21 @@ You now have four options for using the theme system:
|
|
|
276
304
|
#### 1. Use the Built-in Theme (with automatic dark mode)
|
|
277
305
|
|
|
278
306
|
```tsx
|
|
279
|
-
import 'baseline-kit/theme'
|
|
307
|
+
import 'baseline-kit/theme' // Default theme with light/dark mode support
|
|
280
308
|
```
|
|
281
309
|
|
|
282
310
|
#### 2. Use Specific Theme Variants
|
|
283
311
|
|
|
284
312
|
```tsx
|
|
285
313
|
// Use only the light theme (no dark mode)
|
|
286
|
-
import 'baseline-kit/theme/default'
|
|
314
|
+
import 'baseline-kit/theme/default'
|
|
287
315
|
|
|
288
316
|
// Use only the dark theme
|
|
289
|
-
import 'baseline-kit/theme/dark'
|
|
317
|
+
import 'baseline-kit/theme/dark'
|
|
290
318
|
|
|
291
319
|
// Example: Apply dark theme regardless of system preference
|
|
292
|
-
import 'baseline-kit/styles'
|
|
293
|
-
import 'baseline-kit/theme/dark'
|
|
320
|
+
import 'baseline-kit/styles'
|
|
321
|
+
import 'baseline-kit/theme/dark'
|
|
294
322
|
```
|
|
295
323
|
|
|
296
324
|
#### 3. Create a Custom Theme
|
|
@@ -299,7 +327,7 @@ You can use the tokens template as a starting point:
|
|
|
299
327
|
|
|
300
328
|
```tsx
|
|
301
329
|
// First check the token template to see available variables
|
|
302
|
-
import 'baseline-kit/theme/tokens'
|
|
330
|
+
import 'baseline-kit/theme/tokens' // Just for reference (contains no values)
|
|
303
331
|
```
|
|
304
332
|
|
|
305
333
|
Then create your own custom theme file:
|
|
@@ -324,8 +352,8 @@ Then create your own custom theme file:
|
|
|
324
352
|
Then import your custom theme:
|
|
325
353
|
|
|
326
354
|
```tsx
|
|
327
|
-
import 'baseline-kit/styles'
|
|
328
|
-
import './path/to/yourCustomTheme.css'
|
|
355
|
+
import 'baseline-kit/styles' // Required component styles
|
|
356
|
+
import './path/to/yourCustomTheme.css' // Your custom theme
|
|
329
357
|
```
|
|
330
358
|
|
|
331
359
|
#### 4. Override via Config
|
|
@@ -352,9 +380,8 @@ For minor adjustments, use the Config component:
|
|
|
352
380
|
| Baseline | `--bk-baseline-color-[line/flat]-theme` | Colors for lines and backgrounds |
|
|
353
381
|
| Guide | `--bk-guide-color-[line/pattern/auto/fixed]-theme` | Colors for different guide variants |
|
|
354
382
|
| Box | `--bk-box-color-[line/flat/text]-theme` | Colors for borders, backgrounds and text |
|
|
355
|
-
| Stack | `--bk-stack-color-[line/flat/text]-theme` | Colors for borders, backgrounds and text |
|
|
356
|
-
| Layout | `--bk-layout-color-[line/flat/text]-theme` | Colors for borders, backgrounds and text |
|
|
357
383
|
| Spacer | `--bk-spacer-color-[line/flat/text]-theme` | Colors for borders, backgrounds and text |
|
|
384
|
+
| Padder | `--bk-padder-color-theme` | Padder edge color |
|
|
358
385
|
|
|
359
386
|
See the [tokens file](https://github.com/dnvt/baseline-kit/blob/main/dist/theme/tokens.css) for a complete list of available variables.
|
|
360
387
|
|
|
@@ -398,12 +425,16 @@ Components accept an `ssrMode` prop to explicitly optimize for server rendering:
|
|
|
398
425
|
```
|
|
399
426
|
|
|
400
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.
|
|
401
429
|
|
|
402
430
|
## Development
|
|
403
431
|
|
|
404
432
|
```shell
|
|
405
433
|
# Clone the repository
|
|
406
|
-
git clone https://github.com/dnvt/baseline-kit.git
|
|
434
|
+
git clone --recurse-submodules https://github.com/dnvt/baseline-kit.git
|
|
435
|
+
|
|
436
|
+
# If you already cloned without submodules
|
|
437
|
+
git submodule update --init --recursive
|
|
407
438
|
|
|
408
439
|
# Install dependencies
|
|
409
440
|
bun install
|
|
@@ -415,6 +446,11 @@ bun run dev
|
|
|
415
446
|
bun run test
|
|
416
447
|
```
|
|
417
448
|
|
|
449
|
+
The `.maestro/source` directory is a workflow submodule. Generated local
|
|
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.
|
|
453
|
+
|
|
418
454
|
## Performance Features
|
|
419
455
|
|
|
420
456
|
- Virtualizes large grid overlays
|
package/dist/README.md
CHANGED
|
@@ -4,34 +4,47 @@
|
|
|
4
4
|

|
|
5
5
|

|
|
6
6
|
|
|
7
|
-
Baseline Kit is a lightweight development tool for visualizing and debugging grid systems and spacing in React
|
|
7
|
+
Baseline Kit is a lightweight development tool for visualizing and debugging grid systems and spacing in React applications. It provides configurable overlays for both column-based and baseline grids, spacing primitives, and theme-aware configuration—all optimized for performance and built with TypeScript. The library is based on the "Padded Grid" concept, originally explored in [this article](http://medium.com/design-bootcamp/the-padded-grid-a-designers-hack-to-achieve-baseline-fit-fc40d022bc84) on achieving perfect baseline alignment in digital layouts.
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
|
|
11
11
|
## Table of Contents
|
|
12
|
-
- [
|
|
13
|
-
- [
|
|
14
|
-
- [
|
|
15
|
-
- [
|
|
16
|
-
- [
|
|
17
|
-
|
|
18
|
-
- [
|
|
19
|
-
- [
|
|
20
|
-
- [
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
12
|
+
- [Features](#features)
|
|
13
|
+
- [Requirements](#requirements)
|
|
14
|
+
- [Installation](#installation)
|
|
15
|
+
- [Quick Start](#quick-start)
|
|
16
|
+
- [Core Concepts](#core-concepts)
|
|
17
|
+
- [Base Unit](#base-unit)
|
|
18
|
+
- [Spacing Values](#spacing-values)
|
|
19
|
+
- [Grid Snapping](#grid-snapping)
|
|
20
|
+
- [Debugging Modes](#debugging-modes)
|
|
21
|
+
- [Components](#components)
|
|
22
|
+
- [Component Hierarchy](#component-hierarchy)
|
|
23
|
+
- [Key Components](#key-components)
|
|
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)
|
|
27
41
|
|
|
28
42
|
## Features
|
|
29
43
|
|
|
30
44
|
- 📏 **Baseline Grid:** Core system for maintaining vertical rhythm and consistent spacing across your layouts
|
|
31
45
|
- 🎯 **Column Grid Guide:** Customizable overlay system for visualizing column-based layouts and alignment
|
|
32
46
|
- 📦 **Box Component:** Basic container with configurable spacing that snaps to the baseline grid
|
|
33
|
-
-
|
|
34
|
-
- 📐 **Stack Component:** Flex-based container that maintains consistent spacing and baseline alignment
|
|
47
|
+
- 🧱 **Padder & Spacer:** Spacing primitives with optional baseline snapping
|
|
35
48
|
- 🎨 **Theme System:** Customizable colors and debug visuals through a centralized configuration
|
|
36
49
|
|
|
37
50
|
## Requirements
|
|
@@ -52,35 +65,44 @@ yarn add baseline-kit
|
|
|
52
65
|
pnpm add baseline-kit
|
|
53
66
|
```
|
|
54
67
|
|
|
55
|
-
After installation, import
|
|
68
|
+
After installation, import the smallest entry point that matches your use case.
|
|
69
|
+
For a development grid overlay, use the guide-only React and CSS subpaths:
|
|
56
70
|
|
|
57
71
|
```tsx
|
|
58
|
-
|
|
59
|
-
import 'baseline-kit/
|
|
60
|
-
import 'baseline-kit/theme'; // Recommended theme (or use your own)
|
|
72
|
+
import 'baseline-kit/styles/guide'
|
|
73
|
+
import { Config, Guide } from 'baseline-kit/guide'
|
|
61
74
|
```
|
|
62
75
|
|
|
63
76
|
For frameworks like Remix that use URL imports in a links function:
|
|
64
77
|
|
|
65
78
|
```tsx
|
|
66
79
|
export const links = () => [
|
|
67
|
-
{ rel:
|
|
68
|
-
|
|
69
|
-
];
|
|
80
|
+
{ rel: 'stylesheet', href: 'baseline-kit/styles/guide' },
|
|
81
|
+
]
|
|
70
82
|
```
|
|
71
83
|
|
|
72
|
-
|
|
84
|
+
For the full component set, import the root package and root component styles:
|
|
73
85
|
|
|
74
86
|
```tsx
|
|
75
|
-
|
|
76
|
-
import 'baseline-kit/
|
|
87
|
+
import 'baseline-kit/styles'
|
|
88
|
+
import 'baseline-kit/theme'
|
|
89
|
+
import { Config, Guide, Baseline, Box } from 'baseline-kit'
|
|
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'
|
|
77
96
|
|
|
78
97
|
// For Remix:
|
|
79
98
|
export const links = () => [
|
|
80
|
-
{ rel:
|
|
81
|
-
]
|
|
99
|
+
{ rel: 'stylesheet', href: 'baseline-kit/styles/full' },
|
|
100
|
+
]
|
|
82
101
|
```
|
|
83
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
|
+
|
|
84
106
|
Baseline Kit is written in TypeScript and includes built-in type definitions—no additional packages required.
|
|
85
107
|
|
|
86
108
|
## Quick Start
|
|
@@ -139,12 +161,12 @@ unit:
|
|
|
139
161
|
|
|
140
162
|
```tsx
|
|
141
163
|
<Config base={8}> // Sets 8px as the base unit
|
|
142
|
-
<
|
|
164
|
+
<Padder
|
|
143
165
|
block={17} // Will be rounded to 16px (2 * base)
|
|
144
166
|
inline={22} // Will be rounded to 24px (3 * base)
|
|
145
167
|
>
|
|
146
168
|
{/* Content automatically aligned to the 8px grid */}
|
|
147
|
-
</
|
|
169
|
+
</Padder>
|
|
148
170
|
</Config>
|
|
149
171
|
```
|
|
150
172
|
|
|
@@ -168,8 +190,7 @@ block={{ start: 2, end: 3 }} // Same as above
|
|
|
168
190
|
Components automatically adjust their spacing to maintain baseline grid alignment:
|
|
169
191
|
|
|
170
192
|
- **Box**: Adjusts bottom padding to ensure total height aligns with base unit
|
|
171
|
-
- **
|
|
172
|
-
- **Layout**: Ensures grid cells align with baseline
|
|
193
|
+
- **Padder**: Snaps padded content to baseline-aligned multiples of the base unit
|
|
173
194
|
|
|
174
195
|
### Debugging Modes
|
|
175
196
|
|
|
@@ -185,21 +206,20 @@ debugging = "none" // Removes debug elements entirely
|
|
|
185
206
|
|
|
186
207
|
### Component Hierarchy
|
|
187
208
|
|
|
188
|
-
#### 1.
|
|
209
|
+
#### 1. Spacing primitives
|
|
189
210
|
|
|
190
|
-
- **`Box`** Basic container
|
|
191
|
-
- **`
|
|
192
|
-
- **`
|
|
211
|
+
- **`Box`** Basic container that snaps its height to the baseline grid
|
|
212
|
+
- **`Padder`** Padding wrapper that snaps padded content to baseline multiples
|
|
213
|
+
- **`Spacer`** Fixed-size spacer with optional measurement indicator overlay
|
|
193
214
|
|
|
194
|
-
#### 2.
|
|
215
|
+
#### 2. Debug overlays
|
|
195
216
|
|
|
196
|
-
- **`Baseline`** Horizontal grid overlay
|
|
197
|
-
- **`Guide`**
|
|
198
|
-
- **`Spacer`** Precise spacing measurement
|
|
217
|
+
- **`Baseline`** Horizontal baseline-grid overlay
|
|
218
|
+
- **`Guide`** Column-grid overlay (line / pattern / fixed / auto variants)
|
|
199
219
|
|
|
200
220
|
#### 3. Configuration
|
|
201
221
|
|
|
202
|
-
- **`Config`** Theme and settings provider
|
|
222
|
+
- **`Config`** Theme and settings provider (base unit, colors, debug modes)
|
|
203
223
|
|
|
204
224
|
### Key Components
|
|
205
225
|
|
|
@@ -241,7 +261,7 @@ debugging = "none" // Removes debug elements entirely
|
|
|
241
261
|
```tsx
|
|
242
262
|
<Box
|
|
243
263
|
block={[2, 5]} // Vertical padding in base units
|
|
244
|
-
span={2} // Grid column span when
|
|
264
|
+
span={2} // Grid column span when placed in a CSS grid parent
|
|
245
265
|
snapping="height" // "none", "height", or "clamp"
|
|
246
266
|
>
|
|
247
267
|
<p>Content aligned to baseline grid</p>
|
|
@@ -252,21 +272,29 @@ debugging = "none" // Removes debug elements entirely
|
|
|
252
272
|
|
|
253
273
|
Baseline Kit comes with a flexible CSS structure and theming system:
|
|
254
274
|
|
|
255
|
-
1. `
|
|
256
|
-
2. `
|
|
257
|
-
3. `
|
|
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`)
|
|
258
280
|
|
|
259
281
|
### CSS Import Options
|
|
260
282
|
|
|
261
283
|
Baseline Kit gives you flexibility in how you include the styles:
|
|
262
284
|
|
|
263
285
|
```tsx
|
|
264
|
-
//
|
|
265
|
-
import 'baseline-kit/styles'
|
|
266
|
-
|
|
286
|
+
// Guide-only overlay styles
|
|
287
|
+
import 'baseline-kit/styles/guide'
|
|
288
|
+
|
|
289
|
+
// Root component styles and theme separately
|
|
290
|
+
import 'baseline-kit/styles'
|
|
291
|
+
import 'baseline-kit/theme'
|
|
292
|
+
|
|
293
|
+
// Root component styles and theme in one file
|
|
294
|
+
import 'baseline-kit/styles/full'
|
|
267
295
|
|
|
268
|
-
//
|
|
269
|
-
import 'baseline-kit/
|
|
296
|
+
// Optional reset
|
|
297
|
+
import 'baseline-kit/reset'
|
|
270
298
|
```
|
|
271
299
|
|
|
272
300
|
### Theme Options
|
|
@@ -276,21 +304,21 @@ You now have four options for using the theme system:
|
|
|
276
304
|
#### 1. Use the Built-in Theme (with automatic dark mode)
|
|
277
305
|
|
|
278
306
|
```tsx
|
|
279
|
-
import 'baseline-kit/theme'
|
|
307
|
+
import 'baseline-kit/theme' // Default theme with light/dark mode support
|
|
280
308
|
```
|
|
281
309
|
|
|
282
310
|
#### 2. Use Specific Theme Variants
|
|
283
311
|
|
|
284
312
|
```tsx
|
|
285
313
|
// Use only the light theme (no dark mode)
|
|
286
|
-
import 'baseline-kit/theme/default'
|
|
314
|
+
import 'baseline-kit/theme/default'
|
|
287
315
|
|
|
288
316
|
// Use only the dark theme
|
|
289
|
-
import 'baseline-kit/theme/dark'
|
|
317
|
+
import 'baseline-kit/theme/dark'
|
|
290
318
|
|
|
291
319
|
// Example: Apply dark theme regardless of system preference
|
|
292
|
-
import 'baseline-kit/styles'
|
|
293
|
-
import 'baseline-kit/theme/dark'
|
|
320
|
+
import 'baseline-kit/styles'
|
|
321
|
+
import 'baseline-kit/theme/dark'
|
|
294
322
|
```
|
|
295
323
|
|
|
296
324
|
#### 3. Create a Custom Theme
|
|
@@ -299,7 +327,7 @@ You can use the tokens template as a starting point:
|
|
|
299
327
|
|
|
300
328
|
```tsx
|
|
301
329
|
// First check the token template to see available variables
|
|
302
|
-
import 'baseline-kit/theme/tokens'
|
|
330
|
+
import 'baseline-kit/theme/tokens' // Just for reference (contains no values)
|
|
303
331
|
```
|
|
304
332
|
|
|
305
333
|
Then create your own custom theme file:
|
|
@@ -324,8 +352,8 @@ Then create your own custom theme file:
|
|
|
324
352
|
Then import your custom theme:
|
|
325
353
|
|
|
326
354
|
```tsx
|
|
327
|
-
import 'baseline-kit/styles'
|
|
328
|
-
import './path/to/yourCustomTheme.css'
|
|
355
|
+
import 'baseline-kit/styles' // Required component styles
|
|
356
|
+
import './path/to/yourCustomTheme.css' // Your custom theme
|
|
329
357
|
```
|
|
330
358
|
|
|
331
359
|
#### 4. Override via Config
|
|
@@ -352,9 +380,8 @@ For minor adjustments, use the Config component:
|
|
|
352
380
|
| Baseline | `--bk-baseline-color-[line/flat]-theme` | Colors for lines and backgrounds |
|
|
353
381
|
| Guide | `--bk-guide-color-[line/pattern/auto/fixed]-theme` | Colors for different guide variants |
|
|
354
382
|
| Box | `--bk-box-color-[line/flat/text]-theme` | Colors for borders, backgrounds and text |
|
|
355
|
-
| Stack | `--bk-stack-color-[line/flat/text]-theme` | Colors for borders, backgrounds and text |
|
|
356
|
-
| Layout | `--bk-layout-color-[line/flat/text]-theme` | Colors for borders, backgrounds and text |
|
|
357
383
|
| Spacer | `--bk-spacer-color-[line/flat/text]-theme` | Colors for borders, backgrounds and text |
|
|
384
|
+
| Padder | `--bk-padder-color-theme` | Padder edge color |
|
|
358
385
|
|
|
359
386
|
See the [tokens file](https://github.com/dnvt/baseline-kit/blob/main/dist/theme/tokens.css) for a complete list of available variables.
|
|
360
387
|
|
|
@@ -398,12 +425,16 @@ Components accept an `ssrMode` prop to explicitly optimize for server rendering:
|
|
|
398
425
|
```
|
|
399
426
|
|
|
400
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.
|
|
401
429
|
|
|
402
430
|
## Development
|
|
403
431
|
|
|
404
432
|
```shell
|
|
405
433
|
# Clone the repository
|
|
406
|
-
git clone https://github.com/dnvt/baseline-kit.git
|
|
434
|
+
git clone --recurse-submodules https://github.com/dnvt/baseline-kit.git
|
|
435
|
+
|
|
436
|
+
# If you already cloned without submodules
|
|
437
|
+
git submodule update --init --recursive
|
|
407
438
|
|
|
408
439
|
# Install dependencies
|
|
409
440
|
bun install
|
|
@@ -415,6 +446,11 @@ bun run dev
|
|
|
415
446
|
bun run test
|
|
416
447
|
```
|
|
417
448
|
|
|
449
|
+
The `.maestro/source` directory is a workflow submodule. Generated local
|
|
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.
|
|
453
|
+
|
|
418
454
|
## Performance Features
|
|
419
455
|
|
|
420
456
|
- Virtualizes large grid overlays
|