baseline-kit 3.0.2 → 5.1.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 +235 -0
- package/README.md +226 -334
- package/dist/baseline-kit.css +7 -22
- package/dist/core.cjs +1 -0
- package/dist/core.d.ts +354 -0
- package/dist/core.mjs +2 -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 +586 -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 +204 -30
- package/dist/index.mjs +620 -1747
- 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 +177 -0
- package/dist/remix.mjs +989 -0
- package/dist/remix.mjs.map +1 -0
- package/dist/reset.css +43 -0
- package/dist/src-C-1u5WNS.cjs +2 -0
- package/dist/src-C-1u5WNS.cjs.map +1 -0
- package/dist/src-C3TICsw6.js +547 -0
- package/dist/src-C3TICsw6.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/theme/dark.css +0 -8
- package/dist/theme/default.css +0 -10
- package/dist/theme/tokens.css +1 -11
- package/dist/theme.css +4 -19
- package/package.json +135 -46
- package/dist/README.md +0 -446
- 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/index.d.ts +0 -16
- package/dist/components/styles/index.d.ts +0 -11
- package/dist/components/types.d.ts +0 -102
- package/dist/hooks/index.d.ts +0 -11
- 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/useIsClient.d.ts +0 -6
- 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/index.d.ts +0 -15
- 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/ssr.d.ts +0 -26
- package/dist/utils/timing.d.ts +0 -45
package/dist/README.md
DELETED
|
@@ -1,446 +0,0 @@
|
|
|
1
|
-
# Baseline Kit
|
|
2
|
-
|
|
3
|
-

|
|
4
|
-

|
|
5
|
-

|
|
6
|
-
|
|
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, flexible layout components, 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
|
-
|
|
9
|
-

|
|
10
|
-
|
|
11
|
-
## Table of Contents
|
|
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)
|
|
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
|
-
- 🧩 **Layout Component:** CSS Grid-based container with automatic column calculations and baseline alignment
|
|
48
|
-
- 📐 **Stack Component:** Flex-based container that maintains consistent spacing and baseline alignment
|
|
49
|
-
- 🎨 **Theme System:** Customizable colors and debug visuals through a centralized configuration
|
|
50
|
-
|
|
51
|
-
## Requirements
|
|
52
|
-
|
|
53
|
-
- **React 19**: Baseline Kit is built for React 19 and uses the latest React features like the `use` hook
|
|
54
|
-
- **Modern Browsers**: Supporting the latest CSS features
|
|
55
|
-
|
|
56
|
-
## Installation
|
|
57
|
-
|
|
58
|
-
```shell
|
|
59
|
-
# Using npm
|
|
60
|
-
npm install baseline-kit
|
|
61
|
-
|
|
62
|
-
# Using yarn
|
|
63
|
-
yarn add baseline-kit
|
|
64
|
-
|
|
65
|
-
# Using pnpm
|
|
66
|
-
pnpm add baseline-kit
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
After installation, import both the styles and theme in your application:
|
|
70
|
-
|
|
71
|
-
```tsx
|
|
72
|
-
// Import in your main entry file (e.g., index.js, App.js)
|
|
73
|
-
import 'baseline-kit/styles'; // Required core styles
|
|
74
|
-
import 'baseline-kit/theme'; // Recommended theme (or use your own)
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
For frameworks like Remix that use URL imports in a links function:
|
|
78
|
-
|
|
79
|
-
```tsx
|
|
80
|
-
export const links = () => [
|
|
81
|
-
{ rel: "stylesheet", href: "baseline-kit/styles" },
|
|
82
|
-
{ rel: "stylesheet", href: "baseline-kit/theme" }
|
|
83
|
-
];
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
If you prefer a single CSS file that includes everything:
|
|
87
|
-
|
|
88
|
-
```tsx
|
|
89
|
-
// Alternative: Import everything in one file
|
|
90
|
-
import 'baseline-kit/full';
|
|
91
|
-
|
|
92
|
-
// For Remix:
|
|
93
|
-
export const links = () => [
|
|
94
|
-
{ rel: "stylesheet", href: "baseline-kit/full" }
|
|
95
|
-
];
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
Baseline Kit is written in TypeScript and includes built-in type definitions—no additional packages required.
|
|
99
|
-
|
|
100
|
-
## Quick Start
|
|
101
|
-
|
|
102
|
-
```tsx
|
|
103
|
-
import React from 'react'
|
|
104
|
-
import { Config, Guide, Baseline, Box } from 'baseline-kit'
|
|
105
|
-
|
|
106
|
-
function App() {
|
|
107
|
-
const isDev = process.env.NODE_ENV === 'development'
|
|
108
|
-
const debugging = isDev ? 'visible' : 'hidden'
|
|
109
|
-
|
|
110
|
-
return (
|
|
111
|
-
<Config
|
|
112
|
-
base={8}
|
|
113
|
-
baseline={{ debugging }}
|
|
114
|
-
box={{ debugging }}
|
|
115
|
-
guide={{ debugging }}
|
|
116
|
-
spacer={{ debugging }}
|
|
117
|
-
>
|
|
118
|
-
{/* Baseline Grid for typography alignment */}
|
|
119
|
-
<Baseline
|
|
120
|
-
height="100vh"
|
|
121
|
-
debugging="visible"
|
|
122
|
-
/>
|
|
123
|
-
|
|
124
|
-
{/* Column Grid Guide */}
|
|
125
|
-
<Guide
|
|
126
|
-
variant="pattern"
|
|
127
|
-
columns={['100px', '200px', '100px']}
|
|
128
|
-
gap={16}
|
|
129
|
-
align="center"
|
|
130
|
-
width="1200px"
|
|
131
|
-
/>
|
|
132
|
-
|
|
133
|
-
{/* Box with baseline alignment */}
|
|
134
|
-
<Box
|
|
135
|
-
block={[2, 5]}
|
|
136
|
-
debugging="visible"
|
|
137
|
-
>
|
|
138
|
-
<h1>Content Aligned to the Grid</h1>
|
|
139
|
-
</Box>
|
|
140
|
-
|
|
141
|
-
<main>Your main content goes here...</main>
|
|
142
|
-
</Config>
|
|
143
|
-
)
|
|
144
|
-
}
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
## Core Concepts
|
|
148
|
-
|
|
149
|
-
### Base Unit
|
|
150
|
-
|
|
151
|
-
The base unit is the foundation of Baseline Kit's spacing system. All measurements are calculated as multiples of this
|
|
152
|
-
unit:
|
|
153
|
-
|
|
154
|
-
```tsx
|
|
155
|
-
<Config base={8}> // Sets 8px as the base unit
|
|
156
|
-
<Layout
|
|
157
|
-
block={17} // Will be rounded to 16px (2 * base)
|
|
158
|
-
inline={22} // Will be rounded to 24px (3 * base)
|
|
159
|
-
>
|
|
160
|
-
{/* Content automatically aligned to the 8px grid */}
|
|
161
|
-
</Layout>
|
|
162
|
-
</Config>
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
### Spacing Values
|
|
166
|
-
|
|
167
|
-
Spacing props (`block`, `inline`, `gap`) accept values in three formats:
|
|
168
|
-
|
|
169
|
-
```
|
|
170
|
-
// Single number (applies to both sides)
|
|
171
|
-
block={16} // 16px top and bottom
|
|
172
|
-
|
|
173
|
-
// Array [start, end]
|
|
174
|
-
block={[2, 3]} // 2px top, 3px bottom
|
|
175
|
-
|
|
176
|
-
// Object with explicit values
|
|
177
|
-
block={{ start: 2, end: 3 }} // Same as above
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
### Grid Snapping
|
|
181
|
-
|
|
182
|
-
Components automatically adjust their spacing to maintain baseline grid alignment:
|
|
183
|
-
|
|
184
|
-
- **Box**: Adjusts bottom padding to ensure total height aligns with base unit
|
|
185
|
-
- **Stack**: Maintains baseline alignment in flex layouts
|
|
186
|
-
- **Layout**: Ensures grid cells align with baseline
|
|
187
|
-
|
|
188
|
-
### Debugging Modes
|
|
189
|
-
|
|
190
|
-
Three modes are available for development and testing:
|
|
191
|
-
|
|
192
|
-
```tsx
|
|
193
|
-
debugging = "visible" // Shows all grid lines and measurements
|
|
194
|
-
debugging = "hidden" // Elements exist but are invisible
|
|
195
|
-
debugging = "none" // Removes debug elements entirely
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
## Components
|
|
199
|
-
|
|
200
|
-
### Component Hierarchy
|
|
201
|
-
|
|
202
|
-
#### 1. Core Components
|
|
203
|
-
|
|
204
|
-
- **`Box`** Basic container for text alignment
|
|
205
|
-
- **`Stack`** Flex-based layouts (one-dimensional)
|
|
206
|
-
- **`Layout`** Grid-based layouts (two-dimensional)
|
|
207
|
-
|
|
208
|
-
#### 2. Development Tools
|
|
209
|
-
|
|
210
|
-
- **`Baseline`** Horizontal grid overlay
|
|
211
|
-
- **`Guide`** Vertical grid overlay
|
|
212
|
-
- **`Spacer`** Precise spacing measurement
|
|
213
|
-
|
|
214
|
-
#### 3. Configuration
|
|
215
|
-
|
|
216
|
-
- **`Config`** Theme and settings provider
|
|
217
|
-
|
|
218
|
-
### Key Components
|
|
219
|
-
|
|
220
|
-
#### Config
|
|
221
|
-
|
|
222
|
-
```tsx
|
|
223
|
-
<Config
|
|
224
|
-
base={8} // Base unit for calculations
|
|
225
|
-
baseline={{ debugging }} // Baseline grid visibility
|
|
226
|
-
guide={{ debugging }} // Guide customization
|
|
227
|
-
>
|
|
228
|
-
{children}
|
|
229
|
-
</Config>
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
#### Baseline
|
|
233
|
-
|
|
234
|
-
```tsx
|
|
235
|
-
<Baseline
|
|
236
|
-
height="100vh" // Overlay height
|
|
237
|
-
variant="line" // "line" or "flat"
|
|
238
|
-
debugging="visible" // Show the grid overlay
|
|
239
|
-
/>
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
#### Guide
|
|
243
|
-
|
|
244
|
-
```tsx
|
|
245
|
-
<Guide
|
|
246
|
-
variant="pattern" // "line", "pattern", "fixed", or "auto"
|
|
247
|
-
columns={['100px', '1fr', '100px']} // Column definition
|
|
248
|
-
gap={8} // Gap value
|
|
249
|
-
width="1200px" // Container width
|
|
250
|
-
/>
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
#### Box
|
|
254
|
-
|
|
255
|
-
```tsx
|
|
256
|
-
<Box
|
|
257
|
-
block={[2, 5]} // Vertical padding in base units
|
|
258
|
-
span={2} // Grid column span when used in Layout
|
|
259
|
-
snapping="height" // "none", "height", or "clamp"
|
|
260
|
-
>
|
|
261
|
-
<p>Content aligned to baseline grid</p>
|
|
262
|
-
</Box>
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
## Theme System
|
|
266
|
-
|
|
267
|
-
Baseline Kit comes with a flexible CSS structure and theming system:
|
|
268
|
-
|
|
269
|
-
1. `core.css` - Contains the core component styles required for functionality (imported via `baseline-kit/styles`)
|
|
270
|
-
2. `theme.css` - Contains color variables and theming with automatic dark mode support (imported via `baseline-kit/theme`)
|
|
271
|
-
3. `baseline-kit.css` - Combined file with both core and theme styles (imported via `baseline-kit/full`)
|
|
272
|
-
|
|
273
|
-
### CSS Import Options
|
|
274
|
-
|
|
275
|
-
Baseline Kit gives you flexibility in how you include the styles:
|
|
276
|
-
|
|
277
|
-
```tsx
|
|
278
|
-
// Option 1: Import core styles and theme separately (recommended)
|
|
279
|
-
import 'baseline-kit/styles';
|
|
280
|
-
import 'baseline-kit/theme';
|
|
281
|
-
|
|
282
|
-
// Option 2: Import everything in one file
|
|
283
|
-
import 'baseline-kit/full';
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
### Theme Options
|
|
287
|
-
|
|
288
|
-
You now have four options for using the theme system:
|
|
289
|
-
|
|
290
|
-
#### 1. Use the Built-in Theme (with automatic dark mode)
|
|
291
|
-
|
|
292
|
-
```tsx
|
|
293
|
-
import 'baseline-kit/theme'; // Default theme with light/dark mode support
|
|
294
|
-
```
|
|
295
|
-
|
|
296
|
-
#### 2. Use Specific Theme Variants
|
|
297
|
-
|
|
298
|
-
```tsx
|
|
299
|
-
// Use only the light theme (no dark mode)
|
|
300
|
-
import 'baseline-kit/theme/default';
|
|
301
|
-
|
|
302
|
-
// Use only the dark theme
|
|
303
|
-
import 'baseline-kit/theme/dark';
|
|
304
|
-
|
|
305
|
-
// Example: Apply dark theme regardless of system preference
|
|
306
|
-
import 'baseline-kit/styles';
|
|
307
|
-
import 'baseline-kit/theme/dark';
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
#### 3. Create a Custom Theme
|
|
311
|
-
|
|
312
|
-
You can use the tokens template as a starting point:
|
|
313
|
-
|
|
314
|
-
```tsx
|
|
315
|
-
// First check the token template to see available variables
|
|
316
|
-
import 'baseline-kit/theme/tokens'; // Just for reference (contains no values)
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
Then create your own custom theme file:
|
|
320
|
-
|
|
321
|
-
```css
|
|
322
|
-
/* yourCustomTheme.css */
|
|
323
|
-
:root {
|
|
324
|
-
/* Component-specific colors */
|
|
325
|
-
--bk-baseline-color-line-theme: hsla(210, 100%, 50%, 0.15);
|
|
326
|
-
--bk-baseline-color-flat-theme: hsla(270, 100%, 60%, 0.2);
|
|
327
|
-
/* Add other component colors as needed */
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/* Optional dark mode support */
|
|
331
|
-
@media (prefers-color-scheme: dark) {
|
|
332
|
-
:root {
|
|
333
|
-
--bk-baseline-color-line-theme: hsla(210, 100%, 50%, 0.2);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
Then import your custom theme:
|
|
339
|
-
|
|
340
|
-
```tsx
|
|
341
|
-
import 'baseline-kit/styles'; // Required core styles
|
|
342
|
-
import './path/to/yourCustomTheme.css'; // Your custom theme
|
|
343
|
-
```
|
|
344
|
-
|
|
345
|
-
#### 4. Override via Config
|
|
346
|
-
|
|
347
|
-
For minor adjustments, use the Config component:
|
|
348
|
-
|
|
349
|
-
```tsx
|
|
350
|
-
<Config
|
|
351
|
-
baseline={{
|
|
352
|
-
colors: {
|
|
353
|
-
line: 'rgba(255,0,0,0.1)', // Custom red baseline lines
|
|
354
|
-
flat: 'rgba(255,0,0,0.05)', // Custom red baseline backgrounds
|
|
355
|
-
}
|
|
356
|
-
}}
|
|
357
|
-
>
|
|
358
|
-
{/* Your components here */}
|
|
359
|
-
</Config>
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
### Theme Variables Reference
|
|
363
|
-
|
|
364
|
-
| Component | Variable Pattern | Purpose |
|
|
365
|
-
|-----------|-----------------|---------|
|
|
366
|
-
| Baseline | `--bk-baseline-color-[line/flat]-theme` | Colors for lines and backgrounds |
|
|
367
|
-
| Guide | `--bk-guide-color-[line/pattern/auto/fixed]-theme` | Colors for different guide variants |
|
|
368
|
-
| Box | `--bk-box-color-[line/flat/text]-theme` | Colors for borders, backgrounds and text |
|
|
369
|
-
| Stack | `--bk-stack-color-[line/flat/text]-theme` | Colors for borders, backgrounds and text |
|
|
370
|
-
| Layout | `--bk-layout-color-[line/flat/text]-theme` | Colors for borders, backgrounds and text |
|
|
371
|
-
| Spacer | `--bk-spacer-color-[line/flat/text]-theme` | Colors for borders, backgrounds and text |
|
|
372
|
-
|
|
373
|
-
See the [tokens file](https://github.com/dnvt/baseline-kit/blob/main/dist/theme/tokens.css) for a complete list of available variables.
|
|
374
|
-
|
|
375
|
-
## Browser Support
|
|
376
|
-
|
|
377
|
-
- Modern browsers (Chrome, Firefox, Safari, Edge)
|
|
378
|
-
- Requires CSS Grid Layout support and CSS Custom Properties
|
|
379
|
-
- Falls back gracefully in unsupported browsers
|
|
380
|
-
|
|
381
|
-
## React 19 Features
|
|
382
|
-
|
|
383
|
-
Baseline Kit leverages React 19's latest features:
|
|
384
|
-
- **`use` Hook**: Replaces `useContext` for better performance and cleaner code
|
|
385
|
-
- **Streamlined Context API**: Uses the simplified Context Provider syntax
|
|
386
|
-
- **JSX Transform**: Takes advantage of the mandatory JSX transform in React 19
|
|
387
|
-
|
|
388
|
-
These modern features allow for cleaner code and better performance, but require React 19.
|
|
389
|
-
|
|
390
|
-
## Server-Side Rendering (SSR)
|
|
391
|
-
|
|
392
|
-
Baseline Kit is fully compatible with React's Server-Side Rendering in frameworks like Next.js, Remix, and other React Router-based applications.
|
|
393
|
-
|
|
394
|
-
### SSR-Friendly Design
|
|
395
|
-
|
|
396
|
-
Components are designed to:
|
|
397
|
-
- Provide consistent rendering between server and client
|
|
398
|
-
- Avoid hydration mismatches by using deterministic initial values
|
|
399
|
-
- Progressively enhance with client-side measurements after hydration
|
|
400
|
-
- Work with frameworks that use streaming SSR
|
|
401
|
-
|
|
402
|
-
### SSR Mode Prop
|
|
403
|
-
|
|
404
|
-
Components accept an `ssrMode` prop to explicitly optimize for server rendering:
|
|
405
|
-
|
|
406
|
-
```tsx
|
|
407
|
-
<Baseline
|
|
408
|
-
height="100vh"
|
|
409
|
-
ssrMode={true}
|
|
410
|
-
debugging="visible"
|
|
411
|
-
/>
|
|
412
|
-
```
|
|
413
|
-
|
|
414
|
-
With `ssrMode` enabled, components use simplified rendering during SSR and initial hydration, then enhance with full features after client-side hydration completes.
|
|
415
|
-
|
|
416
|
-
## Development
|
|
417
|
-
|
|
418
|
-
```shell
|
|
419
|
-
# Clone the repository
|
|
420
|
-
git clone https://github.com/dnvt/baseline-kit.git
|
|
421
|
-
|
|
422
|
-
# Install dependencies
|
|
423
|
-
bun install
|
|
424
|
-
|
|
425
|
-
# Start development server
|
|
426
|
-
bun run dev
|
|
427
|
-
|
|
428
|
-
# Run tests
|
|
429
|
-
bun run test
|
|
430
|
-
```
|
|
431
|
-
|
|
432
|
-
## Performance Features
|
|
433
|
-
|
|
434
|
-
- Virtualizes large grid overlays
|
|
435
|
-
- Client-side only rendering for dynamic components
|
|
436
|
-
- Optimized resize event handling
|
|
437
|
-
- Optimizes re-renders using React.memo and useMemo
|
|
438
|
-
- Supports tree-shaking for minimal bundle size
|
|
439
|
-
|
|
440
|
-
## Contributing
|
|
441
|
-
|
|
442
|
-
Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for detailed guidelines.
|
|
443
|
-
|
|
444
|
-
## License
|
|
445
|
-
|
|
446
|
-
MIT © [François Denavaut](https://github.com/dnvt)
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ComponentsProps } from '@components';
|
|
3
|
-
import { Variant } from '../types';
|
|
4
|
-
export type BaselineVariant = Exclude<Variant, 'pattern'>;
|
|
5
|
-
export type BaselineProps = {
|
|
6
|
-
/** Visual style variant for the baseline guides */
|
|
7
|
-
variant?: BaselineVariant;
|
|
8
|
-
/** Explicit width for the overlay (e.g., "1200px" or 1200) */
|
|
9
|
-
width?: number | string;
|
|
10
|
-
/** Explicit height for the overlay (e.g., "100vh" or 800) */
|
|
11
|
-
height?: number | string;
|
|
12
|
-
/** Base unit for measurements (defaults to theme value) */
|
|
13
|
-
base?: number;
|
|
14
|
-
/** Color override for grid lines */
|
|
15
|
-
color?: string;
|
|
16
|
-
/** Flag to enable SSR-compatible mode (simplified initial render) */
|
|
17
|
-
ssrMode?: boolean;
|
|
18
|
-
} & ComponentsProps;
|
|
19
|
-
/**
|
|
20
|
-
* Renders horizontal guidelines for maintaining vertical rhythm and baseline alignment.
|
|
21
|
-
*
|
|
22
|
-
* @remarks
|
|
23
|
-
* Baseline provides horizontal guides that:
|
|
24
|
-
* - Help maintain consistent vertical spacing
|
|
25
|
-
* - Support visual verification of baseline alignment
|
|
26
|
-
* - Optimize performance through virtual rendering
|
|
27
|
-
* - Adapt to container dimensions
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```tsx
|
|
31
|
-
* // Basic baseline overlay
|
|
32
|
-
* <Baseline
|
|
33
|
-
* height="100vh"
|
|
34
|
-
* base={8}
|
|
35
|
-
* debugging="visible"
|
|
36
|
-
* />
|
|
37
|
-
*
|
|
38
|
-
* // Custom variant with padding
|
|
39
|
-
* <Baseline
|
|
40
|
-
* variant="flat"
|
|
41
|
-
* height="100vh"
|
|
42
|
-
* base={4}
|
|
43
|
-
* block={[16, 0]}
|
|
44
|
-
* debugging="visible"
|
|
45
|
-
* />
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
export declare const Baseline: React.NamedExoticComponent<BaselineProps>;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ComponentsProps } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Determines how the Box component aligns to the baseline grid.
|
|
5
|
-
*
|
|
6
|
-
* @remarks
|
|
7
|
-
* - `none`: No snapping; uses raw spacing values as provided
|
|
8
|
-
* - `height`: Only container height snaps to base unit multiples
|
|
9
|
-
* - `clamp`: Both height and spacing values snap to base unit multiples
|
|
10
|
-
*/
|
|
11
|
-
export type SnappingMode = 'none' | 'height' | 'clamp';
|
|
12
|
-
export type BoxProps = {
|
|
13
|
-
/** Number of columns to span in a grid layout */
|
|
14
|
-
colSpan?: number;
|
|
15
|
-
/** Number of rows to span in a grid layout */
|
|
16
|
-
rowSpan?: number;
|
|
17
|
-
/** Shorthand for equal column and row span. Takes precedence over individual spans */
|
|
18
|
-
span?: number;
|
|
19
|
-
/** Controls baseline grid alignment behavior */
|
|
20
|
-
snapping?: SnappingMode;
|
|
21
|
-
/** Flag to enable SSR-compatible mode (simplified initial render) */
|
|
22
|
-
ssrMode?: boolean;
|
|
23
|
-
children?: React.ReactNode;
|
|
24
|
-
} & ComponentsProps;
|
|
25
|
-
/**
|
|
26
|
-
* A foundational container component that ensures consistent spacing and baseline alignment.
|
|
27
|
-
*
|
|
28
|
-
* @remarks
|
|
29
|
-
* Box provides a layout container that:
|
|
30
|
-
* - Ensures consistent spacing aligned to the baseline grid
|
|
31
|
-
* - Supports grid layout integration through span props
|
|
32
|
-
* - Offers configurable snapping modes for fine-grained alignment control
|
|
33
|
-
* - Includes debug overlays for visual alignment verification
|
|
34
|
-
*
|
|
35
|
-
* By default, Box uses "auto" for both width and height unless explicitly specified.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```tsx
|
|
39
|
-
* // Basic usage with spacing
|
|
40
|
-
* <Box block={16} inline={8}>
|
|
41
|
-
* <p>Content aligned to baseline</p>
|
|
42
|
-
* </Box>
|
|
43
|
-
*
|
|
44
|
-
* // With grid spanning and custom snapping
|
|
45
|
-
* <Box
|
|
46
|
-
* colSpan={2}
|
|
47
|
-
* rowSpan={1}
|
|
48
|
-
* snapping="height"
|
|
49
|
-
* debugging="visible"
|
|
50
|
-
* >
|
|
51
|
-
* <p>Grid-integrated content</p>
|
|
52
|
-
* </Box>
|
|
53
|
-
* ```
|
|
54
|
-
*/
|
|
55
|
-
export declare const Box: React.NamedExoticComponent<{
|
|
56
|
-
/** Number of columns to span in a grid layout */
|
|
57
|
-
colSpan?: number;
|
|
58
|
-
/** Number of rows to span in a grid layout */
|
|
59
|
-
rowSpan?: number;
|
|
60
|
-
/** Shorthand for equal column and row span. Takes precedence over individual spans */
|
|
61
|
-
span?: number;
|
|
62
|
-
/** Controls baseline grid alignment behavior */
|
|
63
|
-
snapping?: SnappingMode;
|
|
64
|
-
/** Flag to enable SSR-compatible mode (simplified initial render) */
|
|
65
|
-
ssrMode?: boolean;
|
|
66
|
-
children?: React.ReactNode;
|
|
67
|
-
} & {
|
|
68
|
-
debugging?: import("..").DebuggingMode;
|
|
69
|
-
className?: string;
|
|
70
|
-
style?: React.CSSProperties;
|
|
71
|
-
height?: React.CSSProperties["height"];
|
|
72
|
-
width?: React.CSSProperties["width"];
|
|
73
|
-
} & import("..").SpacingProps & React.RefAttributes<HTMLDivElement>>;
|