@seyuna/postcss 1.0.0-canary.3 → 1.0.0-canary.4
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 +7 -0
- package/dist/at-rules/dark.d.ts +21 -0
- package/dist/at-rules/dark.js +48 -11
- package/dist/at-rules/light.d.ts +21 -0
- package/dist/at-rules/light.js +48 -11
- package/package.json +1 -1
- package/src/at-rules/dark.ts +48 -12
- package/src/at-rules/light.ts +48 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.0.0-canary.4](https://github.com/seyuna-corp/seyuna-postcss/compare/v1.0.0-canary.3...v1.0.0-canary.4) (2025-08-24)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* at-rules for mode now ensure that [data-mode=system] before enforcing prefers-color-scheme ([475055d](https://github.com/seyuna-corp/seyuna-postcss/commit/475055db1d5662d25631953af669bf64b2e0468e))
|
|
7
|
+
|
|
1
8
|
# [1.0.0-canary.3](https://github.com/seyuna-corp/seyuna-postcss/compare/v1.0.0-canary.2...v1.0.0-canary.3) (2025-08-24)
|
|
2
9
|
|
|
3
10
|
|
package/dist/at-rules/dark.d.ts
CHANGED
|
@@ -1,2 +1,23 @@
|
|
|
1
1
|
import { AtRule } from "postcss";
|
|
2
|
+
/**
|
|
3
|
+
* Custom PostCSS plugin handler for `@dark` at-rules.
|
|
4
|
+
*
|
|
5
|
+
* Transforms:
|
|
6
|
+
*
|
|
7
|
+
* @dark {
|
|
8
|
+
* color: white;
|
|
9
|
+
* }
|
|
10
|
+
*
|
|
11
|
+
* Into:
|
|
12
|
+
*
|
|
13
|
+
* @media (prefers-color-scheme: dark) {
|
|
14
|
+
* [data-mode="system"] & {
|
|
15
|
+
* color: white;
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* [data-mode="dark"] & {
|
|
20
|
+
* color: white;
|
|
21
|
+
* }
|
|
22
|
+
*/
|
|
2
23
|
export default function dark(atRule: AtRule): void;
|
package/dist/at-rules/dark.js
CHANGED
|
@@ -2,27 +2,64 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = dark;
|
|
4
4
|
const postcss_1 = require("postcss");
|
|
5
|
+
/**
|
|
6
|
+
* Custom PostCSS plugin handler for `@dark` at-rules.
|
|
7
|
+
*
|
|
8
|
+
* Transforms:
|
|
9
|
+
*
|
|
10
|
+
* @dark {
|
|
11
|
+
* color: white;
|
|
12
|
+
* }
|
|
13
|
+
*
|
|
14
|
+
* Into:
|
|
15
|
+
*
|
|
16
|
+
* @media (prefers-color-scheme: dark) {
|
|
17
|
+
* [data-mode="system"] & {
|
|
18
|
+
* color: white;
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* [data-mode="dark"] & {
|
|
23
|
+
* color: white;
|
|
24
|
+
* }
|
|
25
|
+
*/
|
|
5
26
|
function dark(atRule) {
|
|
6
27
|
const clonedNodes = [];
|
|
7
|
-
// Clone all child nodes
|
|
28
|
+
// Clone all child nodes inside the @dark block
|
|
29
|
+
// (so we can reuse them in both generated rules).
|
|
8
30
|
atRule.each((node) => {
|
|
9
31
|
clonedNodes.push(node.clone());
|
|
10
32
|
});
|
|
11
|
-
|
|
12
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Rule 1: [data-mode="dark"] & { ... }
|
|
35
|
+
*
|
|
36
|
+
* This applies the styles when the user explicitly sets dark mode.
|
|
37
|
+
*/
|
|
38
|
+
const darkRule = new postcss_1.Rule({
|
|
13
39
|
selector: `[data-mode="dark"] &`,
|
|
14
40
|
});
|
|
15
|
-
clonedNodes.forEach((node) =>
|
|
16
|
-
|
|
41
|
+
clonedNodes.forEach((node) => darkRule.append(node.clone()));
|
|
42
|
+
/**
|
|
43
|
+
* Rule 2: @media (prefers-color-scheme: dark) { [data-mode="system"] & { ... } }
|
|
44
|
+
*
|
|
45
|
+
* This applies the styles only when:
|
|
46
|
+
* - The user’s OS prefers dark mode
|
|
47
|
+
* - AND the app is in "system" mode (i.e. follow system preference)
|
|
48
|
+
*/
|
|
17
49
|
const mediaAtRule = new postcss_1.AtRule({
|
|
18
50
|
name: "media",
|
|
19
51
|
params: "(prefers-color-scheme: dark)",
|
|
20
52
|
});
|
|
21
|
-
|
|
22
|
-
|
|
53
|
+
// Wrap cloned rules under `[data-mode="system"]`
|
|
54
|
+
const systemRule = new postcss_1.Rule({
|
|
55
|
+
selector: `[data-mode="system"] &`,
|
|
23
56
|
});
|
|
24
|
-
clonedNodes.forEach((node) =>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
57
|
+
clonedNodes.forEach((node) => systemRule.append(node.clone()));
|
|
58
|
+
// Nest `[data-mode="system"]` inside the @media block
|
|
59
|
+
mediaAtRule.append(systemRule);
|
|
60
|
+
/**
|
|
61
|
+
* Replace the original @dark rule in the CSS tree
|
|
62
|
+
* with our two new generated rules.
|
|
63
|
+
*/
|
|
64
|
+
atRule.replaceWith(mediaAtRule, darkRule);
|
|
28
65
|
}
|
package/dist/at-rules/light.d.ts
CHANGED
|
@@ -1,2 +1,23 @@
|
|
|
1
1
|
import { AtRule } from "postcss";
|
|
2
|
+
/**
|
|
3
|
+
* Custom PostCSS plugin handler for `@light` at-rules.
|
|
4
|
+
*
|
|
5
|
+
* Transforms:
|
|
6
|
+
*
|
|
7
|
+
* @light {
|
|
8
|
+
* color: white;
|
|
9
|
+
* }
|
|
10
|
+
*
|
|
11
|
+
* Into:
|
|
12
|
+
*
|
|
13
|
+
* @media (prefers-color-scheme: light) {
|
|
14
|
+
* [data-mode="system"] & {
|
|
15
|
+
* color: white;
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* [data-mode="light"] & {
|
|
20
|
+
* color: white;
|
|
21
|
+
* }
|
|
22
|
+
*/
|
|
2
23
|
export default function light(atRule: AtRule): void;
|
package/dist/at-rules/light.js
CHANGED
|
@@ -2,27 +2,64 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = light;
|
|
4
4
|
const postcss_1 = require("postcss");
|
|
5
|
+
/**
|
|
6
|
+
* Custom PostCSS plugin handler for `@light` at-rules.
|
|
7
|
+
*
|
|
8
|
+
* Transforms:
|
|
9
|
+
*
|
|
10
|
+
* @light {
|
|
11
|
+
* color: white;
|
|
12
|
+
* }
|
|
13
|
+
*
|
|
14
|
+
* Into:
|
|
15
|
+
*
|
|
16
|
+
* @media (prefers-color-scheme: light) {
|
|
17
|
+
* [data-mode="system"] & {
|
|
18
|
+
* color: white;
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* [data-mode="light"] & {
|
|
23
|
+
* color: white;
|
|
24
|
+
* }
|
|
25
|
+
*/
|
|
5
26
|
function light(atRule) {
|
|
6
27
|
const clonedNodes = [];
|
|
7
|
-
// Clone all child nodes
|
|
28
|
+
// Clone all child nodes inside the @light block
|
|
29
|
+
// (so we can reuse them in both generated rules).
|
|
8
30
|
atRule.each((node) => {
|
|
9
31
|
clonedNodes.push(node.clone());
|
|
10
32
|
});
|
|
11
|
-
|
|
12
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Rule 1: [data-mode="light"] & { ... }
|
|
35
|
+
*
|
|
36
|
+
* This applies the styles when the user explicitly sets light mode.
|
|
37
|
+
*/
|
|
38
|
+
const lightRule = new postcss_1.Rule({
|
|
13
39
|
selector: `[data-mode="light"] &`,
|
|
14
40
|
});
|
|
15
|
-
clonedNodes.forEach((node) =>
|
|
16
|
-
|
|
41
|
+
clonedNodes.forEach((node) => lightRule.append(node.clone()));
|
|
42
|
+
/**
|
|
43
|
+
* Rule 2: @media (prefers-color-scheme: light) { [data-mode="system"] & { ... } }
|
|
44
|
+
*
|
|
45
|
+
* This applies the styles only when:
|
|
46
|
+
* - The user’s OS prefers light mode
|
|
47
|
+
* - AND the app is in "system" mode (i.e. follow system preference)
|
|
48
|
+
*/
|
|
17
49
|
const mediaAtRule = new postcss_1.AtRule({
|
|
18
50
|
name: "media",
|
|
19
51
|
params: "(prefers-color-scheme: light)",
|
|
20
52
|
});
|
|
21
|
-
|
|
22
|
-
|
|
53
|
+
// Wrap cloned rules under `[data-mode="system"]`
|
|
54
|
+
const systemRule = new postcss_1.Rule({
|
|
55
|
+
selector: `[data-mode="system"] &`,
|
|
23
56
|
});
|
|
24
|
-
clonedNodes.forEach((node) =>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
57
|
+
clonedNodes.forEach((node) => systemRule.append(node.clone()));
|
|
58
|
+
// Nest `[data-mode="system"]` inside the @media block
|
|
59
|
+
mediaAtRule.append(systemRule);
|
|
60
|
+
/**
|
|
61
|
+
* Replace the original @light rule in the CSS tree
|
|
62
|
+
* with our two new generated rules.
|
|
63
|
+
*/
|
|
64
|
+
atRule.replaceWith(mediaAtRule, lightRule);
|
|
28
65
|
}
|
package/package.json
CHANGED
package/src/at-rules/dark.ts
CHANGED
|
@@ -1,33 +1,69 @@
|
|
|
1
1
|
import { Rule, AtRule, ChildNode } from "postcss";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Custom PostCSS plugin handler for `@dark` at-rules.
|
|
5
|
+
*
|
|
6
|
+
* Transforms:
|
|
7
|
+
*
|
|
8
|
+
* @dark {
|
|
9
|
+
* color: white;
|
|
10
|
+
* }
|
|
11
|
+
*
|
|
12
|
+
* Into:
|
|
13
|
+
*
|
|
14
|
+
* @media (prefers-color-scheme: dark) {
|
|
15
|
+
* [data-mode="system"] & {
|
|
16
|
+
* color: white;
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* [data-mode="dark"] & {
|
|
21
|
+
* color: white;
|
|
22
|
+
* }
|
|
23
|
+
*/
|
|
3
24
|
export default function dark(atRule: AtRule) {
|
|
4
25
|
const clonedNodes: ChildNode[] = [];
|
|
5
26
|
|
|
6
|
-
// Clone all child nodes
|
|
27
|
+
// Clone all child nodes inside the @dark block
|
|
28
|
+
// (so we can reuse them in both generated rules).
|
|
7
29
|
atRule.each((node: ChildNode) => {
|
|
8
30
|
clonedNodes.push(node.clone());
|
|
9
31
|
});
|
|
10
32
|
|
|
11
|
-
|
|
12
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Rule 1: [data-mode="dark"] & { ... }
|
|
35
|
+
*
|
|
36
|
+
* This applies the styles when the user explicitly sets dark mode.
|
|
37
|
+
*/
|
|
38
|
+
const darkRule = new Rule({
|
|
13
39
|
selector: `[data-mode="dark"] &`,
|
|
14
40
|
});
|
|
41
|
+
clonedNodes.forEach((node) => darkRule.append(node.clone()));
|
|
15
42
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Rule 2: @media (prefers-color-scheme: dark) { [data-mode="system"] & { ... } }
|
|
45
|
+
*
|
|
46
|
+
* This applies the styles only when:
|
|
47
|
+
* - The user’s OS prefers dark mode
|
|
48
|
+
* - AND the app is in "system" mode (i.e. follow system preference)
|
|
49
|
+
*/
|
|
19
50
|
const mediaAtRule = new AtRule({
|
|
20
51
|
name: "media",
|
|
21
52
|
params: "(prefers-color-scheme: dark)",
|
|
22
53
|
});
|
|
23
54
|
|
|
24
|
-
|
|
25
|
-
|
|
55
|
+
// Wrap cloned rules under `[data-mode="system"]`
|
|
56
|
+
const systemRule = new Rule({
|
|
57
|
+
selector: `[data-mode="system"] &`,
|
|
26
58
|
});
|
|
59
|
+
clonedNodes.forEach((node) => systemRule.append(node.clone()));
|
|
27
60
|
|
|
28
|
-
|
|
29
|
-
mediaAtRule.append(
|
|
61
|
+
// Nest `[data-mode="system"]` inside the @media block
|
|
62
|
+
mediaAtRule.append(systemRule);
|
|
30
63
|
|
|
31
|
-
|
|
32
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Replace the original @dark rule in the CSS tree
|
|
66
|
+
* with our two new generated rules.
|
|
67
|
+
*/
|
|
68
|
+
atRule.replaceWith(mediaAtRule, darkRule);
|
|
33
69
|
}
|
package/src/at-rules/light.ts
CHANGED
|
@@ -1,33 +1,69 @@
|
|
|
1
1
|
import { Rule, AtRule, ChildNode } from "postcss";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Custom PostCSS plugin handler for `@light` at-rules.
|
|
5
|
+
*
|
|
6
|
+
* Transforms:
|
|
7
|
+
*
|
|
8
|
+
* @light {
|
|
9
|
+
* color: white;
|
|
10
|
+
* }
|
|
11
|
+
*
|
|
12
|
+
* Into:
|
|
13
|
+
*
|
|
14
|
+
* @media (prefers-color-scheme: light) {
|
|
15
|
+
* [data-mode="system"] & {
|
|
16
|
+
* color: white;
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* [data-mode="light"] & {
|
|
21
|
+
* color: white;
|
|
22
|
+
* }
|
|
23
|
+
*/
|
|
3
24
|
export default function light(atRule: AtRule) {
|
|
4
25
|
const clonedNodes: ChildNode[] = [];
|
|
5
26
|
|
|
6
|
-
// Clone all child nodes
|
|
27
|
+
// Clone all child nodes inside the @light block
|
|
28
|
+
// (so we can reuse them in both generated rules).
|
|
7
29
|
atRule.each((node: ChildNode) => {
|
|
8
30
|
clonedNodes.push(node.clone());
|
|
9
31
|
});
|
|
10
32
|
|
|
11
|
-
|
|
12
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Rule 1: [data-mode="light"] & { ... }
|
|
35
|
+
*
|
|
36
|
+
* This applies the styles when the user explicitly sets light mode.
|
|
37
|
+
*/
|
|
38
|
+
const lightRule = new Rule({
|
|
13
39
|
selector: `[data-mode="light"] &`,
|
|
14
40
|
});
|
|
41
|
+
clonedNodes.forEach((node) => lightRule.append(node.clone()));
|
|
15
42
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Rule 2: @media (prefers-color-scheme: light) { [data-mode="system"] & { ... } }
|
|
45
|
+
*
|
|
46
|
+
* This applies the styles only when:
|
|
47
|
+
* - The user’s OS prefers light mode
|
|
48
|
+
* - AND the app is in "system" mode (i.e. follow system preference)
|
|
49
|
+
*/
|
|
19
50
|
const mediaAtRule = new AtRule({
|
|
20
51
|
name: "media",
|
|
21
52
|
params: "(prefers-color-scheme: light)",
|
|
22
53
|
});
|
|
23
54
|
|
|
24
|
-
|
|
25
|
-
|
|
55
|
+
// Wrap cloned rules under `[data-mode="system"]`
|
|
56
|
+
const systemRule = new Rule({
|
|
57
|
+
selector: `[data-mode="system"] &`,
|
|
26
58
|
});
|
|
59
|
+
clonedNodes.forEach((node) => systemRule.append(node.clone()));
|
|
27
60
|
|
|
28
|
-
|
|
29
|
-
mediaAtRule.append(
|
|
61
|
+
// Nest `[data-mode="system"]` inside the @media block
|
|
62
|
+
mediaAtRule.append(systemRule);
|
|
30
63
|
|
|
31
|
-
|
|
32
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Replace the original @light rule in the CSS tree
|
|
66
|
+
* with our two new generated rules.
|
|
67
|
+
*/
|
|
68
|
+
atRule.replaceWith(mediaAtRule, lightRule);
|
|
33
69
|
}
|