@seyuna/postcss 1.0.0-canary.29 → 1.0.0-canary.30
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/CHANGELOG.md +12 -0
- package/README.md +29 -24
- package/dist/config.d.ts +6 -2
- package/dist/config.js +5 -5
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +1 -6
- package/dist/types.d.ts +3 -4
- package/package.json +1 -1
- package/src/config.ts +10 -9
- package/src/errors.ts +8 -8
- package/src/types.ts +6 -6
- package/tests/plugin.test.ts +0 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# [1.0.0-canary.30](https://github.com/seyuna-corp/seyuna-postcss/compare/v1.0.0-canary.29...v1.0.0-canary.30) (2026-01-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* remove strict mode usage in errors and cleanup tests ([cdbfa50](https://github.com/seyuna-corp/seyuna-postcss/commit/cdbfa50537c216bb8afc46b22e7391233eacb105))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* simplify plugin by removing configurable options and hardcoding modeAttribute ([f5033d6](https://github.com/seyuna-corp/seyuna-postcss/commit/f5033d6a32f3fd1c98a9c2759f6bfcbffcc9a2be))
|
|
12
|
+
|
|
1
13
|
# [1.0.0-canary.29](https://github.com/seyuna-corp/seyuna-postcss/compare/v1.0.0-canary.28...v1.0.0-canary.29) (2026-01-21)
|
|
2
14
|
|
|
3
15
|
|
package/README.md
CHANGED
|
@@ -53,7 +53,7 @@ CSS shouldn't be bloated with repetitive color definitions and hardcoded values.
|
|
|
53
53
|
}
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
Your color palette
|
|
56
|
+
Your color palette is defined directly in your CSS. Your stylesheets reference colors by name. Change a value once in `@config`, and it updates everywhere.
|
|
57
57
|
|
|
58
58
|
### 4. Seamless Color Functions
|
|
59
59
|
|
|
@@ -82,7 +82,7 @@ These functions compile to pure CSS using `calc()` and CSS custom properties. No
|
|
|
82
82
|
### Installation
|
|
83
83
|
|
|
84
84
|
```bash
|
|
85
|
-
npm install @seyuna/postcss postcss --save-dev
|
|
85
|
+
npm install @seyuna/postcss postcss-import postcss-advanced-variables postcss-preset-env --save-dev
|
|
86
86
|
```
|
|
87
87
|
|
|
88
88
|
### PostCSS Configuration
|
|
@@ -90,11 +90,20 @@ npm install @seyuna/postcss postcss --save-dev
|
|
|
90
90
|
```javascript
|
|
91
91
|
// postcss.config.js
|
|
92
92
|
import seyunaPostcss from "@seyuna/postcss";
|
|
93
|
+
import postcssImport from "postcss-import";
|
|
94
|
+
import postcssAdvancedVariables from "postcss-advanced-variables";
|
|
95
|
+
import postcssPresetEnv from "postcss-preset-env";
|
|
93
96
|
|
|
94
97
|
export default {
|
|
95
98
|
plugins: [
|
|
96
|
-
seyunaPostcss(
|
|
97
|
-
|
|
99
|
+
seyunaPostcss(),
|
|
100
|
+
postcssImport,
|
|
101
|
+
postcssAdvancedVariables,
|
|
102
|
+
postcssPresetEnv({
|
|
103
|
+
stage: 3,
|
|
104
|
+
features: {
|
|
105
|
+
"nesting-rules": true,
|
|
106
|
+
},
|
|
98
107
|
}),
|
|
99
108
|
],
|
|
100
109
|
};
|
|
@@ -160,16 +169,22 @@ Standard colors define only a hue angle in the config and inherit theme lightnes
|
|
|
160
169
|
|
|
161
170
|
### Fixed Colors
|
|
162
171
|
|
|
163
|
-
Fixed colors have explicit lightness, chroma, and hue values.
|
|
172
|
+
Fixed colors have explicit lightness, chroma, and hue values. They can also be overridden per theme mode.
|
|
164
173
|
|
|
165
174
|
```css
|
|
166
175
|
@config "seyuna" {
|
|
167
176
|
--color-white: 1 0 0;
|
|
177
|
+
--color-brand: 0.5 0.2 100; /* Global value */
|
|
178
|
+
--light-color-brand: 1 0 100; /* Light mode override */
|
|
168
179
|
}
|
|
169
180
|
|
|
170
181
|
.logo {
|
|
171
182
|
color: SeyunaFixedColor(white);
|
|
172
183
|
}
|
|
184
|
+
|
|
185
|
+
.highlight {
|
|
186
|
+
background: SeyunaFixedColor(brand);
|
|
187
|
+
}
|
|
173
188
|
```
|
|
174
189
|
|
|
175
190
|
---
|
|
@@ -271,32 +286,22 @@ Generate utility classes by iterating over your color configuration:
|
|
|
271
286
|
|
|
272
287
|
Within the `@config "seyuna"` block, you can use the following property prefixes:
|
|
273
288
|
|
|
274
|
-
| Prefix
|
|
275
|
-
|
|
|
276
|
-
| `--hue-*`
|
|
277
|
-
| `--color-*`
|
|
278
|
-
| `--light-*` |
|
|
279
|
-
| `--
|
|
289
|
+
| Prefix | Description | Example |
|
|
290
|
+
| :---------------- | :--------------------------------------------------------------- | :---------------------------------- |
|
|
291
|
+
| `--hue-*` | Defines a hue angle for a standard color | `--hue-primary: 240;` |
|
|
292
|
+
| `--color-*` | Defines a global fixed color (L C H) | `--color-brand: 0.6 0.2 120;` |
|
|
293
|
+
| `--light-color-*` | Overrides a fixed color for light mode | `--light-color-brand: 0.8 0.1 120;` |
|
|
294
|
+
| `--light-*` | Configures the light theme (lightness, chroma, background, text) | `--light-lightness: 0.8;` |
|
|
295
|
+
| `--dark-color-*` | Overrides a fixed color for dark mode | `--dark-color-brand: 0.4 0.1 120;` |
|
|
296
|
+
| `--dark-*` | Configures the dark theme | `--dark-background: 0 0 0;` |
|
|
280
297
|
|
|
281
298
|
For colors and background/text, use a space-separated list of values: `lightness chroma hue`.
|
|
282
299
|
|
|
283
300
|
---
|
|
284
301
|
|
|
285
|
-
## Plugin Options
|
|
286
|
-
|
|
287
|
-
```javascript
|
|
288
|
-
seyunaPostcss({
|
|
289
|
-
configPath: "seyuna.json", // Path to your config file
|
|
290
|
-
modeAttribute: "data-mode", // Attribute for theme switching
|
|
291
|
-
strict: false, // Throw errors for missing colors
|
|
292
|
-
});
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
---
|
|
296
|
-
|
|
297
302
|
## Accessing Config Values
|
|
298
303
|
|
|
299
|
-
Use `SeyunaTheme()` to access any value from your
|
|
304
|
+
Use `SeyunaTheme()` to access any value from your design tokens:
|
|
300
305
|
|
|
301
306
|
```css
|
|
302
307
|
.container {
|
package/dist/config.d.ts
CHANGED
|
@@ -2,9 +2,13 @@ import { SeyunaConfig, PluginOptions } from "./types.js";
|
|
|
2
2
|
export type { PluginOptions, PluginContext, FunctionMap } from "./types.js";
|
|
3
3
|
export declare function loadConfig(options?: PluginOptions): {
|
|
4
4
|
config: SeyunaConfig;
|
|
5
|
-
options: Required<PluginOptions
|
|
5
|
+
options: Required<PluginOptions> & {
|
|
6
|
+
modeAttribute: string;
|
|
7
|
+
};
|
|
6
8
|
};
|
|
7
9
|
export declare function loadConfigAsync(options?: PluginOptions): Promise<{
|
|
8
10
|
config: SeyunaConfig;
|
|
9
|
-
options: Required<PluginOptions
|
|
11
|
+
options: Required<PluginOptions> & {
|
|
12
|
+
modeAttribute: string;
|
|
13
|
+
};
|
|
10
14
|
}>;
|
package/dist/config.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
const DEFAULT_OPTIONS = {
|
|
2
|
-
configPath: "seyuna.json",
|
|
3
|
-
modeAttribute: "data-mode",
|
|
4
|
-
strict: false,
|
|
5
2
|
config: undefined,
|
|
6
3
|
functions: undefined,
|
|
7
4
|
};
|
|
8
5
|
export function loadConfig(options = {}) {
|
|
9
6
|
const mergedOptions = { ...DEFAULT_OPTIONS, ...options };
|
|
10
7
|
if (mergedOptions.config) {
|
|
11
|
-
return {
|
|
8
|
+
return {
|
|
9
|
+
config: mergedOptions.config,
|
|
10
|
+
options: { ...mergedOptions, modeAttribute: "data-mode" },
|
|
11
|
+
};
|
|
12
12
|
}
|
|
13
13
|
// Return base empty config - we'll populate it from CSS
|
|
14
14
|
return {
|
|
@@ -34,7 +34,7 @@ export function loadConfig(options = {}) {
|
|
|
34
34
|
},
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
|
-
options: mergedOptions,
|
|
37
|
+
options: { ...mergedOptions, modeAttribute: "data-mode" },
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
export async function loadConfigAsync(options = {}) {
|
package/dist/errors.d.ts
CHANGED
package/dist/errors.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
export function reportError(message, node, context, options = {}) {
|
|
2
2
|
const { options: pluginOptions } = context;
|
|
3
3
|
const formattedMessage = `[Seyuna PostCSS] ${message}`;
|
|
4
|
-
|
|
5
|
-
throw node.error(formattedMessage, options);
|
|
6
|
-
}
|
|
7
|
-
else {
|
|
8
|
-
reportWarning(formattedMessage, node, context);
|
|
9
|
-
}
|
|
4
|
+
reportWarning(formattedMessage, node, context);
|
|
10
5
|
}
|
|
11
6
|
export function reportWarning(message, node, context) {
|
|
12
7
|
if (context?.result) {
|
package/dist/types.d.ts
CHANGED
|
@@ -44,15 +44,14 @@ export interface SeyunaConfig {
|
|
|
44
44
|
}
|
|
45
45
|
export type FunctionMap = Record<string, (context: PluginContext, ...args: string[]) => string>;
|
|
46
46
|
export interface PluginOptions {
|
|
47
|
-
configPath?: string;
|
|
48
|
-
modeAttribute?: string;
|
|
49
|
-
strict?: boolean;
|
|
50
47
|
config?: SeyunaConfig;
|
|
51
48
|
functions?: FunctionMap;
|
|
52
49
|
}
|
|
53
50
|
export interface PluginContext {
|
|
54
51
|
config: SeyunaConfig;
|
|
55
|
-
options: Required<PluginOptions
|
|
52
|
+
options: Required<PluginOptions> & {
|
|
53
|
+
modeAttribute: string;
|
|
54
|
+
};
|
|
56
55
|
functions: FunctionMap;
|
|
57
56
|
result?: any;
|
|
58
57
|
}
|
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -11,21 +11,21 @@ import {
|
|
|
11
11
|
export type { PluginOptions, PluginContext, FunctionMap } from "./types.js";
|
|
12
12
|
|
|
13
13
|
const DEFAULT_OPTIONS: Required<PluginOptions> = {
|
|
14
|
-
configPath: "seyuna.json",
|
|
15
|
-
modeAttribute: "data-mode",
|
|
16
|
-
strict: false,
|
|
17
14
|
config: undefined as any,
|
|
18
15
|
functions: undefined as any,
|
|
19
16
|
};
|
|
20
17
|
|
|
21
18
|
export function loadConfig(options: PluginOptions = {}): {
|
|
22
19
|
config: SeyunaConfig;
|
|
23
|
-
options: Required<PluginOptions
|
|
20
|
+
options: Required<PluginOptions> & { modeAttribute: string };
|
|
24
21
|
} {
|
|
25
22
|
const mergedOptions = { ...DEFAULT_OPTIONS, ...options };
|
|
26
23
|
|
|
27
24
|
if (mergedOptions.config) {
|
|
28
|
-
return {
|
|
25
|
+
return {
|
|
26
|
+
config: mergedOptions.config,
|
|
27
|
+
options: { ...mergedOptions, modeAttribute: "data-mode" },
|
|
28
|
+
};
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
// Return base empty config - we'll populate it from CSS
|
|
@@ -52,12 +52,13 @@ export function loadConfig(options: PluginOptions = {}): {
|
|
|
52
52
|
},
|
|
53
53
|
},
|
|
54
54
|
} as any,
|
|
55
|
-
options: mergedOptions,
|
|
55
|
+
options: { ...mergedOptions, modeAttribute: "data-mode" },
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
export async function loadConfigAsync(
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
export async function loadConfigAsync(options: PluginOptions = {}): Promise<{
|
|
60
|
+
config: SeyunaConfig;
|
|
61
|
+
options: Required<PluginOptions> & { modeAttribute: string };
|
|
62
|
+
}> {
|
|
62
63
|
return loadConfig(options);
|
|
63
64
|
}
|
package/src/errors.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
// import type { Node } from 'postcss';
|
|
2
|
-
import { PluginContext } from
|
|
2
|
+
import { PluginContext } from "./types.js";
|
|
3
3
|
|
|
4
4
|
export function reportError(
|
|
5
5
|
message: string,
|
|
6
6
|
node: any,
|
|
7
7
|
context: PluginContext,
|
|
8
|
-
options: { word?: string; index?: number } = {}
|
|
8
|
+
options: { word?: string; index?: number } = {},
|
|
9
9
|
) {
|
|
10
10
|
const { options: pluginOptions } = context;
|
|
11
11
|
const formattedMessage = `[Seyuna PostCSS] ${message}`;
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
throw node.error(formattedMessage, options);
|
|
15
|
-
} else {
|
|
16
|
-
reportWarning(formattedMessage, node, context);
|
|
17
|
-
}
|
|
13
|
+
reportWarning(formattedMessage, node, context);
|
|
18
14
|
}
|
|
19
15
|
|
|
20
|
-
export function reportWarning(
|
|
16
|
+
export function reportWarning(
|
|
17
|
+
message: string,
|
|
18
|
+
node: any,
|
|
19
|
+
context?: PluginContext,
|
|
20
|
+
) {
|
|
21
21
|
if (context?.result) {
|
|
22
22
|
node.warn(context.result, `[Seyuna PostCSS] ${message}`);
|
|
23
23
|
} else {
|
package/src/types.ts
CHANGED
|
@@ -53,19 +53,19 @@ export interface SeyunaConfig {
|
|
|
53
53
|
|
|
54
54
|
// Shared types to avoid circular dependencies between config.ts and parser.ts
|
|
55
55
|
|
|
56
|
-
export type FunctionMap = Record<
|
|
56
|
+
export type FunctionMap = Record<
|
|
57
|
+
string,
|
|
58
|
+
(context: PluginContext, ...args: string[]) => string
|
|
59
|
+
>;
|
|
57
60
|
|
|
58
61
|
export interface PluginOptions {
|
|
59
|
-
configPath?: string;
|
|
60
|
-
modeAttribute?: string;
|
|
61
|
-
strict?: boolean;
|
|
62
62
|
config?: SeyunaConfig;
|
|
63
63
|
functions?: FunctionMap;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
export interface PluginContext {
|
|
67
67
|
config: SeyunaConfig;
|
|
68
|
-
options: Required<PluginOptions
|
|
68
|
+
options: Required<PluginOptions> & { modeAttribute: string };
|
|
69
69
|
functions: FunctionMap;
|
|
70
70
|
result?: any; // PostCSS Result
|
|
71
|
-
}
|
|
71
|
+
}
|
package/tests/plugin.test.ts
CHANGED
|
@@ -132,27 +132,6 @@ describe("Seyuna PostCSS Plugin", () => {
|
|
|
132
132
|
expect(result.css).toContain(output);
|
|
133
133
|
});
|
|
134
134
|
|
|
135
|
-
it("throws error for unknown standard color in strict mode", async () => {
|
|
136
|
-
const input = ".test { color: SeyunaStandardColor(unknown); }";
|
|
137
|
-
await expect(
|
|
138
|
-
run(input, { config: mockConfig, strict: true }),
|
|
139
|
-
).rejects.toThrow(/Standard color 'unknown' not found/);
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it("throws error for unknown fixed color in strict mode", async () => {
|
|
143
|
-
const input = ".test { color: SeyunaFixedColor(unknown); }";
|
|
144
|
-
await expect(
|
|
145
|
-
run(input, { config: mockConfig, strict: true }),
|
|
146
|
-
).rejects.toThrow(/Fixed color 'unknown' not found/);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it("throws error for unknown color in SeyunaAlpha() in strict mode", async () => {
|
|
150
|
-
const input = ".test { color: SeyunaAlpha(unknown, 0.5); }";
|
|
151
|
-
await expect(
|
|
152
|
-
run(input, { config: mockConfig, strict: true }),
|
|
153
|
-
).rejects.toThrow(/Color 'unknown' not found in seyuna.json/);
|
|
154
|
-
});
|
|
155
|
-
|
|
156
135
|
it('processes @import "seyuna"', async () => {
|
|
157
136
|
const input = '@import "seyuna";';
|
|
158
137
|
const result = await run(input, { config: mockConfig });
|