@seyuna/postcss 0.0.1-dev.7 → 0.0.1-dev.9

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.
@@ -0,0 +1,4 @@
1
+ {
2
+ "editor.formatOnSave": true,
3
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
4
+ }
@@ -1,2 +1,2 @@
1
- import type { AtRule } from "postcss";
1
+ import { type AtRule } from "postcss";
2
2
  export default function dark(atRule: AtRule): void;
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = dark;
4
+ const postcss_1 = require("postcss");
4
5
  function dark(atRule) {
5
- const nestRule = atRule.clone({
6
- name: "nest",
7
- params: `[data-mode="dark"] &`,
6
+ // Create a new nested rule: [data-mode="dark"] & { ... }
7
+ const nestedRule = new postcss_1.Rule({
8
+ selector: `[data-mode="dark"] &`,
9
+ nodes: atRule.nodes, // move children inside
8
10
  });
9
- atRule.replaceWith(nestRule);
11
+ // Replace @dark atRule with the new nested rule
12
+ atRule.replaceWith(nestedRule);
10
13
  }
@@ -1,2 +1,2 @@
1
- import type { AtRule } from "postcss";
1
+ import { type AtRule } from "postcss";
2
2
  export default function light(atRule: AtRule): void;
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = light;
4
+ const postcss_1 = require("postcss");
4
5
  function light(atRule) {
5
- const nestRule = atRule.clone({
6
- name: "nest",
7
- params: `[data-mode="light"] &`,
6
+ // Create a new nested rule: [data-mode="light"] & { ... }
7
+ const nestedRule = new postcss_1.Rule({
8
+ selector: `[data-mode="light"] &`,
9
+ nodes: atRule.nodes, // move children inside
8
10
  });
9
- atRule.replaceWith(nestRule);
11
+ // Replace @light atRule with the new nested rule
12
+ atRule.replaceWith(nestedRule);
10
13
  }
package/dist/plugin.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.dynamicFunctionsPlugin = void 0;
4
4
  const functions_1 = require("./functions");
5
+ const at_rules_1 = require("./at-rules");
5
6
  const dynamicFunctionsPlugin = (opts = {}) => {
6
7
  const fnMap = { ...functions_1.functions, ...opts.functions };
7
8
  return {
@@ -19,6 +20,9 @@ const dynamicFunctionsPlugin = (opts = {}) => {
19
20
  }
20
21
  decl.value = value;
21
22
  },
23
+ AtRule: {
24
+ ...at_rules_1.atRuleHandlers,
25
+ },
22
26
  };
23
27
  };
24
28
  exports.dynamicFunctionsPlugin = dynamicFunctionsPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seyuna/postcss",
3
- "version": "0.0.1-dev.7",
3
+ "version": "0.0.1-dev.9",
4
4
  "description": "Seyuna UI's postcss plugin",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,9 +1,12 @@
1
- import type { AtRule } from "postcss";
1
+ import { Rule, type AtRule } from "postcss";
2
2
 
3
3
  export default function dark(atRule: AtRule) {
4
- const nestRule = atRule.clone({
5
- name: "nest",
6
- params: `[data-mode="dark"] &`,
4
+ // Create a new nested rule: [data-mode="dark"] & { ... }
5
+ const nestedRule = new Rule({
6
+ selector: `[data-mode="dark"] &`,
7
+ nodes: atRule.nodes, // move children inside
7
8
  });
8
- atRule.replaceWith(nestRule);
9
+
10
+ // Replace @dark atRule with the new nested rule
11
+ atRule.replaceWith(nestedRule);
9
12
  }
@@ -1,9 +1,12 @@
1
- import type { AtRule } from "postcss";
1
+ import { Rule, type AtRule } from "postcss";
2
2
 
3
3
  export default function light(atRule: AtRule) {
4
- const nestRule = atRule.clone({
5
- name: "nest",
6
- params: `[data-mode="light"] &`,
4
+ // Create a new nested rule: [data-mode="light"] & { ... }
5
+ const nestedRule = new Rule({
6
+ selector: `[data-mode="light"] &`,
7
+ nodes: atRule.nodes, // move children inside
7
8
  });
8
- atRule.replaceWith(nestRule);
9
+
10
+ // Replace @light atRule with the new nested rule
11
+ atRule.replaceWith(nestedRule);
9
12
  }
package/src/plugin.ts CHANGED
@@ -1,15 +1,19 @@
1
1
  import { PluginCreator } from "postcss";
2
2
  import { functions } from "./functions";
3
+ import { atRuleHandlers } from "./at-rules";
3
4
 
4
5
  export interface PluginOptions {
5
6
  functions?: Record<string, (...args: string[]) => string>;
6
7
  }
7
8
 
8
- export const dynamicFunctionsPlugin: PluginCreator<PluginOptions> = (opts = {}) => {
9
+ export const dynamicFunctionsPlugin: PluginCreator<PluginOptions> = (
10
+ opts = {}
11
+ ) => {
9
12
  const fnMap = { ...functions, ...opts.functions };
10
13
 
11
14
  return {
12
15
  postcssPlugin: "postcss-dynamic-functions",
16
+
13
17
  Declaration(decl) {
14
18
  let value = decl.value;
15
19
 
@@ -26,6 +30,10 @@ export const dynamicFunctionsPlugin: PluginCreator<PluginOptions> = (opts = {})
26
30
 
27
31
  decl.value = value;
28
32
  },
33
+
34
+ AtRule: {
35
+ ...atRuleHandlers,
36
+ },
29
37
  };
30
38
  };
31
39