baseline-kit 2.0.0 → 2.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/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Baseline Kit
2
2
 
3
- Baseline Kit is a lightweight development tool for visualizing and debugging grid systems and spacing in React
3
+ Baseline Kit is a lightweight development tool for visualizing and debugging grid systems and spacing in React 19
4
4
  applications. It provides configurable overlays for both column-based and baseline grids, flexible layout components,
5
5
  and theme-aware configuration—all optimized for performance and built with TypeScript.
6
6
 
7
- ![Demo visual](demo/padded-demo.png)
7
+ ![Demo visual](kit.png)
8
8
 
9
9
  ## Features
10
10
 
@@ -15,6 +15,11 @@ and theme-aware configuration—all optimized for performance and built with Typ
15
15
  - 📐 **Stack Component:** Flex-based container that maintains consistent spacing and baseline alignment
16
16
  - 🎨 **Theme System:** Customizable colors and debug visuals through a centralized configuration
17
17
 
18
+ ## Requirements
19
+
20
+ - **React 19**: Baseline Kit is built for React 19 and uses the latest React features like the `use` hook
21
+ - **Modern Browsers**: Supporting the latest CSS features
22
+
18
23
  ## Installation
19
24
 
20
25
  ```shell
@@ -28,18 +33,21 @@ yarn add baseline-kit
28
33
  pnpm add baseline-kit
29
34
  ```
30
35
 
31
- ### TypeScript Support
36
+ After installation, import both the styles and theme in your application:
37
+
38
+ ```tsx
39
+ // Import in your main entry file (e.g., index.js, App.js)
40
+ import 'baseline-kit/styles'; // Required core styles
41
+ import 'baseline-kit/theme'; // Recommended theme (or use your own)
42
+ ```
32
43
 
33
- Baseline Kit is written in TypeScript and includes built-in type definitions. No additional packages are required.
44
+ Baseline Kit is written in TypeScript and includes built-in type definitions—no additional packages required.
34
45
 
35
46
  ## Quick Start
36
47
 
37
- Basic setup with debugging enabled during development:
38
-
39
48
  ```tsx
40
49
  import React from 'react'
41
50
  import { Config, Guide, Baseline, Box } from 'baseline-kit'
42
- import 'baseline-kit/styles.css'
43
51
 
44
52
  function App() {
45
53
  const isDev = process.env.NODE_ENV === 'development'
@@ -71,7 +79,6 @@ function App() {
71
79
  {/* Box with baseline alignment */}
72
80
  <Box
73
81
  block={[2, 5]}
74
- inline={1}
75
82
  debugging="visible"
76
83
  >
77
84
  <h1>Content Aligned to the Grid</h1>
@@ -91,20 +98,13 @@ The base unit is the foundation of Baseline Kit's spacing system. All measuremen
91
98
  unit:
92
99
 
93
100
  ```tsx
94
- <Config base={8}> // Sets 8px as the base unit
101
+ <Config base={8}> // Sets 8px as the base unit
95
102
  <Layout
96
103
  block={17} // Will be rounded to 16px (2 * base)
97
104
  inline={22} // Will be rounded to 24px (3 * base)
98
105
  >
99
106
  {/* Content automatically aligned to the 8px grid */}
100
107
  </Layout>
101
-
102
- <Stack
103
- block={[17, 25]} // Top: 16px, Bottom: 24px
104
- inline={22} // Left/Right: 24px
105
- >
106
- {/* Padding automatically adjusted to base unit multiples */}
107
- </Stack>
108
108
  </Config>
109
109
  ```
110
110
 
@@ -114,7 +114,7 @@ Spacing props (`block`, `inline`, `gap`) accept values in three formats:
114
114
 
115
115
  ```
116
116
  // Single number (applies to both sides)
117
- block={16px} // 16px top and bottom
117
+ block={16} // 16px top and bottom
118
118
 
119
119
  // Array [start, end]
120
120
  block={[2, 3]} // 2px top, 3px bottom
@@ -160,129 +160,172 @@ debugging = "none" // Removes debug elements entirely
160
160
  #### 3. Configuration
161
161
 
162
162
  - **`Config`** Theme and settings provider
163
- - **`Padder`** Internal spacing utility
164
163
 
165
- ### Config
164
+ ### Key Components
166
165
 
167
- The Config component provides theme and debugging settings to all child components.
166
+ #### Config
168
167
 
169
168
  ```tsx
170
169
  <Config
171
170
  base={8} // Base unit for calculations
172
171
  baseline={{ debugging }} // Baseline grid visibility
173
- guide={{ // Guide customization
174
- debugging,
175
- colors: {
176
- line: 'rgba(0,0,255,0.1)'
177
- }
178
- }}
172
+ guide={{ debugging }} // Guide customization
179
173
  >
180
174
  {children}
181
175
  </Config>
182
176
  ```
183
177
 
184
- ### Baseline
178
+ #### Baseline
185
179
 
186
180
  ```tsx
187
181
  <Baseline
188
- base={8} // Base unit (defaults to Config value)
189
182
  height="100vh" // Overlay height
190
183
  variant="line" // "line" or "flat"
191
184
  debugging="visible" // Show the grid overlay
192
185
  />
193
186
  ```
194
187
 
195
- ### Guide
188
+ #### Guide
196
189
 
197
190
  ```tsx
198
191
  <Guide
199
- variant="pattern" // "line", "pattern", "fixed", or "auto"
200
- columns={['100px', '1fr', '100px']} // Column definition
201
- gap={8} // Gap value
202
- align="center" // "start", "center", or "end"
203
- width="1200px" // Container width
204
- debugging="visible" // Show grid overlay
192
+ variant="pattern" // "line", "pattern", "fixed", or "auto"
193
+ columns={['100px', '1fr', '100px']} // Column definition
194
+ gap={8} // Gap value
195
+ width="1200px" // Container width
205
196
  />
206
197
  ```
207
198
 
208
- ### Box
199
+ #### Box
209
200
 
210
201
  ```tsx
211
202
  <Box
212
- block={[2, 5]} // Vertical padding in base units (auto-adjusted for baseline)
213
- inline={1} // Horizontal padding in base units
203
+ block={[2, 5]} // Vertical padding in base units
214
204
  span={2} // Grid column span when used in Layout
215
205
  snapping="height" // "none", "height", or "clamp"
216
- debugging="visible" // Show alignment guides
217
206
  >
218
207
  <p>Content aligned to baseline grid</p>
219
208
  </Box>
220
209
  ```
221
210
 
222
- ### Stack
211
+ ## Theme System
212
+
213
+ Baseline Kit comes with two CSS files:
214
+
215
+ 1. `styles.css` - Contains the core component styles required for functionality
216
+ 2. `theme.css` - Contains color variables and theming (optional but recommended)
217
+
218
+ ### Theme Options
219
+
220
+ You have three options for using the theme system:
221
+
222
+ #### 1. Use the Built-in Theme
223
223
 
224
224
  ```tsx
225
- <Stack
226
- direction="column" // "row" or "column"
227
- block={[8, 24]} // Vertical padding (auto-snapping)
228
- inline={16} // Horizontal padding (auto-snapping)
229
- gap={16} // Gap value
230
- justify="center" // Flex justify-content
231
- align="center" // Flex align-items
232
- debugging="visible" // Show alignment guides
233
- >
234
- <Box>Item 1</Box>
235
- <Box>Item 2</Box>
236
- </Stack>
225
+ import 'baseline-kit/theme'; // Default theme with light/dark mode support
237
226
  ```
238
227
 
239
- ### Layout
228
+ #### 2. Create a Custom Theme
240
229
 
241
- ```tsx
242
- <Layout
243
- columns={3} // Number of columns or pattern array
244
- gap={16} // Gap value
245
- block={16} // Vertical padding (auto-snapping)
246
- inline={8} // Horizontal padding (auto-snapping)
247
- debugging="visible" // Show grid guides
248
- >
249
- <Box span={2}>Wide content</Box>
250
- <Box>Regular content</Box>
251
- </Layout>
230
+ Create your own theme.css file:
231
+
232
+ ```css
233
+ /* yourCustomTheme.css */
234
+ :root {
235
+ /* Component-specific colors */
236
+ --bk-baseline-color-line-theme: hsla(210, 100%, 50%, 0.15);
237
+ --bk-baseline-color-flat-theme: hsla(270, 100%, 60%, 0.2);
238
+ /* Add other component colors as needed */
239
+ }
240
+
241
+ /* Optional dark mode support */
242
+ @media (prefers-color-scheme: dark) {
243
+ :root {
244
+ --bk-baseline-color-line-theme: hsla(210, 100%, 50%, 0.2);
245
+ }
246
+ }
252
247
  ```
253
248
 
254
- ## Theme System
249
+ Then import your custom theme:
250
+
251
+ ```tsx
252
+ import 'baseline-kit/styles'; // Required core styles
253
+ import './path/to/yourCustomTheme.css'; // Your custom theme
254
+ ```
255
255
 
256
- ### Color Customization
256
+ #### 3. Override via Config
257
257
 
258
- The theme system allows customization of debugging visuals through the Config component:
258
+ For minor adjustments, use the Config component:
259
259
 
260
260
  ```tsx
261
261
  <Config
262
- base={8}
263
- guide={{
264
- colors: {
265
- line: 'rgba(0,0,255,0.1)',
266
- pattern: 'rgba(0,0,255,0.05)',
267
- auto: 'rgba(0,0,255,0.05)',
268
- fixed: 'rgba(0,0,255,0.05)'
269
- }
270
- }}
271
262
  baseline={{
272
263
  colors: {
273
- line: 'rgba(255,0,0,0.1)',
274
- flat: 'rgba(255,0,0,0.05)'
264
+ line: 'rgba(255,0,0,0.1)', // Custom red baseline lines
265
+ flat: 'rgba(255,0,0,0.05)', // Custom red baseline backgrounds
275
266
  }
276
267
  }}
277
268
  >
278
- {children}
269
+ {/* Your components here */}
279
270
  </Config>
280
271
  ```
281
272
 
282
- The library uses CSS custom properties for colors, which automatically respect the user's system dark mode preferences
283
- through CSS media queries. No additional configuration is required.
273
+ ### Theme Variables Reference
284
274
 
285
- ## Development Setup
275
+ | Component | Variable Pattern | Purpose |
276
+ |-----------|-----------------|---------|
277
+ | Baseline | `--bk-baseline-color-[line/flat]-theme` | Colors for lines and backgrounds |
278
+ | Guide | `--bk-guide-color-[line/pattern/auto/fixed]-theme` | Colors for different guide variants |
279
+ | Box | `--bk-box-color-[line/flat/text]-theme` | Colors for borders, backgrounds and text |
280
+ | Stack | `--bk-stack-color-[line/flat/text]-theme` | Colors for borders, backgrounds and text |
281
+ | Layout | `--bk-layout-color-[line/flat/text]-theme` | Colors for borders, backgrounds and text |
282
+ | Spacer | `--bk-spacer-color-[line/flat/text]-theme` | Colors for borders, backgrounds and text |
283
+
284
+ See the [default theme file](https://github.com/dnvt/baseline-kit/blob/main/dist/theme.css) for a complete example.
285
+
286
+ ## Browser Support
287
+
288
+ - Modern browsers (Chrome, Firefox, Safari, Edge)
289
+ - Requires CSS Grid Layout support and CSS Custom Properties
290
+ - Falls back gracefully in unsupported browsers
291
+
292
+ ## React 19 Features
293
+
294
+ Baseline Kit leverages React 19's latest features:
295
+
296
+ - **`use` Hook**: Replaces `useContext` for better performance and cleaner code
297
+ - **Streamlined Context API**: Uses the simplified Context Provider syntax
298
+ - **JSX Transform**: Takes advantage of the mandatory JSX transform in React 19
299
+
300
+ These modern features allow for cleaner code and better performance, but require React 19.
301
+
302
+ ## Server-Side Rendering (SSR)
303
+
304
+ Baseline Kit is fully compatible with React's Server-Side Rendering in frameworks like Next.js, Remix, and other React Router-based applications.
305
+
306
+ ### SSR-Friendly Design
307
+
308
+ Components are designed to:
309
+ - Provide consistent rendering between server and client
310
+ - Avoid hydration mismatches by using deterministic initial values
311
+ - Progressively enhance with client-side measurements after hydration
312
+ - Work with frameworks that use streaming SSR
313
+
314
+ ### SSR Mode Prop
315
+
316
+ Components accept an `ssrMode` prop to explicitly optimize for server rendering:
317
+
318
+ ```tsx
319
+ <Baseline
320
+ height="100vh"
321
+ ssrMode={true}
322
+ debugging="visible"
323
+ />
324
+ ```
325
+
326
+ With `ssrMode` enabled, components use simplified rendering during SSR and initial hydration, then enhance with full features after client-side hydration completes.
327
+
328
+ ## Development
286
329
 
287
330
  ```shell
288
331
  # Clone the repository
@@ -296,38 +339,17 @@ bun run dev
296
339
 
297
340
  # Run tests
298
341
  bun run test
299
-
300
- # Build package
301
- bun run build
302
342
  ```
303
343
 
304
- ## Server-Side Rendering
344
+ ## Performance Features
305
345
 
306
- Baseline Kit is compatible with SSR frameworks like Next.js and Gatsby. The overlay components automatically handle
307
- hydration mismatches.
308
-
309
- ## Browser Support
310
-
311
- - Modern browsers (Chrome, Firefox, Safari, Edge)
312
- - Requires CSS Grid Layout support
313
- - Requires CSS Custom Properties (CSS Variables)
314
- - Falls back gracefully in unsupported browsers
315
-
316
- ## Performance Considerations
317
-
318
- - Uses requestAnimationFrame for smooth animations
319
346
  - Virtualizes large grid overlays
320
347
  - Optimizes re-renders using React.memo
321
348
  - Supports tree-shaking for minimal bundle size
322
349
 
323
350
  ## Contributing
324
351
 
325
- Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for detailed guidelines on:
326
-
327
- - Development setup
328
- - Code style
329
- - Testing requirements
330
- - Pull request process
352
+ Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for detailed guidelines.
331
353
 
332
354
  ## License
333
355