baseline-kit 2.0.1 → 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 +126 -102
- package/dist/README.md +126 -102
- package/dist/components/Baseline/Baseline.d.ts +27 -5
- package/dist/components/Box/Box.d.ts +26 -5
- package/dist/components/Config/Config.d.ts +51 -8
- package/dist/components/Guide/Guide.d.ts +35 -12
- package/dist/components/Layout/Layout.d.ts +20 -6
- package/dist/components/Padder/Padder.d.ts +24 -7
- package/dist/components/Spacer/Spacer.d.ts +44 -11
- package/dist/components/Stack/Stack.d.ts +24 -8
- package/dist/components/types.d.ts +1 -1
- package/dist/hooks/useBaseline.d.ts +13 -18
- 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/useVirtual.d.ts +0 -5
- package/dist/index.cjs +11 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1447 -1038
- 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 +0 -5
- 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'
|
|
@@ -97,13 +105,6 @@ unit:
|
|
|
97
105
|
>
|
|
98
106
|
{/* Content automatically aligned to the 8px grid */}
|
|
99
107
|
</Layout>
|
|
100
|
-
|
|
101
|
-
<Stack
|
|
102
|
-
block={[17, 25]} // Top: 16px, Bottom: 24px
|
|
103
|
-
inline={22} // Left/Right: 24px
|
|
104
|
-
>
|
|
105
|
-
{/* Padding automatically adjusted to base unit multiples */}
|
|
106
|
-
</Stack>
|
|
107
108
|
</Config>
|
|
108
109
|
```
|
|
109
110
|
|
|
@@ -113,7 +114,7 @@ Spacing props (`block`, `inline`, `gap`) accept values in three formats:
|
|
|
113
114
|
|
|
114
115
|
```
|
|
115
116
|
// Single number (applies to both sides)
|
|
116
|
-
block={
|
|
117
|
+
block={16} // 16px top and bottom
|
|
117
118
|
|
|
118
119
|
// Array [start, end]
|
|
119
120
|
block={[2, 3]} // 2px top, 3px bottom
|
|
@@ -159,128 +160,172 @@ debugging = "none" // Removes debug elements entirely
|
|
|
159
160
|
#### 3. Configuration
|
|
160
161
|
|
|
161
162
|
- **`Config`** Theme and settings provider
|
|
162
|
-
- **`Padder`** Internal spacing utility
|
|
163
163
|
|
|
164
|
-
###
|
|
164
|
+
### Key Components
|
|
165
165
|
|
|
166
|
-
|
|
166
|
+
#### Config
|
|
167
167
|
|
|
168
168
|
```tsx
|
|
169
169
|
<Config
|
|
170
170
|
base={8} // Base unit for calculations
|
|
171
171
|
baseline={{ debugging }} // Baseline grid visibility
|
|
172
|
-
guide={{
|
|
173
|
-
debugging,
|
|
174
|
-
colors: {
|
|
175
|
-
line: 'rgba(0,0,255,0.1)'
|
|
176
|
-
}
|
|
177
|
-
}}
|
|
172
|
+
guide={{ debugging }} // Guide customization
|
|
178
173
|
>
|
|
179
174
|
{children}
|
|
180
175
|
</Config>
|
|
181
176
|
```
|
|
182
177
|
|
|
183
|
-
|
|
178
|
+
#### Baseline
|
|
184
179
|
|
|
185
180
|
```tsx
|
|
186
181
|
<Baseline
|
|
187
|
-
base={8} // Base unit (defaults to Config value)
|
|
188
182
|
height="100vh" // Overlay height
|
|
189
183
|
variant="line" // "line" or "flat"
|
|
190
184
|
debugging="visible" // Show the grid overlay
|
|
191
185
|
/>
|
|
192
186
|
```
|
|
193
187
|
|
|
194
|
-
|
|
188
|
+
#### Guide
|
|
195
189
|
|
|
196
190
|
```tsx
|
|
197
191
|
<Guide
|
|
198
|
-
variant="pattern"
|
|
199
|
-
columns={['100px', '1fr', '100px']}
|
|
200
|
-
gap={8}
|
|
201
|
-
|
|
202
|
-
width="1200px" // Container width
|
|
203
|
-
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
|
|
204
196
|
/>
|
|
205
197
|
```
|
|
206
198
|
|
|
207
|
-
|
|
199
|
+
#### Box
|
|
208
200
|
|
|
209
201
|
```tsx
|
|
210
202
|
<Box
|
|
211
|
-
block={[2, 5]} // Vertical padding in base units
|
|
203
|
+
block={[2, 5]} // Vertical padding in base units
|
|
212
204
|
span={2} // Grid column span when used in Layout
|
|
213
205
|
snapping="height" // "none", "height", or "clamp"
|
|
214
|
-
debugging="visible" // Show alignment guides
|
|
215
206
|
>
|
|
216
207
|
<p>Content aligned to baseline grid</p>
|
|
217
208
|
</Box>
|
|
218
209
|
```
|
|
219
210
|
|
|
220
|
-
|
|
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
|
|
221
223
|
|
|
222
224
|
```tsx
|
|
223
|
-
|
|
224
|
-
direction="column" // "row" or "column"
|
|
225
|
-
block={[8, 24]} // Vertical padding (auto-snapping)
|
|
226
|
-
inline={16} // Horizontal padding (auto-snapping)
|
|
227
|
-
gap={16} // Gap value
|
|
228
|
-
justify="center" // Flex justify-content
|
|
229
|
-
align="center" // Flex align-items
|
|
230
|
-
debugging="visible" // Show alignment guides
|
|
231
|
-
>
|
|
232
|
-
<Box>Item 1</Box>
|
|
233
|
-
<Box>Item 2</Box>
|
|
234
|
-
</Stack>
|
|
225
|
+
import 'baseline-kit/theme'; // Default theme with light/dark mode support
|
|
235
226
|
```
|
|
236
227
|
|
|
237
|
-
|
|
228
|
+
#### 2. Create a Custom Theme
|
|
238
229
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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
|
+
}
|
|
250
247
|
```
|
|
251
248
|
|
|
252
|
-
|
|
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
|
+
```
|
|
253
255
|
|
|
254
|
-
|
|
256
|
+
#### 3. Override via Config
|
|
255
257
|
|
|
256
|
-
|
|
258
|
+
For minor adjustments, use the Config component:
|
|
257
259
|
|
|
258
260
|
```tsx
|
|
259
261
|
<Config
|
|
260
|
-
base={8}
|
|
261
|
-
guide={{
|
|
262
|
-
colors: {
|
|
263
|
-
line: 'rgba(0,0,255,0.1)',
|
|
264
|
-
pattern: 'rgba(0,0,255,0.05)',
|
|
265
|
-
auto: 'rgba(0,0,255,0.05)',
|
|
266
|
-
fixed: 'rgba(0,0,255,0.05)'
|
|
267
|
-
}
|
|
268
|
-
}}
|
|
269
262
|
baseline={{
|
|
270
263
|
colors: {
|
|
271
|
-
line: 'rgba(255,0,0,0.1)',
|
|
272
|
-
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
|
|
273
266
|
}
|
|
274
267
|
}}
|
|
275
268
|
>
|
|
276
|
-
{
|
|
269
|
+
{/* Your components here */}
|
|
277
270
|
</Config>
|
|
278
271
|
```
|
|
279
272
|
|
|
280
|
-
|
|
281
|
-
through CSS media queries. No additional configuration is required.
|
|
273
|
+
### Theme Variables Reference
|
|
282
274
|
|
|
283
|
-
|
|
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
|
|
284
329
|
|
|
285
330
|
```shell
|
|
286
331
|
# Clone the repository
|
|
@@ -294,38 +339,17 @@ bun run dev
|
|
|
294
339
|
|
|
295
340
|
# Run tests
|
|
296
341
|
bun run test
|
|
297
|
-
|
|
298
|
-
# Build package
|
|
299
|
-
bun run build
|
|
300
342
|
```
|
|
301
343
|
|
|
302
|
-
##
|
|
344
|
+
## Performance Features
|
|
303
345
|
|
|
304
|
-
Baseline Kit is compatible with SSR frameworks like Next.js and Gatsby. The overlay components automatically handle
|
|
305
|
-
hydration mismatches.
|
|
306
|
-
|
|
307
|
-
## Browser Support
|
|
308
|
-
|
|
309
|
-
- Modern browsers (Chrome, Firefox, Safari, Edge)
|
|
310
|
-
- Requires CSS Grid Layout support
|
|
311
|
-
- Requires CSS Custom Properties (CSS Variables)
|
|
312
|
-
- Falls back gracefully in unsupported browsers
|
|
313
|
-
|
|
314
|
-
## Performance Considerations
|
|
315
|
-
|
|
316
|
-
- Uses requestAnimationFrame for smooth animations
|
|
317
346
|
- Virtualizes large grid overlays
|
|
318
347
|
- Optimizes re-renders using React.memo
|
|
319
348
|
- Supports tree-shaking for minimal bundle size
|
|
320
349
|
|
|
321
350
|
## Contributing
|
|
322
351
|
|
|
323
|
-
Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for detailed guidelines
|
|
324
|
-
|
|
325
|
-
- Development setup
|
|
326
|
-
- Code style
|
|
327
|
-
- Testing requirements
|
|
328
|
-
- Pull request process
|
|
352
|
+
Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for detailed guidelines.
|
|
329
353
|
|
|
330
354
|
## License
|
|
331
355
|
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Baseline Component
|
|
3
|
-
* @description Horizontal grid overlay for baseline alignment
|
|
4
|
-
* @module components
|
|
5
|
-
*/
|
|
6
1
|
import * as React from 'react';
|
|
7
2
|
import { ComponentsProps } from '@components';
|
|
8
3
|
import { Variant } from '../types';
|
|
@@ -16,7 +11,33 @@ export type BaselineProps = {
|
|
|
16
11
|
height?: number | string;
|
|
17
12
|
/** Base unit for measurements (defaults to theme value) */
|
|
18
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;
|
|
19
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;
|
|
20
41
|
/**
|
|
21
42
|
* Renders horizontal guidelines for maintaining vertical rhythm and baseline alignment.
|
|
22
43
|
*
|
|
@@ -47,3 +68,4 @@ export type BaselineProps = {
|
|
|
47
68
|
* ```
|
|
48
69
|
*/
|
|
49
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
|
*
|
|
@@ -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.
|
|
@@ -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,20 +1,42 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Guide Component
|
|
3
|
-
* @description Visual grid overlay component for alignment and debugging
|
|
4
|
-
* @module components
|
|
5
|
-
*/
|
|
6
1
|
import * as React from 'react';
|
|
7
2
|
import { AutoConfig, FixedConfig, LineConfig, PatternConfig } from './types';
|
|
8
|
-
import type { ComponentsProps } from '../types';
|
|
3
|
+
import type { ComponentsProps, GuideVariant } from '../types';
|
|
9
4
|
/** Merged configuration types that support various grid layout strategies */
|
|
10
5
|
export type GuideConfig = PatternConfig | AutoConfig | FixedConfig | LineConfig;
|
|
11
6
|
export type GuideProps = {
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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>;
|
|
18
40
|
/**
|
|
19
41
|
* A developer tool component that provides visual grid overlays for alignment.
|
|
20
42
|
*
|
|
@@ -59,3 +81,4 @@ export type GuideProps = {
|
|
|
59
81
|
* ```
|
|
60
82
|
*/
|
|
61
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
|
*
|
|
@@ -67,3 +80,4 @@ export type LayoutProps = {
|
|
|
67
80
|
* ```
|
|
68
81
|
*/
|
|
69
82
|
export declare const Layout: React.NamedExoticComponent<LayoutProps>;
|
|
83
|
+
export {};
|
|
@@ -1,10 +1,24 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Padder Component
|
|
3
|
-
* @description Low-level padding management with visual debugging
|
|
4
|
-
* @module components
|
|
5
|
-
*/
|
|
6
1
|
import * as React from 'react';
|
|
2
|
+
import { Variant } from '../types';
|
|
7
3
|
import { IndicatorNode } from '../Spacer';
|
|
4
|
+
import { DebuggingMode } from '@/components';
|
|
5
|
+
type RenderSpacerFn = (width: React.CSSProperties['width'], height: React.CSSProperties['height']) => React.ReactNode;
|
|
6
|
+
type PaddingStyles = {
|
|
7
|
+
paddingBlock?: string;
|
|
8
|
+
paddingInline?: string;
|
|
9
|
+
[key: string]: string | undefined;
|
|
10
|
+
};
|
|
11
|
+
/** Creates default container styles for Padder */
|
|
12
|
+
export declare const createPadderContainerStyles: (width: React.CSSProperties["width"], height: React.CSSProperties["height"], base: number, color: string) => Record<string, string>;
|
|
13
|
+
/** Creates padding styles when spacers are disabled */
|
|
14
|
+
export declare const createDirectPaddingStyles: (enableSpacers: boolean, padding: {
|
|
15
|
+
top: number;
|
|
16
|
+
right: number;
|
|
17
|
+
bottom: number;
|
|
18
|
+
left: number;
|
|
19
|
+
}) => PaddingStyles;
|
|
20
|
+
/** Creates a render function for spacers */
|
|
21
|
+
export declare const createRenderSpacerFn: (variant: Variant | undefined, debugging: DebuggingMode | undefined, indicatorNode?: IndicatorNode) => RenderSpacerFn;
|
|
8
22
|
/**
|
|
9
23
|
* A foundational component that manages consistent padding with visual debugging.
|
|
10
24
|
*
|
|
@@ -51,11 +65,14 @@ import { IndicatorNode } from '../Spacer';
|
|
|
51
65
|
export declare const Padder: React.NamedExoticComponent<{
|
|
52
66
|
/** Render function for custom measurement indicators */
|
|
53
67
|
indicatorNode?: IndicatorNode;
|
|
68
|
+
/** Flag to enable SSR-compatible mode (simplified initial render) */
|
|
69
|
+
ssrMode?: boolean;
|
|
54
70
|
children?: React.ReactNode;
|
|
55
71
|
} & {
|
|
56
|
-
debugging?:
|
|
72
|
+
debugging?: DebuggingMode;
|
|
57
73
|
className?: string;
|
|
58
74
|
style?: React.CSSProperties;
|
|
59
75
|
height?: React.CSSProperties["height"];
|
|
60
76
|
width?: React.CSSProperties["width"];
|
|
61
|
-
} & import("
|
|
77
|
+
} & import("@/components").SpacingProps & React.RefAttributes<HTMLDivElement>>;
|
|
78
|
+
export {};
|