-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod.ts
More file actions
143 lines (142 loc) · 3.51 KB
/
mod.ts
File metadata and controls
143 lines (142 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/**
* Type-safe CSS-in-TypeScript library with automatic class generation.
*
* This library provides utilities for creating CSS styles with full type safety,
* automatic class name generation, nested selectors, CSS variables with contracts,
* and at-rule support.
*
* @example Basic styles
* ```ts
* import { style, render, use } from "@baetheus/css";
*
* // Create styles with auto-generated class names
* const button = style({
* backgroundColor: "blue",
* color: "white",
* padding: "8px 16px",
* borderRadius: "4px",
* });
*
* // Use in HTML/JSX
* console.log(button.toString()); // ".a1b2c3d4"
*
* // Render to CSS string
* console.log(render(button));
* // .a1b2c3d4 {
* // background-color: blue;
* // color: white;
* // padding: 8px 16px;
* // border-radius: 4px;
* // }
* ```
*
* @example Nested selectors and pseudo-classes
* ```ts
* import { style, render } from "@baetheus/css";
*
* const card = style({
* padding: "16px",
* transition: "transform 0.2s",
* select: {
* "&:hover": { transform: "scale(1.02)" },
* "& > h2": { marginTop: 0 },
* "@media (min-width: 768px)": { padding: "24px" },
* },
* });
* ```
*
* @example Combining multiple styles
* ```ts
* import { style, use } from "@baetheus/css";
*
* const base = style({ padding: "8px" });
* const primary = style({ backgroundColor: "blue", color: "white" });
* const large = style({ fontSize: "1.25rem" });
*
* // Combine into a single class string
* const className = use(base, primary, large);
* // ".abc123 .def456 .ghi789"
* ```
*
* @example CSS variable contracts
* ```ts
* import { contract, vars, style, render } from "@baetheus/css";
*
* // Define a type-safe variable contract
* const theme = contract({
* colors: {
* primary: null,
* background: null,
* },
* spacing: {
* small: null,
* medium: null,
* },
* });
*
* // Use contract references in styles (type-checked)
* const card = style({
* backgroundColor: theme.colors.background,
* padding: theme.spacing.medium,
* color: theme.colors.primary,
* });
*
* // Create theme implementations
* const lightTheme = vars(theme, {
* colors: { primary: "#0066cc", background: "#ffffff" },
* spacing: { small: "4px", medium: "16px" },
* });
*
* const darkTheme = vars(theme, {
* colors: { primary: "#66b3ff", background: "#1a1a1a" },
* spacing: { small: "4px", medium: "16px" },
* });
*
* console.log(render(lightTheme, card));
* ```
*
* @example At-rules (font-face, keyframes, etc.)
* ```ts
* import { at, render } from "@baetheus/css";
*
* const roboto = at("@font-face", {
* fontFamily: "Roboto",
* src: "url('/fonts/roboto.woff2') format('woff2')",
* fontWeight: "400",
* fontDisplay: "swap",
* });
*
* const themeColor = at("@property --theme-color", {
* syntax: '"<color>"',
* inherits: "true",
* initialValue: "blue",
* });
*
* console.log(render(roboto, themeColor));
* ```
*
* @example Minified output
* ```ts
* import { style, render, MINIMAL_RENDER_OPTIONS } from "@baetheus/css";
*
* const button = style({ color: "white", backgroundColor: "blue" });
*
* // Minified for production
* console.log(render(MINIMAL_RENDER_OPTIONS, button));
* // .a1b2c3d4{color:white;background-color:blue;}
* ```
*
* @module
* @since 0.0.4
*/
export {
isStyle,
MINIMAL_RENDER_OPTIONS,
properties,
render,
STANDARD_RENDER_OPTIONS,
style,
use,
} from "./style.ts";
export { contract, vars } from "./variables.ts";
export { at } from "./atrules.ts";