@plumeria/core 0.9.6 → 0.9.8
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 +81 -55
- package/dist/index.d.ts +5 -4
- package/dist/index.js +14 -8
- package/dist/index.mjs +14 -8
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,39 +1,38 @@
|
|
|
1
1
|
# @plumeria/core
|
|
2
2
|
|
|
3
|
-
**Zero-runtime CSS
|
|
4
|
-
Compile at build-time. No runtime overhead.
|
|
3
|
+
**Zero-runtime, expressive CSS-in-JS library for TypeScript.**
|
|
5
4
|
|
|
6
|
-
## Installation
|
|
5
|
+
## 🌱 Installation
|
|
7
6
|
|
|
8
|
-
To
|
|
7
|
+
To get started with Plumeria, install the core package:
|
|
9
8
|
|
|
10
9
|
```sh
|
|
11
10
|
npm install @plumeria/core
|
|
12
11
|
```
|
|
13
12
|
|
|
14
|
-
### Compiler
|
|
13
|
+
### 🛠 Compiler (for static extraction)
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
[`@plumeria/compiler`](https://www.npmjs.com/package/@plumeria/compiler) for static extraction through the build process.
|
|
15
|
+
If you want to extract styles at build time using commands like `npx css`, install:
|
|
18
16
|
|
|
19
17
|
```sh
|
|
20
18
|
npm install --save-dev @plumeria/compiler
|
|
21
19
|
```
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
More at: [@plumeria/compiler on npm](https://www.npmjs.com/package/@plumeria/compiler)
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
### 🎨 Stylesheet Import
|
|
24
|
+
|
|
25
|
+
In your app entry point, import the compiled CSS file:
|
|
27
26
|
|
|
28
27
|
```ts
|
|
29
28
|
import '@plumeria/core/stylesheet.css';
|
|
30
29
|
```
|
|
31
30
|
|
|
32
|
-
## API
|
|
31
|
+
## 📘 API Reference
|
|
33
32
|
|
|
34
|
-
### css.create()
|
|
33
|
+
### `css.create()`
|
|
35
34
|
|
|
36
|
-
|
|
35
|
+
Define a set of styles:
|
|
37
36
|
|
|
38
37
|
```ts
|
|
39
38
|
import { css } from '@plumeria/core';
|
|
@@ -49,15 +48,13 @@ const styles = css.create({
|
|
|
49
48
|
});
|
|
50
49
|
```
|
|
51
50
|
|
|
52
|
-
|
|
53
|
-
Also, any properties that are not wrapped will conform to that className.
|
|
51
|
+
Supports pseudo/media queries inline:
|
|
54
52
|
|
|
55
53
|
```ts
|
|
56
54
|
const styles = css.create({
|
|
57
55
|
box: {
|
|
58
|
-
[css.media.
|
|
56
|
+
[css.media.maxWidth(900)]: {
|
|
59
57
|
width: '100%',
|
|
60
|
-
color: 'rgb(60,60,60)',
|
|
61
58
|
},
|
|
62
59
|
},
|
|
63
60
|
text: {
|
|
@@ -70,9 +67,9 @@ const styles = css.create({
|
|
|
70
67
|
});
|
|
71
68
|
```
|
|
72
69
|
|
|
73
|
-
### css.global()
|
|
70
|
+
### `css.global()`
|
|
74
71
|
|
|
75
|
-
|
|
72
|
+
Define global styles:
|
|
76
73
|
|
|
77
74
|
```ts
|
|
78
75
|
css.global({
|
|
@@ -89,18 +86,12 @@ css.global({
|
|
|
89
86
|
h1: {
|
|
90
87
|
fontSize: 32,
|
|
91
88
|
},
|
|
92
|
-
h2: {
|
|
93
|
-
fontSize: 24,
|
|
94
|
-
},
|
|
95
|
-
h3: {
|
|
96
|
-
fontSize: 16,
|
|
97
|
-
},
|
|
98
89
|
});
|
|
99
90
|
```
|
|
100
91
|
|
|
101
|
-
### css.keyframes()
|
|
92
|
+
### `css.keyframes()`
|
|
102
93
|
|
|
103
|
-
|
|
94
|
+
Create keyframes for animation:
|
|
104
95
|
|
|
105
96
|
```ts
|
|
106
97
|
const fade = css.keyframes({
|
|
@@ -120,25 +111,55 @@ const styles = css.create({
|
|
|
120
111
|
});
|
|
121
112
|
```
|
|
122
113
|
|
|
123
|
-
### css.
|
|
114
|
+
### `css.defineConsts()`
|
|
115
|
+
|
|
116
|
+
Define reusable constant values with type safety:
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
const breakpoints = css.defineConsts({
|
|
120
|
+
xs: css.media.maxWidth(480),
|
|
121
|
+
sm: css.media.maxWidth(640),
|
|
122
|
+
md: css.media.maxWidth(768),
|
|
123
|
+
lg: css.media.maxWidth(1024),
|
|
124
|
+
xl: css.media.maxWidth(1280),
|
|
125
|
+
});
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Use them in your style definitions:
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
const styles = css.create({
|
|
132
|
+
container: {
|
|
133
|
+
[breakpoints.sm]: {
|
|
134
|
+
padding: 16,
|
|
135
|
+
},
|
|
136
|
+
[breakpoints.lg]: {
|
|
137
|
+
padding: 32,
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Constants are fully type-safe and readonly.
|
|
144
|
+
|
|
145
|
+
### `css.defineVars()`
|
|
124
146
|
|
|
125
|
-
|
|
126
|
-
This API allows you to declare design tokens such as spacing, sizes, or other constants, which can be referenced throughout your styles using the tokens.sm to `var(--sm)` syntax.
|
|
147
|
+
Define design tokens with CSS variables:
|
|
127
148
|
|
|
128
149
|
```ts
|
|
129
150
|
const tokens = css.defineVars({
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
151
|
+
white: 'white',
|
|
152
|
+
black: 'black',
|
|
153
|
+
textPrimary: '#eaeaea',
|
|
154
|
+
textSecondary: '#333',
|
|
155
|
+
link: 'lightblue',
|
|
156
|
+
accent: 'purple',
|
|
135
157
|
});
|
|
136
158
|
```
|
|
137
159
|
|
|
138
|
-
### css.defineTheme()
|
|
160
|
+
### `css.defineTheme()`
|
|
139
161
|
|
|
140
|
-
Define
|
|
141
|
-
A default compile to :root, and the rest as a string compile to data-theme, You can also use media and container here.
|
|
162
|
+
Define theme values with responsive and conditional support:
|
|
142
163
|
|
|
143
164
|
```ts
|
|
144
165
|
const themes = css.defineTheme({
|
|
@@ -155,40 +176,45 @@ const themes = css.defineTheme({
|
|
|
155
176
|
});
|
|
156
177
|
```
|
|
157
178
|
|
|
158
|
-
### css.color
|
|
179
|
+
### `css.color`
|
|
159
180
|
|
|
160
|
-
|
|
161
|
-
The first argument takes the color and the second argument takes the same value as opacity (string % or number).
|
|
181
|
+
Color utilities:
|
|
162
182
|
|
|
163
183
|
```ts
|
|
164
184
|
color: css.color.darken('skyblue', 0.12),
|
|
165
185
|
color: css.color.lighten('navy', 0.6),
|
|
186
|
+
|
|
166
187
|
color: css.color.skyblue,
|
|
167
|
-
color: css.color.
|
|
188
|
+
color: css.color.aqua,
|
|
189
|
+
// and many more
|
|
168
190
|
```
|
|
169
191
|
|
|
170
|
-
### cx
|
|
192
|
+
### `cx`
|
|
171
193
|
|
|
172
|
-
|
|
194
|
+
Classname merging helper:
|
|
173
195
|
|
|
174
196
|
```tsx
|
|
175
|
-
cx(css.pseudo.hover, css.pseudo.after);
|
|
176
|
-
|
|
197
|
+
cx(css.pseudo.hover, css.pseudo.after);
|
|
198
|
+
// => ":hover::after"
|
|
199
|
+
cx(styles.text, styles.box);
|
|
200
|
+
// => "text_hash box_hash"
|
|
177
201
|
```
|
|
178
202
|
|
|
179
|
-
## ESLint
|
|
203
|
+
## 🧹 ESLint Support
|
|
180
204
|
|
|
181
|
-
[@plumeria/eslint-plugin](https://www.npmjs.com/package/@plumeria/eslint-plugin)
|
|
205
|
+
Use [@plumeria/eslint-plugin](https://www.npmjs.com/package/@plumeria/eslint-plugin) for recommended rules:
|
|
182
206
|
|
|
183
207
|
### Rules: recommended
|
|
184
208
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
209
|
+
```
|
|
210
|
+
- no-inner-call: error
|
|
211
|
+
- no-unused-keys: warn
|
|
212
|
+
- sort-properties: warn
|
|
213
|
+
- validate-values: warn
|
|
214
|
+
```
|
|
189
215
|
|
|
190
|
-
|
|
216
|
+
Plumeria is best used alongside TypeScript for excellent autocomplete and validation support.
|
|
191
217
|
|
|
192
|
-
## License
|
|
218
|
+
## 📄 License
|
|
193
219
|
|
|
194
|
-
|
|
220
|
+
Plumeria is [MIT licensed](https://github.com/zss-in-js/plumeria/blob/main/LICENSE).
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { CSSHTML, CSSProperties, CreateKeyframes, CreateStyle, CreateStyleType, CreateTheme,
|
|
1
|
+
import { CSSHTML, CSSProperties, CreateKeyframes, CreateStyle, CreateStyleType, CreateTheme, CreateValues, ReturnType } from "zss-engine";
|
|
2
2
|
|
|
3
3
|
//#region src/css.d.ts
|
|
4
4
|
declare class css {
|
|
5
|
-
static create<T extends Record<string, CSSProperties>>(object: CreateStyleType<T>): ReturnType<T>;
|
|
5
|
+
static create<const T extends Record<string, CSSProperties>>(object: CreateStyleType<T>): ReturnType<T>;
|
|
6
6
|
static global(object: CSSHTML): void;
|
|
7
|
-
static defineVars<const T extends CreateVars>(object: T): { [K in keyof T]: `var(--${string})` };
|
|
8
|
-
static defineTheme<const T extends CreateTheme>(object: T): { [K in keyof T]: `var(--${string})` };
|
|
9
7
|
static keyframes(object: CreateKeyframes): string;
|
|
8
|
+
static defineConsts<const T extends CreateValues>(object: T): T;
|
|
9
|
+
static defineVars<const T extends CreateValues>(object: T): { [K in keyof T]: `var(--${string})` };
|
|
10
|
+
static defineTheme<const T extends CreateTheme>(object: T): { [K in keyof T]: `var(--${string})` };
|
|
10
11
|
static media: {
|
|
11
12
|
dark: "@media (prefers-color-scheme: dark)";
|
|
12
13
|
light: "@media (prefers-color-scheme: light)";
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,14 @@ function global(object) {
|
|
|
26
26
|
require_css.resolvePromise_2(styleSheet);
|
|
27
27
|
if (zss_engine.isDevAndTest) zss_engine.isServer ? (0, zss_engine.injectServerCSS)(base36Hash, styleSheet) : (0, zss_engine.injectClientGlobalCSS)(styleSheet);
|
|
28
28
|
}
|
|
29
|
+
const keyframes = (object) => {
|
|
30
|
+
const prefix = (0, zss_engine.genBase36Hash)(object, 8);
|
|
31
|
+
global({ [`@keyframes ${prefix}`]: object });
|
|
32
|
+
return prefix;
|
|
33
|
+
};
|
|
34
|
+
const defineConsts = (constants) => {
|
|
35
|
+
return constants;
|
|
36
|
+
};
|
|
29
37
|
const defineVars = (object) => {
|
|
30
38
|
const styles = { ":root": {} };
|
|
31
39
|
const result = {};
|
|
@@ -58,11 +66,6 @@ const defineTheme = (object) => {
|
|
|
58
66
|
global(styles);
|
|
59
67
|
return result;
|
|
60
68
|
};
|
|
61
|
-
const keyframes = (object) => {
|
|
62
|
-
const prefix = (0, zss_engine.genBase36Hash)(object, 8);
|
|
63
|
-
global({ [`@keyframes ${prefix}`]: object });
|
|
64
|
-
return prefix;
|
|
65
|
-
};
|
|
66
69
|
var css = class {
|
|
67
70
|
static create(object) {
|
|
68
71
|
return create(object);
|
|
@@ -70,15 +73,18 @@ var css = class {
|
|
|
70
73
|
static global(object) {
|
|
71
74
|
return global(object);
|
|
72
75
|
}
|
|
76
|
+
static keyframes(object) {
|
|
77
|
+
return keyframes(object);
|
|
78
|
+
}
|
|
79
|
+
static defineConsts(object) {
|
|
80
|
+
return defineConsts(object);
|
|
81
|
+
}
|
|
73
82
|
static defineVars(object) {
|
|
74
83
|
return defineVars(object);
|
|
75
84
|
}
|
|
76
85
|
static defineTheme(object) {
|
|
77
86
|
return defineTheme(object);
|
|
78
87
|
}
|
|
79
|
-
static keyframes(object) {
|
|
80
|
-
return keyframes(object);
|
|
81
|
-
}
|
|
82
88
|
static media = zss_utils.media;
|
|
83
89
|
static container = zss_utils.container;
|
|
84
90
|
static pseudo = zss_utils.pseudo;
|
package/dist/index.mjs
CHANGED
|
@@ -25,6 +25,14 @@ function global(object) {
|
|
|
25
25
|
resolvePromise_2(styleSheet);
|
|
26
26
|
if (isDevAndTest) isServer ? injectServerCSS(base36Hash, styleSheet) : injectClientGlobalCSS(styleSheet);
|
|
27
27
|
}
|
|
28
|
+
const keyframes = (object) => {
|
|
29
|
+
const prefix = genBase36Hash(object, 8);
|
|
30
|
+
global({ [`@keyframes ${prefix}`]: object });
|
|
31
|
+
return prefix;
|
|
32
|
+
};
|
|
33
|
+
const defineConsts = (constants) => {
|
|
34
|
+
return constants;
|
|
35
|
+
};
|
|
28
36
|
const defineVars = (object) => {
|
|
29
37
|
const styles = { ":root": {} };
|
|
30
38
|
const result = {};
|
|
@@ -57,11 +65,6 @@ const defineTheme = (object) => {
|
|
|
57
65
|
global(styles);
|
|
58
66
|
return result;
|
|
59
67
|
};
|
|
60
|
-
const keyframes = (object) => {
|
|
61
|
-
const prefix = genBase36Hash(object, 8);
|
|
62
|
-
global({ [`@keyframes ${prefix}`]: object });
|
|
63
|
-
return prefix;
|
|
64
|
-
};
|
|
65
68
|
var css = class {
|
|
66
69
|
static create(object) {
|
|
67
70
|
return create(object);
|
|
@@ -69,15 +72,18 @@ var css = class {
|
|
|
69
72
|
static global(object) {
|
|
70
73
|
return global(object);
|
|
71
74
|
}
|
|
75
|
+
static keyframes(object) {
|
|
76
|
+
return keyframes(object);
|
|
77
|
+
}
|
|
78
|
+
static defineConsts(object) {
|
|
79
|
+
return defineConsts(object);
|
|
80
|
+
}
|
|
72
81
|
static defineVars(object) {
|
|
73
82
|
return defineVars(object);
|
|
74
83
|
}
|
|
75
84
|
static defineTheme(object) {
|
|
76
85
|
return defineTheme(object);
|
|
77
86
|
}
|
|
78
|
-
static keyframes(object) {
|
|
79
|
-
return keyframes(object);
|
|
80
|
-
}
|
|
81
87
|
static media = media;
|
|
82
88
|
static container = container;
|
|
83
89
|
static pseudo = pseudo;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/core",
|
|
3
|
-
"version": "0.9.
|
|
4
|
-
"description": "Zero-runtime CSS
|
|
3
|
+
"version": "0.9.8",
|
|
4
|
+
"description": "Zero-runtime, expressive CSS-in-JS library for TypeScript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"css",
|
|
7
7
|
"css-in-js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"stylesheet.css"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"zss-engine": "0.2.
|
|
42
|
+
"zss-engine": "0.2.40",
|
|
43
43
|
"zss-utils": "0.2.3"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|