@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.
- package/.vscode/settings.json +4 -0
- package/dist/at-rules/dark.d.ts +1 -1
- package/dist/at-rules/dark.js +7 -4
- package/dist/at-rules/light.d.ts +1 -1
- package/dist/at-rules/light.js +7 -4
- package/dist/plugin.js +4 -0
- package/package.json +1 -1
- package/src/at-rules/dark.ts +8 -5
- package/src/at-rules/light.ts +8 -5
- package/src/plugin.ts +9 -1
package/dist/at-rules/dark.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AtRule } from "postcss";
|
|
2
2
|
export default function dark(atRule: AtRule): void;
|
package/dist/at-rules/dark.js
CHANGED
|
@@ -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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
|
11
|
+
// Replace @dark atRule with the new nested rule
|
|
12
|
+
atRule.replaceWith(nestedRule);
|
|
10
13
|
}
|
package/dist/at-rules/light.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AtRule } from "postcss";
|
|
2
2
|
export default function light(atRule: AtRule): void;
|
package/dist/at-rules/light.js
CHANGED
|
@@ -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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
|
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
package/src/at-rules/dark.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { Rule, type AtRule } from "postcss";
|
|
2
2
|
|
|
3
3
|
export default function dark(atRule: AtRule) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
9
|
+
|
|
10
|
+
// Replace @dark atRule with the new nested rule
|
|
11
|
+
atRule.replaceWith(nestedRule);
|
|
9
12
|
}
|
package/src/at-rules/light.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { Rule, type AtRule } from "postcss";
|
|
2
2
|
|
|
3
3
|
export default function light(atRule: AtRule) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
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> = (
|
|
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
|
|