baseline-kit 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +334 -0
- package/dist/README.md +334 -0
- package/dist/components/Baseline/Baseline.d.ts +48 -0
- package/dist/components/Baseline/index.d.ts +6 -0
- package/dist/components/Box/Box.d.ts +62 -0
- package/dist/components/Box/index.d.ts +6 -0
- package/dist/components/Config/Config.d.ts +136 -0
- package/dist/components/Config/defaults.d.ts +25 -0
- package/dist/components/Config/index.d.ts +11 -0
- package/dist/components/Guide/Guide.d.ts +60 -0
- package/dist/components/Guide/index.d.ts +12 -0
- package/dist/components/Guide/types.d.ts +144 -0
- package/dist/components/Guide/validation.d.ts +82 -0
- package/dist/components/Layout/Layout.d.ts +69 -0
- package/dist/components/Layout/index.d.ts +10 -0
- package/dist/components/Padder/Padder.d.ts +61 -0
- package/dist/components/Padder/index.d.ts +10 -0
- package/dist/components/Spacer/Spacer.d.ts +55 -0
- package/dist/components/Spacer/index.d.ts +10 -0
- package/dist/components/Stack/Stack.d.ts +77 -0
- package/dist/components/Stack/index.d.ts +10 -0
- package/dist/components/index.d.ts +15 -0
- package/dist/components/types.d.ts +102 -0
- package/dist/hooks/index.d.ts +11 -0
- package/dist/hooks/useBaseline.d.ts +72 -0
- package/dist/hooks/useConfig.d.ts +46 -0
- package/dist/hooks/useDebug.d.ts +54 -0
- package/dist/hooks/useGuide.d.ts +66 -0
- package/dist/hooks/useMeasure.d.ts +49 -0
- package/dist/hooks/useVirtual.d.ts +65 -0
- package/dist/index.cjs +32 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.mjs +1592 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles.css +1 -0
- package/dist/utils/convert.d.ts +46 -0
- package/dist/utils/index.d.ts +13 -0
- package/dist/utils/math.d.ts +64 -0
- package/dist/utils/merge.d.ts +68 -0
- package/dist/utils/normalize.d.ts +65 -0
- package/dist/utils/padding.d.ts +11 -0
- package/dist/utils/parse.d.ts +52 -0
- package/dist/utils/snapping.d.ts +33 -0
- package/dist/utils/timing.d.ts +50 -0
- package/package.json +113 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Baseline Component
|
|
3
|
+
* @description Horizontal grid overlay for baseline alignment
|
|
4
|
+
* @module components
|
|
5
|
+
*/
|
|
6
|
+
import { ComponentsProps } from '@components';
|
|
7
|
+
import { Variant } from '../types';
|
|
8
|
+
export type BaselineVariant = Exclude<Variant, 'pattern'>;
|
|
9
|
+
export type BaselineProps = {
|
|
10
|
+
/** Visual style variant for the baseline guides */
|
|
11
|
+
variant?: BaselineVariant;
|
|
12
|
+
/** Explicit width for the overlay (e.g., "1200px" or 1200) */
|
|
13
|
+
width?: number | string;
|
|
14
|
+
/** Explicit height for the overlay (e.g., "100vh" or 800) */
|
|
15
|
+
height?: number | string;
|
|
16
|
+
/** Base unit for measurements (defaults to theme value) */
|
|
17
|
+
base?: number;
|
|
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: import("react").NamedExoticComponent<BaselineProps>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Box Component
|
|
3
|
+
* @description A fundamental layout container with baseline grid alignment
|
|
4
|
+
* @module components
|
|
5
|
+
*/
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
/**
|
|
8
|
+
* Determines how the Box component aligns to the baseline grid.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* - `none`: No snapping; uses raw spacing values as provided
|
|
12
|
+
* - `height`: Only container height snaps to base unit multiples
|
|
13
|
+
* - `clamp`: Both height and spacing values snap to base unit multiples
|
|
14
|
+
*/
|
|
15
|
+
export type SnappingMode = 'none' | 'height' | 'clamp';
|
|
16
|
+
/**
|
|
17
|
+
* A foundational container component that ensures consistent spacing and baseline alignment.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* Box provides a layout container that:
|
|
21
|
+
* - Ensures consistent spacing aligned to the baseline grid
|
|
22
|
+
* - Supports grid layout integration through span props
|
|
23
|
+
* - Offers configurable snapping modes for fine-grained alignment control
|
|
24
|
+
* - Includes debug overlays for visual alignment verification
|
|
25
|
+
*
|
|
26
|
+
* By default, Box uses "fit-content" for both width and height unless explicitly specified.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* // Basic usage with spacing
|
|
31
|
+
* <Box block={16} inline={8}>
|
|
32
|
+
* <p>Content aligned to baseline</p>
|
|
33
|
+
* </Box>
|
|
34
|
+
*
|
|
35
|
+
* // With grid spanning and custom snapping
|
|
36
|
+
* <Box
|
|
37
|
+
* colSpan={2}
|
|
38
|
+
* rowSpan={1}
|
|
39
|
+
* snapping="height"
|
|
40
|
+
* debugging="visible"
|
|
41
|
+
* >
|
|
42
|
+
* <p>Grid-integrated content</p>
|
|
43
|
+
* </Box>
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare const Box: React.NamedExoticComponent<{
|
|
47
|
+
/** Number of columns to span in a grid layout */
|
|
48
|
+
colSpan?: number;
|
|
49
|
+
/** Number of rows to span in a grid layout */
|
|
50
|
+
rowSpan?: number;
|
|
51
|
+
/** Shorthand for equal column and row span. Takes precedence over individual spans */
|
|
52
|
+
span?: number;
|
|
53
|
+
/** Controls baseline grid alignment behavior */
|
|
54
|
+
snapping?: SnappingMode;
|
|
55
|
+
children?: React.ReactNode;
|
|
56
|
+
} & {
|
|
57
|
+
debugging?: import("..").DebuggingMode;
|
|
58
|
+
className?: string;
|
|
59
|
+
style?: React.CSSProperties;
|
|
60
|
+
height?: React.CSSProperties["height"];
|
|
61
|
+
width?: React.CSSProperties["width"];
|
|
62
|
+
} & import("..").SpacingProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Config Component
|
|
3
|
+
* @description Theme and configuration provider for baseline-kit components
|
|
4
|
+
* @module components
|
|
5
|
+
*/
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import { BaselineVariant } from '@components';
|
|
8
|
+
import type { GuideVariant, Variant } from '../types';
|
|
9
|
+
/**
|
|
10
|
+
* Controls component debugging visibility and behavior.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* - `none`: Debug features are fully disabled
|
|
14
|
+
* - `hidden`: Debug elements exist in DOM but are not visible
|
|
15
|
+
* - `visible`: Debug elements are fully rendered and visible
|
|
16
|
+
*/
|
|
17
|
+
export type DebuggingMode = 'none' | 'hidden' | 'visible';
|
|
18
|
+
/** Color configuration for component themes. */
|
|
19
|
+
type Colors = {
|
|
20
|
+
/** Color for line-based visuals */
|
|
21
|
+
line: string;
|
|
22
|
+
/** Color for flat surface visuals */
|
|
23
|
+
flat: string;
|
|
24
|
+
/** Color for measurement indicators */
|
|
25
|
+
indice: string;
|
|
26
|
+
};
|
|
27
|
+
/** Complete configuration schema for baseline-kit. */
|
|
28
|
+
export type Config = {
|
|
29
|
+
/** Base unit for spacing calculations */
|
|
30
|
+
base: number;
|
|
31
|
+
/** Guide component configuration */
|
|
32
|
+
guide: {
|
|
33
|
+
variant: GuideVariant;
|
|
34
|
+
debugging: DebuggingMode;
|
|
35
|
+
colors: Record<GuideVariant, string>;
|
|
36
|
+
};
|
|
37
|
+
/** Baseline component configuration */
|
|
38
|
+
baseline: {
|
|
39
|
+
variant: BaselineVariant;
|
|
40
|
+
debugging: DebuggingMode;
|
|
41
|
+
colors: Record<BaselineVariant, string>;
|
|
42
|
+
};
|
|
43
|
+
/** Stack component configuration */
|
|
44
|
+
stack: {
|
|
45
|
+
colors: Colors;
|
|
46
|
+
debugging: DebuggingMode;
|
|
47
|
+
};
|
|
48
|
+
/** Layout component configuration */
|
|
49
|
+
layout: {
|
|
50
|
+
colors: Colors;
|
|
51
|
+
debugging: DebuggingMode;
|
|
52
|
+
};
|
|
53
|
+
/** Spacer component configuration */
|
|
54
|
+
spacer: {
|
|
55
|
+
variant: Variant;
|
|
56
|
+
debugging: DebuggingMode;
|
|
57
|
+
colors: Colors;
|
|
58
|
+
};
|
|
59
|
+
/** Box component configuration */
|
|
60
|
+
box: {
|
|
61
|
+
colors: Colors;
|
|
62
|
+
debugging: DebuggingMode;
|
|
63
|
+
};
|
|
64
|
+
/** Padder component configuration */
|
|
65
|
+
padder: {
|
|
66
|
+
color: string;
|
|
67
|
+
debugging: DebuggingMode;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export declare const useDefaultConfig: () => Config;
|
|
71
|
+
type ConfigProps = {
|
|
72
|
+
children: React.ReactNode;
|
|
73
|
+
/** Base unit for spacing calculations */
|
|
74
|
+
base?: number;
|
|
75
|
+
/** Baseline component overrides */
|
|
76
|
+
baseline?: Partial<Config['baseline']>;
|
|
77
|
+
/** Flex component overrides */
|
|
78
|
+
stack?: Partial<Config['stack']>;
|
|
79
|
+
/** Layout component overrides */
|
|
80
|
+
layout?: Partial<Config['layout']>;
|
|
81
|
+
/** Guide component overrides */
|
|
82
|
+
guide?: Partial<Config['guide']>;
|
|
83
|
+
/** Spacer component overrides */
|
|
84
|
+
spacer?: Partial<Config['spacer']>;
|
|
85
|
+
/** Box component overrides */
|
|
86
|
+
box?: Partial<Config['box']>;
|
|
87
|
+
/** Padder component overrides */
|
|
88
|
+
padder?: Partial<Config['padder']>;
|
|
89
|
+
};
|
|
90
|
+
/** Creates CSS variables from the configuration object. */
|
|
91
|
+
export declare const createCSSVariables: ({ base, baseline, guide, stack, spacer, layout, box, padder, }: Config) => Record<string, string>;
|
|
92
|
+
/**
|
|
93
|
+
* Configuration provider for baseline-kit components.
|
|
94
|
+
*
|
|
95
|
+
* @remarks
|
|
96
|
+
* Config provides theme and debugging settings to all nested components.
|
|
97
|
+
* It allows for:
|
|
98
|
+
* - Global base unit configuration
|
|
99
|
+
* - Component-specific color themes
|
|
100
|
+
* - Debug mode control
|
|
101
|
+
* - Visual style customization
|
|
102
|
+
*
|
|
103
|
+
* Configs can be nested to override settings for specific sections.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```tsx
|
|
107
|
+
* // Basic global configuration
|
|
108
|
+
* <Config base={8}>
|
|
109
|
+
* <App />
|
|
110
|
+
* </Config>
|
|
111
|
+
*
|
|
112
|
+
* // Component-specific overrides
|
|
113
|
+
* <Config
|
|
114
|
+
* base={8}
|
|
115
|
+
* guide={{
|
|
116
|
+
* debugging: "visible",
|
|
117
|
+
* colors: {
|
|
118
|
+
* line: "rgba(255,0,0,0.2)",
|
|
119
|
+
* pattern: "rgba(0,0,255,0.2)"
|
|
120
|
+
* }
|
|
121
|
+
* }}
|
|
122
|
+
* >
|
|
123
|
+
* <Layout>...</Layout>
|
|
124
|
+
* </Config>
|
|
125
|
+
*
|
|
126
|
+
* // Nested configurations
|
|
127
|
+
* <Config base={8}>
|
|
128
|
+
* <div>Uses 8px base</div>
|
|
129
|
+
* <Config base={4}>
|
|
130
|
+
* <div>Uses 4px base</div>
|
|
131
|
+
* </Config>
|
|
132
|
+
* </Config>
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
export declare function Config({ children, base, stack, baseline, guide, layout, spacer, box, padder, }: ConfigProps): import("react/jsx-runtime").JSX.Element;
|
|
136
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file defaults.ts
|
|
3
|
+
* @description Default theme and configuration values for baseline-kit
|
|
4
|
+
* @module baseline-kit/components/Config
|
|
5
|
+
*/
|
|
6
|
+
import type { Config } from './Config';
|
|
7
|
+
/**
|
|
8
|
+
* Default configuration for baseline-kit.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Provides the base configuration for all components including:
|
|
12
|
+
* - Base unit for spacing calculations (8px default)
|
|
13
|
+
* - Default component variants
|
|
14
|
+
* - Initial debugging modes
|
|
15
|
+
* - Theme color assignments
|
|
16
|
+
*
|
|
17
|
+
* Each component section includes:
|
|
18
|
+
* - Visual variant selection (where applicable)
|
|
19
|
+
* - Debugging mode setting
|
|
20
|
+
* - Color theme assignments
|
|
21
|
+
*
|
|
22
|
+
* The configuration is marked as const to ensure type safety
|
|
23
|
+
* and prevent accidental modifications.
|
|
24
|
+
*/
|
|
25
|
+
export declare const DEFAULT_CONFIG: Config;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Config Component Entry (components/Config/index.ts)
|
|
3
|
+
* @description Theme and configuration provider
|
|
4
|
+
* @module baseline-kit/components/Config
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Central configuration system for baseline-kit, managing
|
|
8
|
+
* theme values and default settings.
|
|
9
|
+
*/
|
|
10
|
+
export * from './Config';
|
|
11
|
+
export * from './defaults';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Guide Component
|
|
3
|
+
* @description Visual grid overlay component for alignment and debugging
|
|
4
|
+
* @module components
|
|
5
|
+
*/
|
|
6
|
+
import { AutoConfig, FixedConfig, LineConfig, PatternConfig } from './types';
|
|
7
|
+
import type { ComponentsProps } from '../types';
|
|
8
|
+
/** Merged configuration types that support various grid layout strategies */
|
|
9
|
+
export type GuideConfig = PatternConfig | AutoConfig | FixedConfig | LineConfig;
|
|
10
|
+
export type GuideProps = {
|
|
11
|
+
/**
|
|
12
|
+
* Controls horizontal alignment of columns within the container.
|
|
13
|
+
* @default "start"
|
|
14
|
+
*/
|
|
15
|
+
align?: 'start' | 'center' | 'end';
|
|
16
|
+
} & ComponentsProps & GuideConfig;
|
|
17
|
+
/**
|
|
18
|
+
* A developer tool component that provides visual grid overlays for alignment.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* Guide renders a configurable grid overlay that helps visualize:
|
|
22
|
+
* - Column layouts and spacing
|
|
23
|
+
* - Content alignment
|
|
24
|
+
* - Layout patterns
|
|
25
|
+
*
|
|
26
|
+
* The component supports multiple variants:
|
|
27
|
+
* - "line": Simple evenly-spaced vertical lines
|
|
28
|
+
* - "pattern": Custom repeating column width patterns
|
|
29
|
+
* - "fixed": Fixed number of equal or custom-width columns
|
|
30
|
+
* - "auto": Dynamically calculated columns based on container width
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* // Basic column guide
|
|
35
|
+
* <Guide
|
|
36
|
+
* variant="line"
|
|
37
|
+
* gap={8}
|
|
38
|
+
* debugging="visible"
|
|
39
|
+
* />
|
|
40
|
+
*
|
|
41
|
+
* // Custom column pattern
|
|
42
|
+
* <Guide
|
|
43
|
+
* variant="pattern"
|
|
44
|
+
* columns={['100px', '1fr', '2fr']}
|
|
45
|
+
* gap={16}
|
|
46
|
+
* align="center"
|
|
47
|
+
* debugging="visible"
|
|
48
|
+
* />
|
|
49
|
+
*
|
|
50
|
+
* // Fixed columns with custom width
|
|
51
|
+
* <Guide
|
|
52
|
+
* variant="fixed"
|
|
53
|
+
* columns={12}
|
|
54
|
+
* columnWidth="60px"
|
|
55
|
+
* gap={8}
|
|
56
|
+
* debugging="visible"
|
|
57
|
+
* />
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare const Guide: import("react").NamedExoticComponent<GuideProps>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Guide Component Entry (components/Guide/index.ts)
|
|
3
|
+
* @description Visual grid overlay system for alignment
|
|
4
|
+
* @module baseline-kit/components/Guide
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Provides visual grid overlays for layout alignment with
|
|
8
|
+
* multiple grid strategies and validation.
|
|
9
|
+
*/
|
|
10
|
+
export * from './Guide';
|
|
11
|
+
export * from './types';
|
|
12
|
+
export * from './validation';
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file types.ts
|
|
3
|
+
* @description Type definitions for Guide component configurations
|
|
4
|
+
* @module baseline-kit/components/Guide/types
|
|
5
|
+
*/
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import { GuideColumnsPattern } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Base configuration shared by all guide variants.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const baseConfig: BaseGuideConfig = {
|
|
14
|
+
* gap: 2, // 2px gap
|
|
15
|
+
* base: 8 // 8px base unit
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
type BaseGuideConfig = {
|
|
20
|
+
/** Gap between columnms. */
|
|
21
|
+
gap?: React.CSSProperties['gap'];
|
|
22
|
+
/**
|
|
23
|
+
* Base unit in pixels for spacing calculations.
|
|
24
|
+
* Typically inherited from theme configuration.
|
|
25
|
+
*/
|
|
26
|
+
base?: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Pattern-based grid configuration.
|
|
30
|
+
* Defines repeating column width patterns.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* // Three-column pattern: 100px | 200px | 100px
|
|
35
|
+
* const pattern: PatternConfig = {
|
|
36
|
+
* variant: 'pattern',
|
|
37
|
+
* columns: [100, '200px', '1fr'],
|
|
38
|
+
* gap: 2
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* // Responsive pattern with mixed units
|
|
42
|
+
* const responsive: PatternConfig = {
|
|
43
|
+
* variant: 'pattern',
|
|
44
|
+
* columns: ['20%', '1fr', '200px'],
|
|
45
|
+
* gap: 2
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export type PatternConfig = BaseGuideConfig & {
|
|
50
|
+
/** Identifies this as a pattern-based configuration */
|
|
51
|
+
variant: 'pattern';
|
|
52
|
+
/** Array of column widths that repeat */
|
|
53
|
+
columns: GuideColumnsPattern;
|
|
54
|
+
/** Not applicable in pattern mode */
|
|
55
|
+
columnWidth?: never;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Fixed-column grid configuration.
|
|
59
|
+
* Specifies exact number of equal-width columns.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* // Basic 12-column grid
|
|
64
|
+
* const grid: FixedConfig = {
|
|
65
|
+
* variant: 'fixed',
|
|
66
|
+
* columns: 12,
|
|
67
|
+
* gap: 2
|
|
68
|
+
* }
|
|
69
|
+
*
|
|
70
|
+
* // Fixed-width columns
|
|
71
|
+
* const fixed: FixedConfig = {
|
|
72
|
+
* variant: 'fixed',
|
|
73
|
+
* columns: 6,
|
|
74
|
+
* columnWidth: '160px',
|
|
75
|
+
* gap: 2
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export type FixedConfig = BaseGuideConfig & {
|
|
80
|
+
/** Identifies this as a fixed-column configuration */
|
|
81
|
+
variant: 'fixed';
|
|
82
|
+
/** Number of columns to create */
|
|
83
|
+
columns: number;
|
|
84
|
+
/** Optional fixed width for all columns */
|
|
85
|
+
columnWidth?: React.CSSProperties['width'];
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Auto-calculated grid configuration.
|
|
89
|
+
* Creates as many columns as will fit given a column width.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* // Auto-fit columns of 200px
|
|
94
|
+
* const auto: AutoConfig = {
|
|
95
|
+
* variant: 'auto',
|
|
96
|
+
* columnWidth: '200px',
|
|
97
|
+
* gap: 2
|
|
98
|
+
* }
|
|
99
|
+
*
|
|
100
|
+
* // Responsive columns with minimum width
|
|
101
|
+
* const responsive: AutoConfig = {
|
|
102
|
+
* variant: 'auto',
|
|
103
|
+
* columnWidth: 'minmax(200px, 1fr)',
|
|
104
|
+
* gap: 2
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
export type AutoConfig = BaseGuideConfig & {
|
|
109
|
+
/** Identifies this as an auto-calculated configuration */
|
|
110
|
+
variant: 'auto';
|
|
111
|
+
/** Desired width for each column */
|
|
112
|
+
columnWidth: React.CSSProperties['columnWidth'];
|
|
113
|
+
/** Not applicable in auto mode */
|
|
114
|
+
columns?: never;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Simple line-based guide configuration.
|
|
118
|
+
* Creates evenly-spaced vertical lines.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```ts
|
|
122
|
+
* // Basic line guide
|
|
123
|
+
* const lines: LineConfig = {
|
|
124
|
+
* variant: 'line',
|
|
125
|
+
* gap: 1
|
|
126
|
+
* }
|
|
127
|
+
*
|
|
128
|
+
* // Custom-spaced lines
|
|
129
|
+
* const wideLines: LineConfig = {
|
|
130
|
+
* variant: 'line',
|
|
131
|
+
* gap: 4,
|
|
132
|
+
* base: 8
|
|
133
|
+
* }
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
export type LineConfig = BaseGuideConfig & {
|
|
137
|
+
/** Optional variant identifier (defaults to 'line') */
|
|
138
|
+
variant?: 'line';
|
|
139
|
+
/** Not applicable in line mode */
|
|
140
|
+
columns?: never;
|
|
141
|
+
/** Not applicable in line mode */
|
|
142
|
+
columnWidth?: never;
|
|
143
|
+
};
|
|
144
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file validation.ts
|
|
3
|
+
* @description Validation utilities for Guide component configurations
|
|
4
|
+
* @module baseline-kit/components/Guide/validation
|
|
5
|
+
*/
|
|
6
|
+
import { GridAlignment, GuideColumnsPattern, GuideColumnValue, GuideConfig } from '@components';
|
|
7
|
+
/**
|
|
8
|
+
* Validates individual grid column values.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* isValidGuideColumnValue(100) // true
|
|
13
|
+
* isValidGuideColumnValue('100px') // true
|
|
14
|
+
* isValidGuideColumnValue('auto') // true
|
|
15
|
+
* isValidGuideColumnValue('foo') // false
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare const isValidGuideColumnValue: (value: unknown) => value is GuideColumnValue;
|
|
19
|
+
/**
|
|
20
|
+
* Validates an array of column values as a grid pattern.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* isValidGuidePattern(['100px', '1fr']) // true
|
|
25
|
+
* isValidGuidePattern([100, 200]) // true
|
|
26
|
+
* isValidGuidePattern(['invalid']) // false
|
|
27
|
+
* isValidGuidePattern([]) // false
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare const isValidGuidePattern: (pattern: unknown) => pattern is GuideColumnsPattern;
|
|
31
|
+
/**
|
|
32
|
+
* Validates CSS grid values against supported units.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* isGuideValue('100px') // true
|
|
37
|
+
* isGuideValue('2rem') // true
|
|
38
|
+
* isGuideValue('foo') // false
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare const isGuideValue: (value: unknown) => boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Validates grid alignment values.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* isGuideAlignment('start') // true
|
|
48
|
+
* isGuideAlignment('center') // true
|
|
49
|
+
* isGuideAlignment('foo') // false
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare const isGuideAlignment: (value: unknown) => value is GridAlignment;
|
|
53
|
+
/**
|
|
54
|
+
* Validates line-based guide configurations.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* isGuideLineConfig({ variant: 'line' }) // true
|
|
59
|
+
* isGuideLineConfig({ variant: 'pattern' }) // false
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare const isGuideLineConfig: (config: unknown) => config is GuideConfig;
|
|
63
|
+
/**
|
|
64
|
+
* Validates column-based guide configurations.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* isGuideColumnConfig({ columns: 12 }) // true
|
|
69
|
+
* isGuideColumnConfig({ variant: 'line' }) // false
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare const isGuideColumnConfig: (config: unknown) => config is GuideConfig;
|
|
73
|
+
/**
|
|
74
|
+
* Validates auto-calculated guide configurations.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* isAutoCalculatedGuide({ columnWidth: '200px' }) // true
|
|
79
|
+
* isAutoCalculatedGuide({ columns: 12 }) // false
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export declare const isAutoCalculatedGuide: (config: unknown) => config is GuideConfig;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Layout Component
|
|
3
|
+
* @description Grid-based layout component with baseline alignment
|
|
4
|
+
* @module components
|
|
5
|
+
*/
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import type { Gaps, IndicatorNode } from '@components';
|
|
8
|
+
import { ComponentsProps, Variant } from '../types';
|
|
9
|
+
export type LayoutProps = {
|
|
10
|
+
/**
|
|
11
|
+
* Grid column definition. Supports:
|
|
12
|
+
* - Number: Equal columns (3 → repeat(3, 1fr))
|
|
13
|
+
* - String: Raw template ("1fr auto 200px")
|
|
14
|
+
* - Array: Mixed values ([100, '1fr'] → "100px 1fr")
|
|
15
|
+
*/
|
|
16
|
+
columns?: number | string | Array<number | string>;
|
|
17
|
+
/** Grid row definition (same format as columns) */
|
|
18
|
+
rows?: number | string | Array<number | string>;
|
|
19
|
+
/** Controls item alignment along column axis */
|
|
20
|
+
justifyItems?: React.CSSProperties['justifyItems'];
|
|
21
|
+
/** Controls item alignment along row axis */
|
|
22
|
+
alignItems?: React.CSSProperties['alignItems'];
|
|
23
|
+
/** Controls content distribution along row axis */
|
|
24
|
+
justifyContent?: React.CSSProperties['justifyContent'];
|
|
25
|
+
/** Controls content distribution along column axis */
|
|
26
|
+
alignContent?: React.CSSProperties['alignContent'];
|
|
27
|
+
/** Custom measurement indicator renderer */
|
|
28
|
+
indicatorNode?: IndicatorNode;
|
|
29
|
+
/** Visual style in debug mode */
|
|
30
|
+
variant?: Variant;
|
|
31
|
+
children?: React.ReactNode;
|
|
32
|
+
} & ComponentsProps & Gaps;
|
|
33
|
+
/**
|
|
34
|
+
* A grid-based layout component with baseline alignment and responsive columns.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* Layout provides a CSS Grid container that:
|
|
38
|
+
* - Supports flexible column definitions
|
|
39
|
+
* - Maintains baseline grid alignment
|
|
40
|
+
* - Includes gap management
|
|
41
|
+
* - Offers comprehensive alignment controls
|
|
42
|
+
* - Provides debug overlays for visual verification
|
|
43
|
+
*
|
|
44
|
+
* When no explicit dimensions are provided, Layout defaults to "fit-content"
|
|
45
|
+
* for both width and height.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```tsx
|
|
49
|
+
* // Basic equal columns
|
|
50
|
+
* <Layout columns={3} gap={16}>
|
|
51
|
+
* <div>Column 1</div>
|
|
52
|
+
* <div>Column 2</div>
|
|
53
|
+
* <div>Column 3</div>
|
|
54
|
+
* </Layout>
|
|
55
|
+
*
|
|
56
|
+
* // Mixed column widths with alignment
|
|
57
|
+
* <Layout
|
|
58
|
+
* columns={['200px', '1fr', '2fr']}
|
|
59
|
+
* gap={24}
|
|
60
|
+
* alignItems="center"
|
|
61
|
+
* justifyContent="space-between"
|
|
62
|
+
* >
|
|
63
|
+
* <div>Fixed</div>
|
|
64
|
+
* <div>Flexible</div>
|
|
65
|
+
* <div>Double width</div>
|
|
66
|
+
* </Layout>
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare const Layout: React.NamedExoticComponent<LayoutProps>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Layout Component Entry (components/Layout/index.ts)
|
|
3
|
+
* @description Grid-based layout component with baseline alignment
|
|
4
|
+
* @module baseline-kit/components/Layout
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Provides CSS Grid functionality with built-in baseline grid
|
|
8
|
+
* alignment and debugging features.
|
|
9
|
+
*/
|
|
10
|
+
export * from './Layout';
|