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 +127 -105
- package/dist/README.md +127 -105
- package/dist/components/Baseline/Baseline.d.ts +29 -6
- package/dist/components/Box/Box.d.ts +27 -6
- package/dist/components/Config/Config.d.ts +52 -9
- package/dist/components/Guide/Guide.d.ts +37 -13
- package/dist/components/Layout/Layout.d.ts +21 -7
- package/dist/components/Padder/Padder.d.ts +24 -7
- package/dist/components/Spacer/Spacer.d.ts +32 -35
- package/dist/components/Stack/Stack.d.ts +27 -11
- package/dist/components/types.d.ts +1 -1
- package/dist/hooks/useBaseline.d.ts +34 -51
- package/dist/hooks/useConfig.d.ts +0 -5
- package/dist/hooks/useDebug.d.ts +1 -6
- package/dist/hooks/useGuide.d.ts +2 -7
- package/dist/hooks/useMeasure.d.ts +6 -20
- package/dist/hooks/useVirtual.d.ts +0 -5
- package/dist/index.cjs +11 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1665 -1100
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/theme.css +140 -0
- package/dist/utils/convert.d.ts +0 -5
- package/dist/utils/grid.d.ts +22 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/math.d.ts +26 -5
- package/dist/utils/merge.d.ts +54 -5
- package/dist/utils/parse.d.ts +0 -5
- package/dist/utils/snapping.d.ts +0 -5
- package/dist/utils/ssr.d.ts +33 -0
- package/dist/utils/timing.d.ts +2 -7
- package/package.json +43 -32
package/dist/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
|
-

|
|
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
|
-
|
|
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
|
|
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}>
|
|
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={
|
|
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
|
-
###
|
|
164
|
+
### Key Components
|
|
166
165
|
|
|
167
|
-
|
|
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={{
|
|
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
|
-
|
|
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
|
-
|
|
188
|
+
#### Guide
|
|
196
189
|
|
|
197
190
|
```tsx
|
|
198
191
|
<Guide
|
|
199
|
-
variant="pattern"
|
|
200
|
-
columns={['100px', '1fr', '100px']}
|
|
201
|
-
gap={8}
|
|
202
|
-
|
|
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
|
-
|
|
199
|
+
#### Box
|
|
209
200
|
|
|
210
201
|
```tsx
|
|
211
202
|
<Box
|
|
212
|
-
block={[2, 5]} // Vertical padding in base units
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
228
|
+
#### 2. Create a Custom Theme
|
|
240
229
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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
|
-
|
|
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
|
-
|
|
256
|
+
#### 3. Override via Config
|
|
257
257
|
|
|
258
|
-
|
|
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
|
-
{
|
|
269
|
+
{/* Your components here */}
|
|
279
270
|
</Config>
|
|
280
271
|
```
|
|
281
272
|
|
|
282
|
-
|
|
283
|
-
through CSS media queries. No additional configuration is required.
|
|
273
|
+
### Theme Variables Reference
|
|
284
274
|
|
|
285
|
-
|
|
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
|
-
##
|
|
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
|
|
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
|
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* @file Baseline Component
|
|
3
|
-
* @description Horizontal grid overlay for baseline alignment
|
|
4
|
-
* @module components
|
|
5
|
-
*/
|
|
1
|
+
import * as React from 'react';
|
|
6
2
|
import { ComponentsProps } from '@components';
|
|
7
3
|
import { Variant } from '../types';
|
|
8
4
|
export type BaselineVariant = Exclude<Variant, 'pattern'>;
|
|
@@ -15,7 +11,33 @@ export type BaselineProps = {
|
|
|
15
11
|
height?: number | string;
|
|
16
12
|
/** Base unit for measurements (defaults to theme value) */
|
|
17
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
18
|
} & ComponentsProps;
|
|
19
|
+
/** Creates default baseline styles */
|
|
20
|
+
export declare const createDefaultBaselineStyles: (base: number, lineColor: string, flatColor: string) => Record<string, string>;
|
|
21
|
+
/** Create row styles for baseline lines */
|
|
22
|
+
type RowStyleParams = {
|
|
23
|
+
/** Row index */
|
|
24
|
+
index: number;
|
|
25
|
+
/** Base unit for calculations */
|
|
26
|
+
base: number;
|
|
27
|
+
/** Baseline visual variant */
|
|
28
|
+
variant: BaselineVariant;
|
|
29
|
+
/** Selected color for the baseline */
|
|
30
|
+
chosenColor: string;
|
|
31
|
+
/** Theme line color */
|
|
32
|
+
lineColor: string;
|
|
33
|
+
/** Theme flat color */
|
|
34
|
+
flatColor: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Creates styles for an individual baseline row.
|
|
38
|
+
* Applies positioning and visual styling based on variant.
|
|
39
|
+
*/
|
|
40
|
+
export declare const createBaselineRowStyle: (params: RowStyleParams) => React.CSSProperties;
|
|
19
41
|
/**
|
|
20
42
|
* Renders horizontal guidelines for maintaining vertical rhythm and baseline alignment.
|
|
21
43
|
*
|
|
@@ -45,4 +67,5 @@ export type BaselineProps = {
|
|
|
45
67
|
* />
|
|
46
68
|
* ```
|
|
47
69
|
*/
|
|
48
|
-
export declare const Baseline:
|
|
70
|
+
export declare const Baseline: React.NamedExoticComponent<BaselineProps>;
|
|
71
|
+
export {};
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Box Component
|
|
3
|
-
* @description A fundamental layout container with baseline grid alignment
|
|
4
|
-
* @module components
|
|
5
|
-
*/
|
|
6
1
|
import * as React from 'react';
|
|
7
2
|
/**
|
|
8
3
|
* Determines how the Box component aligns to the baseline grid.
|
|
@@ -13,6 +8,29 @@ import * as React from 'react';
|
|
|
13
8
|
* - `clamp`: Both height and spacing values snap to base unit multiples
|
|
14
9
|
*/
|
|
15
10
|
export type SnappingMode = 'none' | 'height' | 'clamp';
|
|
11
|
+
/**
|
|
12
|
+
* Creates default box styles with theme values.
|
|
13
|
+
* Sets CSS variables for width, height, base unit, and colors.
|
|
14
|
+
*/
|
|
15
|
+
export declare const createDefaultBoxStyles: (base: number, lineColor: string) => Record<string, string>;
|
|
16
|
+
/** Parameters for creating box custom styles */
|
|
17
|
+
type BoxCustomStylesParams = {
|
|
18
|
+
/** Width property for the box */
|
|
19
|
+
width?: React.CSSProperties['width'];
|
|
20
|
+
/** Height property for the box */
|
|
21
|
+
height?: React.CSSProperties['height'];
|
|
22
|
+
/** Base unit for measurements */
|
|
23
|
+
base: number;
|
|
24
|
+
/** Line color from theme */
|
|
25
|
+
lineColor: string;
|
|
26
|
+
/** Default styles for comparison */
|
|
27
|
+
defaultStyles: Record<string, string>;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Creates custom styles for the box.
|
|
31
|
+
* Combines all style properties and only applies changes when needed.
|
|
32
|
+
*/
|
|
33
|
+
export declare const createBoxCustomStyles: ({ width, height, base, lineColor, defaultStyles }: BoxCustomStylesParams) => React.CSSProperties;
|
|
16
34
|
/**
|
|
17
35
|
* A foundational container component that ensures consistent spacing and baseline alignment.
|
|
18
36
|
*
|
|
@@ -23,7 +41,7 @@ export type SnappingMode = 'none' | 'height' | 'clamp';
|
|
|
23
41
|
* - Offers configurable snapping modes for fine-grained alignment control
|
|
24
42
|
* - Includes debug overlays for visual alignment verification
|
|
25
43
|
*
|
|
26
|
-
* By default, Box uses "
|
|
44
|
+
* By default, Box uses "auto" for both width and height unless explicitly specified.
|
|
27
45
|
*
|
|
28
46
|
* @example
|
|
29
47
|
* ```tsx
|
|
@@ -52,6 +70,8 @@ export declare const Box: React.NamedExoticComponent<{
|
|
|
52
70
|
span?: number;
|
|
53
71
|
/** Controls baseline grid alignment behavior */
|
|
54
72
|
snapping?: SnappingMode;
|
|
73
|
+
/** Flag to enable SSR-compatible mode (simplified initial render) */
|
|
74
|
+
ssrMode?: boolean;
|
|
55
75
|
children?: React.ReactNode;
|
|
56
76
|
} & {
|
|
57
77
|
debugging?: import("..").DebuggingMode;
|
|
@@ -60,3 +80,4 @@ export declare const Box: React.NamedExoticComponent<{
|
|
|
60
80
|
height?: React.CSSProperties["height"];
|
|
61
81
|
width?: React.CSSProperties["width"];
|
|
62
82
|
} & import("..").SpacingProps & React.RefAttributes<HTMLDivElement>>;
|
|
83
|
+
export {};
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Config Component
|
|
3
|
-
* @description Theme and configuration provider for baseline-kit components
|
|
4
|
-
* @module components
|
|
5
|
-
*/
|
|
6
1
|
import * as React from 'react';
|
|
7
|
-
import { BaselineVariant } from '
|
|
2
|
+
import { BaselineVariant } from '@/components';
|
|
8
3
|
import type { GuideVariant, Variant } from '../types';
|
|
9
4
|
/**
|
|
10
5
|
* Controls component debugging visibility and behavior.
|
|
@@ -22,7 +17,7 @@ type Colors = {
|
|
|
22
17
|
/** Color for flat surface visuals */
|
|
23
18
|
flat: string;
|
|
24
19
|
/** Color for measurement indicators */
|
|
25
|
-
|
|
20
|
+
text: string;
|
|
26
21
|
};
|
|
27
22
|
/** Complete configuration schema for baseline-kit. */
|
|
28
23
|
export type Config = {
|
|
@@ -87,8 +82,56 @@ type ConfigProps = {
|
|
|
87
82
|
/** Padder component overrides */
|
|
88
83
|
padder?: Partial<Config['padder']>;
|
|
89
84
|
};
|
|
90
|
-
/**
|
|
91
|
-
|
|
85
|
+
/** Parameters for creating CSS variables */
|
|
86
|
+
type CSSVariablesParams = {
|
|
87
|
+
/** Base unit for spacing calculations */
|
|
88
|
+
base: number;
|
|
89
|
+
/** Baseline component configuration */
|
|
90
|
+
baseline: Config['baseline'];
|
|
91
|
+
/** Guide component configuration */
|
|
92
|
+
guide: Config['guide'];
|
|
93
|
+
/** Stack component configuration */
|
|
94
|
+
stack: Config['stack'];
|
|
95
|
+
/** Spacer component configuration */
|
|
96
|
+
spacer: Config['spacer'];
|
|
97
|
+
/** Layout component configuration */
|
|
98
|
+
layout: Config['layout'];
|
|
99
|
+
/** Box component configuration */
|
|
100
|
+
box: Config['box'];
|
|
101
|
+
/** Padder component configuration */
|
|
102
|
+
padder: Config['padder'];
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Creates CSS variables from the configuration object.
|
|
106
|
+
* These variables are used throughout the component library.
|
|
107
|
+
*/
|
|
108
|
+
export declare const createCSSVariables: (params: CSSVariablesParams) => Record<string, string>;
|
|
109
|
+
/** Parameters for merging configuration */
|
|
110
|
+
type MergeConfigParams = {
|
|
111
|
+
/** Parent configuration to extend */
|
|
112
|
+
parentConfig: Config;
|
|
113
|
+
/** Base unit override */
|
|
114
|
+
base?: number;
|
|
115
|
+
/** Baseline component overrides */
|
|
116
|
+
baseline?: Partial<Config['baseline']>;
|
|
117
|
+
/** Guide component overrides */
|
|
118
|
+
guide?: Partial<Config['guide']>;
|
|
119
|
+
/** Spacer component overrides */
|
|
120
|
+
spacer?: Partial<Config['spacer']>;
|
|
121
|
+
/** Box component overrides */
|
|
122
|
+
box?: Partial<Config['box']>;
|
|
123
|
+
/** Stack component overrides */
|
|
124
|
+
stack?: Partial<Config['stack']>;
|
|
125
|
+
/** Layout component overrides */
|
|
126
|
+
layout?: Partial<Config['layout']>;
|
|
127
|
+
/** Padder component overrides */
|
|
128
|
+
padder?: Partial<Config['padder']>;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Merges parent config with overrides.
|
|
132
|
+
* Creates a new config object without mutating the parent.
|
|
133
|
+
*/
|
|
134
|
+
export declare const mergeConfig: (params: MergeConfigParams) => Config;
|
|
92
135
|
/**
|
|
93
136
|
* Configuration provider for baseline-kit components.
|
|
94
137
|
*
|
|
@@ -1,19 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
* @file Guide Component
|
|
3
|
-
* @description Visual grid overlay component for alignment and debugging
|
|
4
|
-
* @module components
|
|
5
|
-
*/
|
|
1
|
+
import * as React from 'react';
|
|
6
2
|
import { AutoConfig, FixedConfig, LineConfig, PatternConfig } from './types';
|
|
7
|
-
import type { ComponentsProps } from '../types';
|
|
3
|
+
import type { ComponentsProps, GuideVariant } from '../types';
|
|
8
4
|
/** Merged configuration types that support various grid layout strategies */
|
|
9
5
|
export type GuideConfig = PatternConfig | AutoConfig | FixedConfig | LineConfig;
|
|
10
6
|
export type GuideProps = {
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
/** Controls horizontal alignment of columns within the container */
|
|
8
|
+
align?: React.CSSProperties['justifyContent'];
|
|
9
|
+
/** Visual style of the guide */
|
|
10
|
+
variant?: GuideVariant;
|
|
11
|
+
/** Number of columns (for fixed/auto variants) */
|
|
12
|
+
columns?: number | readonly (string | number | undefined | 'auto')[];
|
|
13
|
+
/** Column width (for fixed variant) */
|
|
14
|
+
columnWidth?: React.CSSProperties['width'];
|
|
15
|
+
/** Gutter width between columns */
|
|
16
|
+
gutterWidth?: React.CSSProperties['width'];
|
|
17
|
+
/** Maximum width of the guide */
|
|
18
|
+
maxWidth?: React.CSSProperties['maxWidth'];
|
|
19
|
+
/** Color override for guide lines */
|
|
20
|
+
color?: React.CSSProperties['color'];
|
|
21
|
+
/** Content to render inside the guide */
|
|
22
|
+
children?: React.ReactNode;
|
|
23
|
+
/** Gap between columns */
|
|
24
|
+
gap?: number;
|
|
25
|
+
/** Flag to enable SSR-compatible mode (simplified initial render) */
|
|
26
|
+
ssrMode?: boolean;
|
|
27
|
+
} & ComponentsProps & Omit<GuideConfig, 'columns' | 'columnWidth' | 'gap'>;
|
|
28
|
+
/** Parameters for creating a grid configuration */
|
|
29
|
+
type GridConfigParams = {
|
|
30
|
+
variant: GuideVariant;
|
|
31
|
+
base: number;
|
|
32
|
+
gap: number;
|
|
33
|
+
columns?: number | readonly (string | number | undefined | 'auto')[];
|
|
34
|
+
columnWidth?: React.CSSProperties['width'];
|
|
35
|
+
};
|
|
36
|
+
/** Creates the appropriate grid configuration based on variant */
|
|
37
|
+
export declare const createGridConfig: (params: GridConfigParams) => (PatternConfig | AutoConfig | FixedConfig | LineConfig);
|
|
38
|
+
/** Creates default guide styles */
|
|
39
|
+
export declare const createDefaultGuideStyles: (base: number, lineColor: string) => Record<string, string>;
|
|
17
40
|
/**
|
|
18
41
|
* A developer tool component that provides visual grid overlays for alignment.
|
|
19
42
|
*
|
|
@@ -57,4 +80,5 @@ export type GuideProps = {
|
|
|
57
80
|
* />
|
|
58
81
|
* ```
|
|
59
82
|
*/
|
|
60
|
-
export declare const Guide:
|
|
83
|
+
export declare const Guide: React.NamedExoticComponent<GuideProps>;
|
|
84
|
+
export {};
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Layout Component
|
|
3
|
-
* @description Grid-based layout component with baseline alignment
|
|
4
|
-
* @module components
|
|
5
|
-
*/
|
|
6
1
|
import * as React from 'react';
|
|
7
|
-
import type { Gaps
|
|
2
|
+
import type { Gaps } from '@components';
|
|
3
|
+
import { Spacer } from '../Spacer';
|
|
8
4
|
import { ComponentsProps, Variant } from '../types';
|
|
5
|
+
type IndicatorNode = NonNullable<React.ComponentProps<typeof Spacer>['indicatorNode']>;
|
|
9
6
|
export type LayoutProps = {
|
|
10
7
|
/**
|
|
11
8
|
* Grid column definition. Supports:
|
|
@@ -28,8 +25,24 @@ export type LayoutProps = {
|
|
|
28
25
|
indicatorNode?: IndicatorNode;
|
|
29
26
|
/** Visual style in debug mode */
|
|
30
27
|
variant?: Variant;
|
|
28
|
+
/** Flag to enable SSR-compatible mode (simplified initial render) */
|
|
29
|
+
ssrMode?: boolean;
|
|
30
|
+
/** Container width (defaults to "auto") */
|
|
31
|
+
width?: React.CSSProperties['width'];
|
|
32
|
+
/** Container height (defaults to "auto") */
|
|
33
|
+
height?: React.CSSProperties['height'];
|
|
31
34
|
children?: React.ReactNode;
|
|
32
35
|
} & ComponentsProps & Gaps;
|
|
36
|
+
/** Creates default layout styles with theme colors */
|
|
37
|
+
export declare const createDefaultLayoutStyles: (colors: {
|
|
38
|
+
line: string;
|
|
39
|
+
flat: string;
|
|
40
|
+
text: string;
|
|
41
|
+
}) => Record<string, string>;
|
|
42
|
+
/** Parses grid template definitions into CSS grid-template values. */
|
|
43
|
+
export declare const getGridTemplate: (prop?: number | string | Array<number | string>) => string;
|
|
44
|
+
/** Creates grid gap styles */
|
|
45
|
+
export declare const createGridGapStyles: (gap?: React.CSSProperties["gap"] | number, rowGap?: React.CSSProperties["rowGap"] | number, columnGap?: React.CSSProperties["columnGap"] | number) => Record<string, string>;
|
|
33
46
|
/**
|
|
34
47
|
* A grid-based layout component with baseline alignment and responsive columns.
|
|
35
48
|
*
|
|
@@ -41,7 +54,7 @@ export type LayoutProps = {
|
|
|
41
54
|
* - Offers comprehensive alignment controls
|
|
42
55
|
* - Provides debug overlays for visual verification
|
|
43
56
|
*
|
|
44
|
-
* When no explicit dimensions are provided, Layout defaults to "
|
|
57
|
+
* When no explicit dimensions are provided, Layout defaults to "auto"
|
|
45
58
|
* for both width and height.
|
|
46
59
|
*
|
|
47
60
|
* @example
|
|
@@ -67,3 +80,4 @@ export type LayoutProps = {
|
|
|
67
80
|
* ```
|
|
68
81
|
*/
|
|
69
82
|
export declare const Layout: React.NamedExoticComponent<LayoutProps>;
|
|
83
|
+
export {};
|