peasy-css 0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Peasy Tools
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,361 @@
1
+ # peasy-css
2
+
3
+ [![npm](https://img.shields.io/npm/v/peasy-css)](https://www.npmjs.com/package/peasy-css)
4
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-blue)](https://www.typescriptlang.org/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
+ [![Zero Dependencies](https://img.shields.io/badge/dependencies-0-brightgreen)](https://www.npmjs.com/package/peasy-css)
7
+
8
+ Pure TypeScript CSS generator — gradients, shadows, flexbox, grid, animations, transforms, filters, glassmorphism, typography, clamp, and more. Zero dependencies, fully typed, ESM-only.
9
+
10
+ Built from [PeasyCSS](https://peasycss.com), the interactive CSS tools platform with 200+ generators and references.
11
+
12
+ > **Try the interactive tools at [peasycss.com](https://peasycss.com)** — [Gradient Generator](https://peasycss.com/tools/gradient/), [Box Shadow](https://peasycss.com/tools/box-shadow/), [Flexbox](https://peasycss.com/tools/flexbox/), [Grid](https://peasycss.com/tools/grid/), [Glassmorphism](https://peasycss.com/tools/glassmorphism/)
13
+
14
+ ## Table of Contents
15
+
16
+ - [Install](#install)
17
+ - [Quick Start](#quick-start)
18
+ - [What You Can Do](#what-you-can-do)
19
+ - [Gradients](#gradients)
20
+ - [Box Shadows](#box-shadows)
21
+ - [Flexbox Layouts](#flexbox-layouts)
22
+ - [CSS Grid](#css-grid)
23
+ - [Animations & Keyframes](#animations--keyframes)
24
+ - [Transforms](#transforms)
25
+ - [CSS Filters](#css-filters)
26
+ - [Glassmorphism](#glassmorphism)
27
+ - [Fluid Typography](#fluid-typography)
28
+ - [Media Queries](#media-queries)
29
+ - [API Reference](#api-reference)
30
+ - [TypeScript Types](#typescript-types)
31
+ - [Learn More About CSS](#learn-more-about-css)
32
+ - [Also Available for Python](#also-available-for-python)
33
+ - [Peasy Developer Tools](#peasy-developer-tools)
34
+ - [License](#license)
35
+
36
+ ## Install
37
+
38
+ ```bash
39
+ npm install peasy-css
40
+ ```
41
+
42
+ ## Quick Start
43
+
44
+ ```typescript
45
+ import {
46
+ gradient,
47
+ boxShadow,
48
+ flexbox,
49
+ glassmorphism,
50
+ } from "peasy-css";
51
+
52
+ // Generate a linear gradient
53
+ const bg = gradient(["#ff6b35", "#f7c948", "#2ec4b6"]);
54
+ // → "linear-gradient(to right, #ff6b35, #f7c948, #2ec4b6)"
55
+
56
+ // Create a box shadow with depth
57
+ const shadow = boxShadow({
58
+ x: "0px",
59
+ y: "4px",
60
+ blur: "12px",
61
+ color: "rgba(0,0,0,0.15)",
62
+ });
63
+ // → "0px 4px 12px 0px rgba(0,0,0,0.15)"
64
+
65
+ // Flexbox layout with centering
66
+ const layout = flexbox({ justify: "center", align: "center", gap: "1rem" });
67
+ // → "display: flex;\n flex-direction: row;\n ..."
68
+
69
+ // Frosted glass effect
70
+ const glass = glassmorphism({ blur: "20px" });
71
+ // → "backdrop-filter: blur(20px);\n -webkit-backdrop-filter: ..."
72
+ ```
73
+
74
+ ## What You Can Do
75
+
76
+ ### Gradients
77
+
78
+ CSS gradients create smooth color transitions — linear (directional), radial (circular), and conic (angular). All three types support repeating patterns and precise color stops.
79
+
80
+ | Type | CSS Function | Use Case |
81
+ |------|-------------|----------|
82
+ | Linear | `linear-gradient()` | Backgrounds, buttons, headers |
83
+ | Radial | `radial-gradient()` | Spotlight effects, circular highlights |
84
+ | Conic | `conic-gradient()` | Pie charts, color wheels |
85
+ | Repeating | `repeating-*-gradient()` | Striped patterns, progress bars |
86
+
87
+ ```typescript
88
+ import { gradient, gradientCss } from "peasy-css";
89
+
90
+ // Linear gradient with custom direction
91
+ gradient(["#e66465", "#9198e5"], { direction: "to bottom" });
92
+ // → "linear-gradient(to bottom, #e66465, #9198e5)"
93
+
94
+ // Radial gradient for spotlight effect
95
+ gradient(["#fff", "#000"], { gradientType: "radial" });
96
+ // → "radial-gradient(circle, #fff, #000)"
97
+
98
+ // Color stops with precise positions
99
+ gradient([
100
+ { color: "red", position: "0%" },
101
+ { color: "yellow", position: "50%" },
102
+ { color: "green", position: "100%" },
103
+ ]);
104
+
105
+ // Complete CSS rule for a hero section
106
+ gradientCss(".hero", ["#667eea", "#764ba2"]);
107
+ // → ".hero {\n background: linear-gradient(to right, #667eea, #764ba2);\n}"
108
+ ```
109
+
110
+ Learn more: [Gradient Generator](https://peasycss.com/tools/gradient/) · [CSS Gradients Guide](https://peasycss.com/glossary/gradient/)
111
+
112
+ ### Box Shadows
113
+
114
+ Box shadows add depth and elevation to elements. Multiple shadows create complex effects like material design elevation or neumorphism.
115
+
116
+ ```typescript
117
+ import { boxShadow, boxShadowCss } from "peasy-css";
118
+
119
+ // Single shadow with elevation
120
+ boxShadow({ x: "0px", y: "4px", blur: "6px", color: "rgba(0,0,0,0.1)" });
121
+
122
+ // Inset shadow for pressed/recessed look
123
+ boxShadow({ inset: true, y: "2px", blur: "4px", color: "rgba(0,0,0,0.2)" });
124
+
125
+ // Layered shadows for realistic depth
126
+ boxShadow(
127
+ { y: "2px", blur: "4px", color: "rgba(0,0,0,0.1)" },
128
+ { y: "8px", blur: "16px", color: "rgba(0,0,0,0.1)" },
129
+ );
130
+ ```
131
+
132
+ Learn more: [Box Shadow Generator](https://peasycss.com/tools/box-shadow/) · [CSS Shadows Guide](https://peasycss.com/glossary/box-shadow/)
133
+
134
+ ### Flexbox Layouts
135
+
136
+ Flexbox distributes space and aligns items in one dimension — row or column.
137
+
138
+ ```typescript
139
+ import { flexbox, flexboxCss } from "peasy-css";
140
+
141
+ // Centered content
142
+ flexbox({ justify: "center", align: "center" });
143
+
144
+ // Responsive card layout with wrapping
145
+ flexbox({ wrap: "wrap", gap: "1.5rem", justify: "space-between" });
146
+
147
+ // Complete navbar rule
148
+ flexboxCss(".navbar", { direction: "row", justify: "space-between", align: "center" });
149
+ ```
150
+
151
+ Learn more: [Flexbox Generator](https://peasycss.com/tools/flexbox/) · [Flexbox Guide](https://peasycss.com/glossary/flexbox/)
152
+
153
+ ### CSS Grid
154
+
155
+ Two-dimensional layout for rows and columns simultaneously.
156
+
157
+ ```typescript
158
+ import { grid, gridCss } from "peasy-css";
159
+
160
+ // Default 3-column grid
161
+ grid();
162
+
163
+ // Responsive auto-fill grid with dense packing
164
+ grid({ columns: "repeat(auto-fill, minmax(250px, 1fr))", autoFlow: "dense" });
165
+
166
+ // Dashboard layout
167
+ gridCss(".dashboard", { columns: "250px 1fr 1fr", rows: "auto 1fr auto", gap: "2rem" });
168
+ ```
169
+
170
+ Learn more: [Grid Generator](https://peasycss.com/tools/grid/) · [CSS Grid Guide](https://peasycss.com/glossary/grid/)
171
+
172
+ ### Animations & Keyframes
173
+
174
+ Multi-step CSS animations with shorthand generation and `@keyframes` rules.
175
+
176
+ ```typescript
177
+ import { animation, keyframes, animationCss } from "peasy-css";
178
+
179
+ // Animation shorthand
180
+ animation("fadeIn", { duration: "0.5s", timing: "ease-in" });
181
+ // → "fadeIn 0.5s ease-in 0s 1 normal none"
182
+
183
+ // Keyframes definition
184
+ keyframes("fadeIn", [
185
+ { selector: "from", properties: { opacity: "0", transform: "translateY(-20px)" } },
186
+ { selector: "to", properties: { opacity: "1", transform: "translateY(0)" } },
187
+ ]);
188
+ ```
189
+
190
+ Learn more: [Animation Generator](https://peasycss.com/tools/animation/) · [CSS Animation Guide](https://peasycss.com/glossary/animation/)
191
+
192
+ ### Transforms
193
+
194
+ Translate, rotate, scale, and skew elements without affecting document flow.
195
+
196
+ ```typescript
197
+ import { transform, transformCss } from "peasy-css";
198
+
199
+ transform({ rotate: "45deg" });
200
+ // → "rotate(45deg)"
201
+
202
+ transform({ translateX: "10px", translateY: "20px", rotate: "45deg", scaleX: "1.5" });
203
+ // → "translate(10px, 20px) rotate(45deg) scale(1.5, 1)"
204
+ ```
205
+
206
+ Learn more: [Transform Generator](https://peasycss.com/tools/transform/) · [CSS Transform Guide](https://peasycss.com/glossary/transform/)
207
+
208
+ ### CSS Filters
209
+
210
+ Graphical effects — blur, brightness, contrast, grayscale — for images and hover states.
211
+
212
+ ```typescript
213
+ import { cssFilter, filterCss } from "peasy-css";
214
+
215
+ cssFilter({ blur: "5px" });
216
+ // → "blur(5px)"
217
+
218
+ cssFilter({ blur: "2px", brightness: "120%", grayscale: "50%" });
219
+ // → "blur(2px) brightness(120%) grayscale(50%)"
220
+ ```
221
+
222
+ Learn more: [Filter Generator](https://peasycss.com/tools/filter/) · [CSS Filter Guide](https://peasycss.com/glossary/filter/)
223
+
224
+ ### Glassmorphism
225
+
226
+ Frosted glass effect with backdrop-filter, semi-transparent backgrounds, and subtle borders.
227
+
228
+ ```typescript
229
+ import { glassmorphism, glassmorphismCss } from "peasy-css";
230
+
231
+ glassmorphism();
232
+ // → "backdrop-filter: blur(10px);\n -webkit-backdrop-filter: ..."
233
+
234
+ glassmorphismCss(".modal", { blur: "15px", background: "rgba(0,0,0,0.3)" });
235
+ ```
236
+
237
+ Learn more: [Glassmorphism Generator](https://peasycss.com/tools/glassmorphism/) · [Glassmorphism Guide](https://peasycss.com/glossary/glassmorphism/)
238
+
239
+ ### Fluid Typography
240
+
241
+ CSS `clamp()` for smooth scaling between viewport sizes.
242
+
243
+ ```typescript
244
+ import { clamp, clampFontCss } from "peasy-css";
245
+
246
+ clamp("1rem", "2.5vw", "3rem");
247
+ // → "clamp(1rem, 2.5vw, 3rem)"
248
+
249
+ clampFontCss("h1", "1.5rem", "4vw", "3rem");
250
+ // → "h1 {\n font-size: clamp(1.5rem, 4vw, 3rem);\n}"
251
+ ```
252
+
253
+ Learn more: [Clamp Calculator](https://peasycss.com/tools/clamp/) · [CSS Clamp Guide](https://peasycss.com/glossary/clamp/)
254
+
255
+ ### Media Queries
256
+
257
+ Responsive design with viewport breakpoints.
258
+
259
+ ```typescript
260
+ import { mediaQuery } from "peasy-css";
261
+
262
+ // Mobile-first (min-width)
263
+ mediaQuery("768px", ".sidebar { display: block; }");
264
+
265
+ // Desktop-first (max-width)
266
+ mediaQuery("480px", "body { font-size: 14px; }", "max-width");
267
+ ```
268
+
269
+ ## API Reference
270
+
271
+ | Function | Description |
272
+ |----------|-------------|
273
+ | `gradient(colors, options?)` | CSS gradient value |
274
+ | `gradientCss(selector, colors, options?)` | Complete gradient CSS rule |
275
+ | `boxShadow(...shadows)` | box-shadow value |
276
+ | `boxShadowCss(selector, ...shadows)` | Complete box-shadow CSS rule |
277
+ | `textShadow(x?, y?, blur?, color?)` | text-shadow value |
278
+ | `textShadowCss(selector, x?, y?, blur?, color?)` | Complete text-shadow CSS rule |
279
+ | `borderRadius(tl?, tr?, br?, bl?)` | border-radius value |
280
+ | `borderRadiusCss(selector, tl?, tr?, br?, bl?)` | Complete border-radius CSS rule |
281
+ | `flexbox(options?)` | Flexbox properties |
282
+ | `flexboxCss(selector, options?)` | Complete flexbox CSS rule |
283
+ | `grid(template?)` | Grid properties |
284
+ | `gridCss(selector, template?)` | Complete grid CSS rule |
285
+ | `animation(name, options?)` | animation shorthand value |
286
+ | `animationCss(selector, name, options?)` | Complete animation CSS rule |
287
+ | `keyframes(name, frames)` | @keyframes rule |
288
+ | `transform(options?)` | transform value |
289
+ | `transformCss(selector, options?)` | Complete transform CSS rule |
290
+ | `cssFilter(options?)` | filter value |
291
+ | `filterCss(selector, options?)` | Complete filter CSS rule |
292
+ | `transition(property?, options?)` | transition value |
293
+ | `transitionCss(selector, property?, options?)` | Complete transition CSS rule |
294
+ | `mediaQuery(breakpoint, css, type?)` | @media rule |
295
+ | `typography(options?)` | Typography properties |
296
+ | `typographyCss(selector, options?)` | Complete typography CSS rule |
297
+ | `aspectRatio(ratio)` | aspect-ratio value |
298
+ | `aspectRatioCss(selector, ratio)` | Complete aspect-ratio CSS rule |
299
+ | `clamp(min, preferred, max)` | clamp() value |
300
+ | `clampFontCss(selector, min, preferred, max)` | Complete fluid font-size CSS rule |
301
+ | `glassmorphism(options?)` | Glassmorphism properties |
302
+ | `glassmorphismCss(selector, options?)` | Complete glassmorphism CSS rule |
303
+
304
+ ## TypeScript Types
305
+
306
+ ```typescript
307
+ import type {
308
+ ColorStop,
309
+ Shadow,
310
+ GridTemplate,
311
+ Keyframe,
312
+ GradientOptions,
313
+ FlexboxOptions,
314
+ AnimationOptions,
315
+ TransformOptions,
316
+ FilterOptions,
317
+ TransitionOptions,
318
+ TypographyOptions,
319
+ GlassmorphismOptions,
320
+ GradientDirection,
321
+ GradientType,
322
+ FlexDirection,
323
+ FlexWrap,
324
+ FlexJustify,
325
+ FlexAlign,
326
+ GridAutoFlow,
327
+ TimingFunction,
328
+ FontWeight,
329
+ } from "peasy-css";
330
+ ```
331
+
332
+ ## Learn More About CSS
333
+
334
+ - **Tools**: [Gradient Generator](https://peasycss.com/tools/gradient/) · [Box Shadow](https://peasycss.com/tools/box-shadow/) · [Flexbox](https://peasycss.com/tools/flexbox/) · [Grid](https://peasycss.com/tools/grid/)
335
+ - **Effects**: [Glassmorphism](https://peasycss.com/tools/glassmorphism/) · [Animation](https://peasycss.com/tools/animation/) · [Transform](https://peasycss.com/tools/transform/)
336
+ - **Reference**: [CSS Glossary](https://peasycss.com/glossary/) · [All CSS Tools](https://peasycss.com/tools/)
337
+ - **API**: [REST API Docs](https://peasycss.com/developers/) · [OpenAPI Spec](https://peasycss.com/api/openapi.json)
338
+ - **Python**: [PyPI Package](https://pypi.org/project/peasy-css/)
339
+
340
+ ## Also Available for Python
341
+
342
+ ```bash
343
+ pip install peasy-css
344
+ ```
345
+
346
+ The Python package provides the same 15 CSS generators with CLI, MCP server, and REST API client. See [peasy-css on PyPI](https://pypi.org/project/peasy-css/).
347
+
348
+ ## Peasy Developer Tools
349
+
350
+ | Package | PyPI | npm | Description |
351
+ |---------|------|-----|-------------|
352
+ | peasytext | [PyPI](https://pypi.org/project/peasytext/) | [npm](https://www.npmjs.com/package/peasytext) | Text analysis — readability, sentiment, keywords |
353
+ | peasy-pdf | [PyPI](https://pypi.org/project/peasy-pdf/) | — | PDF processing — extract, merge, split, metadata |
354
+ | peasy-image | [PyPI](https://pypi.org/project/peasy-image/) | — | Image ops — resize, crop, filter, watermark |
355
+ | **peasy-css** | [PyPI](https://pypi.org/project/peasy-css/) | **[npm](https://www.npmjs.com/package/peasy-css)** | **CSS generation — gradients, shadows, flexbox, grid** |
356
+
357
+ Part of the [Peasy](https://peasytools.com) developer tools ecosystem.
358
+
359
+ ## License
360
+
361
+ MIT
@@ -0,0 +1,188 @@
1
+ /**
2
+ * peasy-css types — TypeScript interfaces for CSS generation.
3
+ */
4
+ /** A color stop with optional position for gradients. */
5
+ interface ColorStop {
6
+ color: string;
7
+ position?: string;
8
+ }
9
+ /** Box/text shadow configuration. */
10
+ interface Shadow {
11
+ x?: string;
12
+ y?: string;
13
+ blur?: string;
14
+ spread?: string;
15
+ color?: string;
16
+ inset?: boolean;
17
+ }
18
+ /** CSS Grid template configuration. */
19
+ interface GridTemplate {
20
+ columns?: string;
21
+ rows?: string;
22
+ gap?: string;
23
+ autoFlow?: string;
24
+ }
25
+ /** A single keyframe in a CSS animation. */
26
+ interface Keyframe {
27
+ selector: string;
28
+ properties: Record<string, string>;
29
+ }
30
+ /** Gradient direction. */
31
+ type GradientDirection = "to right" | "to left" | "to top" | "to bottom" | "to top right" | "to top left" | "to bottom right" | "to bottom left";
32
+ /** Gradient type. */
33
+ type GradientType = "linear" | "radial" | "conic";
34
+ /** Flexbox direction. */
35
+ type FlexDirection = "row" | "row-reverse" | "column" | "column-reverse";
36
+ /** Flexbox wrap mode. */
37
+ type FlexWrap = "nowrap" | "wrap" | "wrap-reverse";
38
+ /** Flexbox justify-content values. */
39
+ type FlexJustify = "flex-start" | "flex-end" | "center" | "space-between" | "space-around" | "space-evenly";
40
+ /** Flexbox align-items values. */
41
+ type FlexAlign = "flex-start" | "flex-end" | "center" | "stretch" | "baseline";
42
+ /** Grid auto-flow mode. */
43
+ type GridAutoFlow = "row" | "column" | "dense" | "row dense" | "column dense";
44
+ /** CSS timing function. */
45
+ type TimingFunction = "ease" | "ease-in" | "ease-out" | "ease-in-out" | "linear";
46
+ /** Font weight values. */
47
+ type FontWeight = "normal" | "bold" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900";
48
+ /** Options for gradient generation. */
49
+ interface GradientOptions {
50
+ direction?: GradientDirection | string;
51
+ gradientType?: GradientType;
52
+ repeating?: boolean;
53
+ }
54
+ /** Options for flexbox generation. */
55
+ interface FlexboxOptions {
56
+ direction?: FlexDirection;
57
+ wrap?: FlexWrap;
58
+ justify?: FlexJustify;
59
+ align?: FlexAlign;
60
+ gap?: string;
61
+ }
62
+ /** Options for animation generation. */
63
+ interface AnimationOptions {
64
+ duration?: string;
65
+ timing?: TimingFunction;
66
+ delay?: string;
67
+ iterationCount?: string | number;
68
+ direction?: string;
69
+ fillMode?: string;
70
+ }
71
+ /** Options for transform generation. */
72
+ interface TransformOptions {
73
+ translateX?: string;
74
+ translateY?: string;
75
+ rotate?: string;
76
+ scaleX?: string;
77
+ scaleY?: string;
78
+ skewX?: string;
79
+ skewY?: string;
80
+ }
81
+ /** Options for CSS filter generation. */
82
+ interface FilterOptions {
83
+ blur?: string;
84
+ brightness?: string;
85
+ contrast?: string;
86
+ grayscale?: string;
87
+ saturate?: string;
88
+ sepia?: string;
89
+ hueRotate?: string;
90
+ invert?: string;
91
+ opacity?: string;
92
+ dropShadow?: string;
93
+ }
94
+ /** Options for transition generation. */
95
+ interface TransitionOptions {
96
+ duration?: string;
97
+ timing?: TimingFunction;
98
+ delay?: string;
99
+ }
100
+ /** Options for typography generation. */
101
+ interface TypographyOptions {
102
+ fontFamily?: string;
103
+ fontSize?: string;
104
+ fontWeight?: FontWeight;
105
+ lineHeight?: string;
106
+ letterSpacing?: string;
107
+ textTransform?: string;
108
+ wordSpacing?: string;
109
+ }
110
+ /** Options for glassmorphism generation. */
111
+ interface GlassmorphismOptions {
112
+ blur?: string;
113
+ background?: string;
114
+ borderColor?: string;
115
+ }
116
+
117
+ /**
118
+ * peasy-css engine — Pure TypeScript CSS generation.
119
+ *
120
+ * 15 CSS generators: gradients, shadows, flexbox, grid, animations,
121
+ * transforms, filters, transitions, media queries, typography,
122
+ * border-radius, aspect-ratio, clamp, and glassmorphism.
123
+ *
124
+ * Zero dependencies. All functions are pure — no side effects.
125
+ */
126
+
127
+ /** Generate a CSS gradient value string. */
128
+ declare function gradient(colors: (string | ColorStop)[], options?: GradientOptions): string;
129
+ /** Generate a complete CSS rule with gradient background. */
130
+ declare function gradientCss(selector: string, colors: (string | ColorStop)[], options?: GradientOptions): string;
131
+ /** Generate a box-shadow CSS value from one or more shadows. */
132
+ declare function boxShadow(...shadows: Shadow[]): string;
133
+ /** Generate a complete CSS rule with box-shadow. */
134
+ declare function boxShadowCss(selector: string, ...shadows: Shadow[]): string;
135
+ /** Generate a text-shadow CSS value. */
136
+ declare function textShadow(x?: string, y?: string, blur?: string, color?: string): string;
137
+ /** Generate a complete CSS rule with text-shadow. */
138
+ declare function textShadowCss(selector: string, x?: string, y?: string, blur?: string, color?: string): string;
139
+ /** Generate a border-radius CSS value. */
140
+ declare function borderRadius(topLeft?: string, topRight?: string, bottomRight?: string, bottomLeft?: string): string;
141
+ /** Generate a complete CSS rule with border-radius. */
142
+ declare function borderRadiusCss(selector: string, topLeft?: string, topRight?: string, bottomRight?: string, bottomLeft?: string): string;
143
+ /** Generate flexbox CSS properties. */
144
+ declare function flexbox(options?: FlexboxOptions): string;
145
+ /** Generate a complete CSS rule with flexbox layout. */
146
+ declare function flexboxCss(selector: string, options?: FlexboxOptions): string;
147
+ /** Generate CSS Grid properties. */
148
+ declare function grid(template?: GridTemplate): string;
149
+ /** Generate a complete CSS rule with grid layout. */
150
+ declare function gridCss(selector: string, template?: GridTemplate): string;
151
+ /** Generate a CSS animation shorthand value. */
152
+ declare function animation(name: string, options?: AnimationOptions): string;
153
+ /** Generate a complete CSS rule with animation. */
154
+ declare function animationCss(selector: string, name: string, options?: AnimationOptions): string;
155
+ /** Generate a @keyframes CSS rule. */
156
+ declare function keyframes(name: string, frames: Keyframe[]): string;
157
+ /** Generate a CSS transform value. */
158
+ declare function transform(options?: TransformOptions): string;
159
+ /** Generate a complete CSS rule with transform. */
160
+ declare function transformCss(selector: string, options?: TransformOptions): string;
161
+ /** Generate a CSS filter value. */
162
+ declare function cssFilter(options?: FilterOptions): string;
163
+ /** Generate a complete CSS rule with filter. */
164
+ declare function filterCss(selector: string, options?: FilterOptions): string;
165
+ /** Generate a CSS transition value. */
166
+ declare function transition(property?: string, options?: TransitionOptions): string;
167
+ /** Generate a complete CSS rule with transition. */
168
+ declare function transitionCss(selector: string, property?: string, options?: TransitionOptions): string;
169
+ /** Wrap CSS in a media query. */
170
+ declare function mediaQuery(breakpoint: string, cssBlock: string, type?: string): string;
171
+ /** Generate typography CSS properties. */
172
+ declare function typography(options?: TypographyOptions): string;
173
+ /** Generate a complete CSS rule with typography. */
174
+ declare function typographyCss(selector: string, options?: TypographyOptions): string;
175
+ /** Return the aspect-ratio CSS value (pass-through validation). */
176
+ declare function aspectRatio(ratio: string): string;
177
+ /** Generate a complete CSS rule with aspect-ratio. */
178
+ declare function aspectRatioCss(selector: string, ratio: string): string;
179
+ /** Generate a CSS clamp() value for fluid sizing. */
180
+ declare function clamp(min: string, preferred: string, max: string): string;
181
+ /** Generate a complete CSS rule with fluid font-size. */
182
+ declare function clampFontCss(selector: string, min: string, preferred: string, max: string): string;
183
+ /** Generate glassmorphism (frosted glass) CSS properties. */
184
+ declare function glassmorphism(options?: GlassmorphismOptions): string;
185
+ /** Generate a complete CSS rule with glassmorphism. */
186
+ declare function glassmorphismCss(selector: string, options?: GlassmorphismOptions): string;
187
+
188
+ export { type AnimationOptions, type ColorStop, type FilterOptions, type FlexAlign, type FlexDirection, type FlexJustify, type FlexWrap, type FlexboxOptions, type FontWeight, type GlassmorphismOptions, type GradientDirection, type GradientOptions, type GradientType, type GridAutoFlow, type GridTemplate, type Keyframe, type Shadow, type TimingFunction, type TransformOptions, type TransitionOptions, type TypographyOptions, animation, animationCss, aspectRatio, aspectRatioCss, borderRadius, borderRadiusCss, boxShadow, boxShadowCss, clamp, clampFontCss, cssFilter, filterCss, flexbox, flexboxCss, glassmorphism, glassmorphismCss, gradient, gradientCss, grid, gridCss, keyframes, mediaQuery, textShadow, textShadowCss, transform, transformCss, transition, transitionCss, typography, typographyCss };
package/dist/index.js ADDED
@@ -0,0 +1,263 @@
1
+ // src/engine.ts
2
+ function rule(selector, body) {
3
+ return `${selector} {
4
+ ${body}
5
+ }`;
6
+ }
7
+ function colorStopStr(stop) {
8
+ if (typeof stop === "string") return stop;
9
+ return stop.position ? `${stop.color} ${stop.position}` : stop.color;
10
+ }
11
+ function gradient(colors, options = {}) {
12
+ const {
13
+ direction = "to right",
14
+ gradientType = "linear",
15
+ repeating = false
16
+ } = options;
17
+ const stops = colors.map(colorStopStr).join(", ");
18
+ const prefix = repeating ? "repeating-" : "";
19
+ if (gradientType === "radial") {
20
+ return `${prefix}radial-gradient(circle, ${stops})`;
21
+ }
22
+ if (gradientType === "conic") {
23
+ return `${prefix}conic-gradient(${stops})`;
24
+ }
25
+ return `${prefix}linear-gradient(${direction}, ${stops})`;
26
+ }
27
+ function gradientCss(selector, colors, options = {}) {
28
+ return rule(selector, `background: ${gradient(colors, options)};`);
29
+ }
30
+ function boxShadow(...shadows) {
31
+ return shadows.map((s) => {
32
+ const x = s.x ?? "0px";
33
+ const y = s.y ?? "0px";
34
+ const blur = s.blur ?? "0px";
35
+ const spread = s.spread ?? "0px";
36
+ const color = s.color ?? "rgba(0, 0, 0, 0.1)";
37
+ const parts = s.inset ? ["inset", x, y, blur, spread, color] : [x, y, blur, spread, color];
38
+ return parts.join(" ");
39
+ }).join(", ");
40
+ }
41
+ function boxShadowCss(selector, ...shadows) {
42
+ return rule(selector, `box-shadow: ${boxShadow(...shadows)};`);
43
+ }
44
+ function textShadow(x = "1px", y = "1px", blur = "2px", color = "rgba(0, 0, 0, 0.3)") {
45
+ return `${x} ${y} ${blur} ${color}`;
46
+ }
47
+ function textShadowCss(selector, x = "1px", y = "1px", blur = "2px", color = "rgba(0, 0, 0, 0.3)") {
48
+ return rule(selector, `text-shadow: ${textShadow(x, y, blur, color)};`);
49
+ }
50
+ function borderRadius(topLeft = "0px", topRight = "0px", bottomRight = "0px", bottomLeft = "0px") {
51
+ if (topLeft === topRight && topRight === bottomRight && bottomRight === bottomLeft) {
52
+ return topLeft;
53
+ }
54
+ return `${topLeft} ${topRight} ${bottomRight} ${bottomLeft}`;
55
+ }
56
+ function borderRadiusCss(selector, topLeft = "0px", topRight = "0px", bottomRight = "0px", bottomLeft = "0px") {
57
+ const value = borderRadius(topLeft, topRight, bottomRight, bottomLeft);
58
+ return rule(selector, `border-radius: ${value};`);
59
+ }
60
+ function flexbox(options = {}) {
61
+ const {
62
+ direction = "row",
63
+ wrap = "nowrap",
64
+ justify = "flex-start",
65
+ align = "stretch",
66
+ gap = "0px"
67
+ } = options;
68
+ const lines = [
69
+ "display: flex;",
70
+ `flex-direction: ${direction};`,
71
+ `flex-wrap: ${wrap};`,
72
+ `justify-content: ${justify};`,
73
+ `align-items: ${align};`
74
+ ];
75
+ if (gap !== "0px" && gap !== "0") {
76
+ lines.push(`gap: ${gap};`);
77
+ }
78
+ return lines.join("\n ");
79
+ }
80
+ function flexboxCss(selector, options = {}) {
81
+ return rule(selector, flexbox(options));
82
+ }
83
+ function grid(template) {
84
+ const t = template ?? {};
85
+ const columns = t.columns ?? "1fr 1fr 1fr";
86
+ const rows = t.rows ?? "auto";
87
+ const gap = t.gap ?? "1rem";
88
+ const lines = [
89
+ "display: grid;",
90
+ `grid-template-columns: ${columns};`,
91
+ `grid-template-rows: ${rows};`,
92
+ `gap: ${gap};`
93
+ ];
94
+ if (t.autoFlow) {
95
+ lines.push(`grid-auto-flow: ${t.autoFlow};`);
96
+ }
97
+ return lines.join("\n ");
98
+ }
99
+ function gridCss(selector, template) {
100
+ return rule(selector, grid(template));
101
+ }
102
+ function animation(name, options = {}) {
103
+ const {
104
+ duration = "1s",
105
+ timing = "ease",
106
+ delay = "0s",
107
+ iterationCount = 1,
108
+ direction = "normal",
109
+ fillMode = "none"
110
+ } = options;
111
+ return `${name} ${duration} ${timing} ${delay} ${iterationCount} ${direction} ${fillMode}`;
112
+ }
113
+ function animationCss(selector, name, options = {}) {
114
+ return rule(selector, `animation: ${animation(name, options)};`);
115
+ }
116
+ function keyframes(name, frames) {
117
+ const body = frames.map((f) => {
118
+ const props = Object.entries(f.properties).map(([k, v]) => `${k}: ${v};`).join(" ");
119
+ return ` ${f.selector} { ${props} }`;
120
+ }).join("\n");
121
+ return `@keyframes ${name} {
122
+ ${body}
123
+ }`;
124
+ }
125
+ function transform(options = {}) {
126
+ const parts = [];
127
+ const tx = options.translateX;
128
+ const ty = options.translateY;
129
+ if (tx || ty) {
130
+ parts.push(`translate(${tx ?? "0"}, ${ty ?? "0"})`);
131
+ }
132
+ if (options.rotate) {
133
+ parts.push(`rotate(${options.rotate})`);
134
+ }
135
+ const sx = options.scaleX;
136
+ const sy = options.scaleY;
137
+ if (sx || sy) {
138
+ parts.push(`scale(${sx ?? "1"}, ${sy ?? "1"})`);
139
+ }
140
+ if (options.skewX || options.skewY) {
141
+ parts.push(`skew(${options.skewX ?? "0"}, ${options.skewY ?? "0"})`);
142
+ }
143
+ return parts.length > 0 ? parts.join(" ") : "none";
144
+ }
145
+ function transformCss(selector, options = {}) {
146
+ return rule(selector, `transform: ${transform(options)};`);
147
+ }
148
+ function cssFilter(options = {}) {
149
+ const parts = [];
150
+ if (options.blur) parts.push(`blur(${options.blur})`);
151
+ if (options.brightness) parts.push(`brightness(${options.brightness})`);
152
+ if (options.contrast) parts.push(`contrast(${options.contrast})`);
153
+ if (options.grayscale) parts.push(`grayscale(${options.grayscale})`);
154
+ if (options.saturate) parts.push(`saturate(${options.saturate})`);
155
+ if (options.sepia) parts.push(`sepia(${options.sepia})`);
156
+ if (options.hueRotate) parts.push(`hue-rotate(${options.hueRotate})`);
157
+ if (options.invert) parts.push(`invert(${options.invert})`);
158
+ if (options.opacity) parts.push(`opacity(${options.opacity})`);
159
+ if (options.dropShadow) parts.push(`drop-shadow(${options.dropShadow})`);
160
+ return parts.length > 0 ? parts.join(" ") : "none";
161
+ }
162
+ function filterCss(selector, options = {}) {
163
+ return rule(selector, `filter: ${cssFilter(options)};`);
164
+ }
165
+ function transition(property = "all", options = {}) {
166
+ const { duration = "0.3s", timing = "ease", delay = "0s" } = options;
167
+ return `${property} ${duration} ${timing} ${delay}`;
168
+ }
169
+ function transitionCss(selector, property = "all", options = {}) {
170
+ return rule(
171
+ selector,
172
+ `transition: ${transition(property, options)};`
173
+ );
174
+ }
175
+ function mediaQuery(breakpoint, cssBlock, type = "min-width") {
176
+ return `@media (${type}: ${breakpoint}) {
177
+ ${cssBlock}
178
+ }`;
179
+ }
180
+ function typography(options = {}) {
181
+ const {
182
+ fontFamily = "system-ui, -apple-system, sans-serif",
183
+ fontSize = "1rem",
184
+ fontWeight = "normal",
185
+ lineHeight = "1.5",
186
+ letterSpacing,
187
+ textTransform,
188
+ wordSpacing
189
+ } = options;
190
+ const lines = [
191
+ `font-family: ${fontFamily};`,
192
+ `font-size: ${fontSize};`,
193
+ `font-weight: ${fontWeight};`,
194
+ `line-height: ${lineHeight};`
195
+ ];
196
+ if (letterSpacing) lines.push(`letter-spacing: ${letterSpacing};`);
197
+ if (textTransform) lines.push(`text-transform: ${textTransform};`);
198
+ if (wordSpacing) lines.push(`word-spacing: ${wordSpacing};`);
199
+ return lines.join("\n ");
200
+ }
201
+ function typographyCss(selector, options = {}) {
202
+ return rule(selector, typography(options));
203
+ }
204
+ function aspectRatio(ratio) {
205
+ return ratio;
206
+ }
207
+ function aspectRatioCss(selector, ratio) {
208
+ return rule(selector, `aspect-ratio: ${ratio};`);
209
+ }
210
+ function clamp(min, preferred, max) {
211
+ return `clamp(${min}, ${preferred}, ${max})`;
212
+ }
213
+ function clampFontCss(selector, min, preferred, max) {
214
+ return rule(selector, `font-size: ${clamp(min, preferred, max)};`);
215
+ }
216
+ function glassmorphism(options = {}) {
217
+ const {
218
+ blur = "10px",
219
+ background = "rgba(255, 255, 255, 0.25)",
220
+ borderColor = "rgba(255, 255, 255, 0.18)"
221
+ } = options;
222
+ return [
223
+ `backdrop-filter: blur(${blur});`,
224
+ `-webkit-backdrop-filter: blur(${blur});`,
225
+ `background: ${background};`,
226
+ `border: 1px solid ${borderColor};`
227
+ ].join("\n ");
228
+ }
229
+ function glassmorphismCss(selector, options = {}) {
230
+ return rule(selector, glassmorphism(options));
231
+ }
232
+ export {
233
+ animation,
234
+ animationCss,
235
+ aspectRatio,
236
+ aspectRatioCss,
237
+ borderRadius,
238
+ borderRadiusCss,
239
+ boxShadow,
240
+ boxShadowCss,
241
+ clamp,
242
+ clampFontCss,
243
+ cssFilter,
244
+ filterCss,
245
+ flexbox,
246
+ flexboxCss,
247
+ glassmorphism,
248
+ glassmorphismCss,
249
+ gradient,
250
+ gradientCss,
251
+ grid,
252
+ gridCss,
253
+ keyframes,
254
+ mediaQuery,
255
+ textShadow,
256
+ textShadowCss,
257
+ transform,
258
+ transformCss,
259
+ transition,
260
+ transitionCss,
261
+ typography,
262
+ typographyCss
263
+ };
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "peasy-css",
3
+ "version": "0.1.0",
4
+ "description": "Pure TypeScript CSS generator — gradients, shadows, flexbox, grid, animations, transforms, filters, glassmorphism, typography, clamp, and more. Zero dependencies, fully typed.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsup src/index.ts --format esm --dts",
19
+ "test": "vitest run",
20
+ "typecheck": "tsc --noEmit"
21
+ },
22
+ "keywords": [
23
+ "css",
24
+ "css-generator",
25
+ "gradient",
26
+ "box-shadow",
27
+ "flexbox",
28
+ "css-grid",
29
+ "animation",
30
+ "keyframes",
31
+ "transform",
32
+ "filter",
33
+ "glassmorphism",
34
+ "typography",
35
+ "clamp",
36
+ "media-query",
37
+ "border-radius",
38
+ "transition",
39
+ "aspect-ratio",
40
+ "css-in-js",
41
+ "zero-dependencies"
42
+ ],
43
+ "author": "Peasy Tools",
44
+ "license": "MIT",
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "https://github.com/peasytools/peasy-css-js.git"
48
+ },
49
+ "homepage": "https://peasycss.com",
50
+ "devDependencies": {
51
+ "tsup": "^8.0",
52
+ "typescript": "^5.7",
53
+ "vitest": "^3.0"
54
+ }
55
+ }