@seyuna/postcss 1.0.0-canary.7 → 1.0.0-canary.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/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # [1.0.0-canary.8](https://github.com/seyuna-corp/seyuna-postcss/compare/v1.0.0-canary.7...v1.0.0-canary.8) (2025-09-10)
2
+
3
+
4
+ ### Features
5
+
6
+ * added at-rule `each-fixed-color` ([699ee0d](https://github.com/seyuna-corp/seyuna-postcss/commit/699ee0defd1fbb0ff91a90c1e13358b1ef9832b2))
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+ * at-rule `each-seyuna-color` renamed to `each-standard-color`
12
+
1
13
  # [1.0.0-canary.7](https://github.com/seyuna-corp/seyuna-postcss/compare/v1.0.0-canary.6...v1.0.0-canary.7) (2025-09-10)
2
14
 
3
15
 
@@ -1,10 +1,10 @@
1
1
  import { AtRule } from "postcss";
2
2
  /**
3
- * Custom PostCSS plugin handler for `@each-seyuna-color` at-rules.
3
+ * Custom PostCSS plugin handler for `@each-standard-color` at-rules.
4
4
  *
5
5
  * Example usage:
6
6
  *
7
- * @each-seyuna-color {
7
+ * @each-standard-color {
8
8
  * color: white;
9
9
  * }
10
10
  *
@@ -15,4 +15,20 @@ import { AtRule } from "postcss";
15
15
  * .gamma { color: white; }
16
16
  * ...
17
17
  */
18
- export declare function eachSeyunaColor(atRule: AtRule): void;
18
+ export declare function eachStandardColor(atRule: AtRule): void;
19
+ /**
20
+ * Custom PostCSS plugin handler for `@each-fixed-color` at-rules.
21
+ *
22
+ * Example usage:
23
+ *
24
+ * @each-fixed-color {
25
+ * color: white;
26
+ * }
27
+ *
28
+ * Will generate:
29
+ *
30
+ * .primary { color: white; }
31
+ * .secondary { color: white; }
32
+ * ...
33
+ */
34
+ export declare function eachFixedColor(atRule: AtRule): void;
@@ -3,16 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.eachSeyunaColor = eachSeyunaColor;
6
+ exports.eachStandardColor = eachStandardColor;
7
+ exports.eachFixedColor = eachFixedColor;
7
8
  const postcss_1 = require("postcss");
8
9
  const fs_1 = __importDefault(require("fs"));
9
10
  const path_1 = __importDefault(require("path"));
10
11
  /**
11
- * Custom PostCSS plugin handler for `@each-seyuna-color` at-rules.
12
+ * Custom PostCSS plugin handler for `@each-standard-color` at-rules.
12
13
  *
13
14
  * Example usage:
14
15
  *
15
- * @each-seyuna-color {
16
+ * @each-standard-color {
16
17
  * color: white;
17
18
  * }
18
19
  *
@@ -23,15 +24,57 @@ const path_1 = __importDefault(require("path"));
23
24
  * .gamma { color: white; }
24
25
  * ...
25
26
  */
26
- function eachSeyunaColor(atRule) {
27
+ function eachStandardColor(atRule) {
27
28
  // Read seyuna.json from project root
28
29
  const jsonPath = path_1.default.resolve(process.cwd(), "seyuna.json");
29
30
  const fileContents = fs_1.default.readFileSync(jsonPath, "utf-8");
30
31
  const data = JSON.parse(fileContents);
31
32
  const hues = data.ui.theme.hues;
33
+ const hueNamesSet = new Set(Object.keys(hues));
34
+ // Guard against atRule.nodes being undefined
35
+ const nodes = atRule.nodes ?? [];
36
+ const generatedRules = [];
37
+ // Helper to clone nodes and replace {name} placeholder
38
+ const cloneNodesWithName = (name) => nodes.map((node) => {
39
+ const cloned = node.clone();
40
+ // Only process declarations
41
+ if (cloned.type === "decl") {
42
+ const decl = cloned;
43
+ decl.value = decl.value.replace(/\{name\}/g, name);
44
+ }
45
+ return cloned;
46
+ });
47
+ // Generate rules for each hue
48
+ for (const hueName of hueNamesSet) {
49
+ const rule = new postcss_1.Rule({ selector: `.${hueName}` });
50
+ cloneNodesWithName(hueName).forEach((n) => rule.append(n));
51
+ generatedRules.push(rule);
52
+ }
53
+ // Replace the original @each-seyuna-color at-rule with all the generated rules
54
+ atRule.replaceWith(...generatedRules);
55
+ }
56
+ /**
57
+ * Custom PostCSS plugin handler for `@each-fixed-color` at-rules.
58
+ *
59
+ * Example usage:
60
+ *
61
+ * @each-fixed-color {
62
+ * color: white;
63
+ * }
64
+ *
65
+ * Will generate:
66
+ *
67
+ * .primary { color: white; }
68
+ * .secondary { color: white; }
69
+ * ...
70
+ */
71
+ function eachFixedColor(atRule) {
72
+ // Read seyuna.json from project root
73
+ const jsonPath = path_1.default.resolve(process.cwd(), "seyuna.json");
74
+ const fileContents = fs_1.default.readFileSync(jsonPath, "utf-8");
75
+ const data = JSON.parse(fileContents);
32
76
  const light_colors = data.ui.theme.light;
33
77
  const dark_colors = data.ui.theme.dark;
34
- const hueNamesSet = new Set(Object.keys(hues));
35
78
  const lightColorNamesSet = new Set(Object.keys(light_colors));
36
79
  const darkColorNamesSet = new Set(Object.keys(dark_colors));
37
80
  const mergedColorNamesSet = new Set([
@@ -51,12 +94,6 @@ function eachSeyunaColor(atRule) {
51
94
  }
52
95
  return cloned;
53
96
  });
54
- // Generate rules for each hue
55
- for (const hueName of hueNamesSet) {
56
- const rule = new postcss_1.Rule({ selector: `.${hueName}` });
57
- cloneNodesWithName(hueName).forEach((n) => rule.append(n));
58
- generatedRules.push(rule);
59
- }
60
97
  // Generate rules for mergedColorNamesSet
61
98
  for (const colorName of mergedColorNamesSet) {
62
99
  const rule = new postcss_1.Rule({ selector: `.${colorName}` });
@@ -11,7 +11,8 @@ const container_1 = __importDefault(require("./container"));
11
11
  const color_1 = require("./color");
12
12
  // Ordered array ensures execution order
13
13
  exports.atRuleHandlers = [
14
- { name: "each-seyuna-color", handler: color_1.eachSeyunaColor }, // first
14
+ { name: "each-standard-color", handler: color_1.eachStandardColor }, // first
15
+ { name: "each-fixed-color", handler: color_1.eachFixedColor },
15
16
  { name: "light", handler: light_1.default },
16
17
  { name: "dark", handler: dark_1.default },
17
18
  { name: "container", handler: container_1.default },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seyuna/postcss",
3
- "version": "1.0.0-canary.7",
3
+ "version": "1.0.0-canary.8",
4
4
  "description": "Seyuna UI's postcss plugin",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -4,11 +4,11 @@ import path from "path";
4
4
  import { SeyunaConfig } from "../types";
5
5
 
6
6
  /**
7
- * Custom PostCSS plugin handler for `@each-seyuna-color` at-rules.
7
+ * Custom PostCSS plugin handler for `@each-standard-color` at-rules.
8
8
  *
9
9
  * Example usage:
10
10
  *
11
- * @each-seyuna-color {
11
+ * @each-standard-color {
12
12
  * color: white;
13
13
  * }
14
14
  *
@@ -19,17 +19,66 @@ import { SeyunaConfig } from "../types";
19
19
  * .gamma { color: white; }
20
20
  * ...
21
21
  */
22
- export function eachSeyunaColor(atRule: AtRule) {
22
+ export function eachStandardColor(atRule: AtRule) {
23
23
  // Read seyuna.json from project root
24
24
  const jsonPath = path.resolve(process.cwd(), "seyuna.json");
25
25
  const fileContents = fs.readFileSync(jsonPath, "utf-8");
26
26
  const data: SeyunaConfig = JSON.parse(fileContents);
27
-
28
27
  const hues = data.ui.theme.hues;
28
+ const hueNamesSet = new Set(Object.keys(hues));
29
+
30
+ // Guard against atRule.nodes being undefined
31
+ const nodes = atRule.nodes ?? [];
32
+
33
+ const generatedRules: Rule[] = [];
34
+
35
+ // Helper to clone nodes and replace {name} placeholder
36
+ const cloneNodesWithName = (name: string) =>
37
+ nodes.map((node) => {
38
+ const cloned = node.clone();
39
+
40
+ // Only process declarations
41
+ if (cloned.type === "decl") {
42
+ const decl = cloned as Declaration;
43
+ decl.value = decl.value.replace(/\{name\}/g, name);
44
+ }
45
+
46
+ return cloned;
47
+ });
48
+
49
+ // Generate rules for each hue
50
+ for (const hueName of hueNamesSet) {
51
+ const rule = new Rule({ selector: `.${hueName}` });
52
+ cloneNodesWithName(hueName).forEach((n) => rule.append(n));
53
+ generatedRules.push(rule);
54
+ }
55
+
56
+ // Replace the original @each-seyuna-color at-rule with all the generated rules
57
+ atRule.replaceWith(...generatedRules);
58
+ }
59
+
60
+ /**
61
+ * Custom PostCSS plugin handler for `@each-fixed-color` at-rules.
62
+ *
63
+ * Example usage:
64
+ *
65
+ * @each-fixed-color {
66
+ * color: white;
67
+ * }
68
+ *
69
+ * Will generate:
70
+ *
71
+ * .primary { color: white; }
72
+ * .secondary { color: white; }
73
+ * ...
74
+ */
75
+ export function eachFixedColor(atRule: AtRule) {
76
+ // Read seyuna.json from project root
77
+ const jsonPath = path.resolve(process.cwd(), "seyuna.json");
78
+ const fileContents = fs.readFileSync(jsonPath, "utf-8");
79
+ const data: SeyunaConfig = JSON.parse(fileContents);
29
80
  const light_colors = data.ui.theme.light;
30
81
  const dark_colors = data.ui.theme.dark;
31
-
32
- const hueNamesSet = new Set(Object.keys(hues));
33
82
  const lightColorNamesSet = new Set(Object.keys(light_colors));
34
83
  const darkColorNamesSet = new Set(Object.keys(dark_colors));
35
84
 
@@ -57,13 +106,6 @@ export function eachSeyunaColor(atRule: AtRule) {
57
106
  return cloned;
58
107
  });
59
108
 
60
- // Generate rules for each hue
61
- for (const hueName of hueNamesSet) {
62
- const rule = new Rule({ selector: `.${hueName}` });
63
- cloneNodesWithName(hueName).forEach((n) => rule.append(n));
64
- generatedRules.push(rule);
65
- }
66
-
67
109
  // Generate rules for mergedColorNamesSet
68
110
  for (const colorName of mergedColorNamesSet) {
69
111
  const rule = new Rule({ selector: `.${colorName}` });
@@ -2,7 +2,7 @@
2
2
  import dark from "./dark";
3
3
  import light from "./light";
4
4
  import container from "./container";
5
- import { eachSeyunaColor } from "./color";
5
+ import { eachStandardColor, eachFixedColor } from "./color";
6
6
  import type { AtRule } from "postcss";
7
7
 
8
8
  // Each handler has a name (matches the at-rule) and the function
@@ -13,7 +13,8 @@ export interface AtRuleHandler {
13
13
 
14
14
  // Ordered array ensures execution order
15
15
  export const atRuleHandlers: AtRuleHandler[] = [
16
- { name: "each-seyuna-color", handler: eachSeyunaColor }, // first
16
+ { name: "each-standard-color", handler: eachStandardColor }, // first
17
+ { name: "each-fixed-color", handler: eachFixedColor },
17
18
  { name: "light", handler: light },
18
19
  { name: "dark", handler: dark },
19
20
  { name: "container", handler: container },