@plumeria/core 0.9.7 → 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 +77 -53
- 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,38 +1,38 @@
|
|
|
1
1
|
# @plumeria/core
|
|
2
2
|
|
|
3
|
-
**Zero-runtime CSS
|
|
3
|
+
**Zero-runtime, expressive CSS-in-JS library for TypeScript.**
|
|
4
4
|
|
|
5
|
-
## Installation
|
|
5
|
+
## 🌱 Installation
|
|
6
6
|
|
|
7
|
-
To
|
|
7
|
+
To get started with Plumeria, install the core package:
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
10
|
npm install @plumeria/core
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
### Compiler
|
|
13
|
+
### 🛠 Compiler (for static extraction)
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
[`@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:
|
|
17
16
|
|
|
18
17
|
```sh
|
|
19
18
|
npm install --save-dev @plumeria/compiler
|
|
20
19
|
```
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
More at: [@plumeria/compiler on npm](https://www.npmjs.com/package/@plumeria/compiler)
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
### 🎨 Stylesheet Import
|
|
24
|
+
|
|
25
|
+
In your app entry point, import the compiled CSS file:
|
|
26
26
|
|
|
27
27
|
```ts
|
|
28
28
|
import '@plumeria/core/stylesheet.css';
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
## API
|
|
31
|
+
## 📘 API Reference
|
|
32
32
|
|
|
33
|
-
### css.create()
|
|
33
|
+
### `css.create()`
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
Define a set of styles:
|
|
36
36
|
|
|
37
37
|
```ts
|
|
38
38
|
import { css } from '@plumeria/core';
|
|
@@ -48,16 +48,13 @@ const styles = css.create({
|
|
|
48
48
|
});
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
Also, any properties that are not wrapped will conform to that className.
|
|
51
|
+
Supports pseudo/media queries inline:
|
|
53
52
|
|
|
54
53
|
```ts
|
|
55
54
|
const styles = css.create({
|
|
56
55
|
box: {
|
|
57
|
-
// 900px
|
|
58
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({
|
|
@@ -92,9 +89,9 @@ css.global({
|
|
|
92
89
|
});
|
|
93
90
|
```
|
|
94
91
|
|
|
95
|
-
### css.keyframes()
|
|
92
|
+
### `css.keyframes()`
|
|
96
93
|
|
|
97
|
-
|
|
94
|
+
Create keyframes for animation:
|
|
98
95
|
|
|
99
96
|
```ts
|
|
100
97
|
const fade = css.keyframes({
|
|
@@ -114,25 +111,55 @@ const styles = css.create({
|
|
|
114
111
|
});
|
|
115
112
|
```
|
|
116
113
|
|
|
117
|
-
### 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
|
+
```
|
|
118
127
|
|
|
119
|
-
|
|
120
|
-
|
|
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()`
|
|
146
|
+
|
|
147
|
+
Define design tokens with CSS variables:
|
|
121
148
|
|
|
122
149
|
```ts
|
|
123
150
|
const tokens = css.defineVars({
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
151
|
+
white: 'white',
|
|
152
|
+
black: 'black',
|
|
153
|
+
textPrimary: '#eaeaea',
|
|
154
|
+
textSecondary: '#333',
|
|
155
|
+
link: 'lightblue',
|
|
156
|
+
accent: 'purple',
|
|
129
157
|
});
|
|
130
158
|
```
|
|
131
159
|
|
|
132
|
-
### css.defineTheme()
|
|
160
|
+
### `css.defineTheme()`
|
|
133
161
|
|
|
134
|
-
Define
|
|
135
|
-
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:
|
|
136
163
|
|
|
137
164
|
```ts
|
|
138
165
|
const themes = css.defineTheme({
|
|
@@ -149,12 +176,9 @@ const themes = css.defineTheme({
|
|
|
149
176
|
});
|
|
150
177
|
```
|
|
151
178
|
|
|
152
|
-
### css.color
|
|
153
|
-
|
|
154
|
-
Mixes #000 or #FFF into the color.
|
|
155
|
-
The first argument takes the color and the second argument takes the same value as opacity (string % or number).
|
|
179
|
+
### `css.color`
|
|
156
180
|
|
|
157
|
-
|
|
181
|
+
Color utilities:
|
|
158
182
|
|
|
159
183
|
```ts
|
|
160
184
|
color: css.color.darken('skyblue', 0.12),
|
|
@@ -162,35 +186,35 @@ color: css.color.lighten('navy', 0.6),
|
|
|
162
186
|
|
|
163
187
|
color: css.color.skyblue,
|
|
164
188
|
color: css.color.aqua,
|
|
165
|
-
//
|
|
166
|
-
color: css.color.*...,
|
|
167
|
-
|
|
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
|
-
// ":hover::after"
|
|
176
197
|
cx(css.pseudo.hover, css.pseudo.after);
|
|
177
|
-
//
|
|
178
|
-
cx(styles.text, styles
|
|
198
|
+
// => ":hover::after"
|
|
199
|
+
cx(styles.text, styles.box);
|
|
200
|
+
// => "text_hash box_hash"
|
|
179
201
|
```
|
|
180
202
|
|
|
181
|
-
## ESLint
|
|
203
|
+
## 🧹 ESLint Support
|
|
182
204
|
|
|
183
|
-
[@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:
|
|
184
206
|
|
|
185
207
|
### Rules: recommended
|
|
186
208
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
209
|
+
```
|
|
210
|
+
- no-inner-call: error
|
|
211
|
+
- no-unused-keys: warn
|
|
212
|
+
- sort-properties: warn
|
|
213
|
+
- validate-values: warn
|
|
214
|
+
```
|
|
191
215
|
|
|
192
|
-
|
|
216
|
+
Plumeria is best used alongside TypeScript for excellent autocomplete and validation support.
|
|
193
217
|
|
|
194
|
-
## License
|
|
218
|
+
## 📄 License
|
|
195
219
|
|
|
196
|
-
|
|
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": {
|