@seyuna/postcss 1.0.0-canary.13 → 1.0.0-canary.15

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.
Files changed (66) hide show
  1. package/.github/workflows/release.yml +1 -1
  2. package/CHANGELOG.md +16 -0
  3. package/README.md +179 -0
  4. package/dist/at-rules/color-scheme.d.ts +4 -0
  5. package/dist/at-rules/color-scheme.js +43 -0
  6. package/dist/at-rules/color.d.ts +5 -4
  7. package/dist/at-rules/color.js +22 -87
  8. package/dist/at-rules/conditional.d.ts +6 -0
  9. package/dist/at-rules/conditional.js +29 -0
  10. package/dist/at-rules/container.d.ts +2 -1
  11. package/dist/at-rules/container.js +12 -8
  12. package/dist/at-rules/custom-media.d.ts +15 -0
  13. package/dist/at-rules/custom-media.js +40 -0
  14. package/dist/at-rules/index.d.ts +3 -2
  15. package/dist/at-rules/index.js +22 -22
  16. package/dist/at-rules/mixin.d.ts +10 -0
  17. package/dist/at-rules/mixin.js +37 -0
  18. package/dist/config.d.ts +20 -0
  19. package/dist/config.js +47 -0
  20. package/dist/errors.d.ts +7 -0
  21. package/dist/errors.js +14 -0
  22. package/dist/functions/color.d.ts +7 -2
  23. package/dist/functions/color.js +103 -27
  24. package/dist/functions/index.d.ts +2 -1
  25. package/dist/functions/index.js +10 -12
  26. package/dist/functions/theme.d.ts +6 -0
  27. package/dist/functions/theme.js +17 -0
  28. package/dist/helpers.d.ts +11 -0
  29. package/dist/helpers.js +54 -0
  30. package/dist/index.d.ts +2 -2
  31. package/dist/index.js +6 -5
  32. package/dist/parser.d.ts +4 -0
  33. package/dist/parser.js +59 -0
  34. package/dist/plugin.d.ts +2 -4
  35. package/dist/plugin.js +17 -22
  36. package/dist/types.d.ts +1 -19
  37. package/dist/types.js +1 -2
  38. package/package.json +14 -5
  39. package/src/at-rules/color-scheme.ts +52 -0
  40. package/src/at-rules/color.ts +20 -87
  41. package/src/at-rules/conditional.ts +34 -0
  42. package/src/at-rules/container.ts +13 -3
  43. package/src/at-rules/custom-media.ts +50 -0
  44. package/src/at-rules/index.ts +13 -6
  45. package/src/at-rules/mixin.ts +46 -0
  46. package/src/config.ts +74 -0
  47. package/src/errors.ts +23 -0
  48. package/src/functions/color.ts +120 -26
  49. package/src/functions/index.ts +9 -4
  50. package/src/functions/theme.ts +20 -0
  51. package/src/helpers.ts +74 -0
  52. package/src/index.ts +3 -1
  53. package/src/parser.ts +80 -0
  54. package/src/plugin.ts +13 -21
  55. package/src/types.ts +1 -19
  56. package/tests/plugin.test.ts +251 -0
  57. package/tsconfig.json +2 -2
  58. package/dist/at-rules/dark.d.ts +0 -23
  59. package/dist/at-rules/dark.js +0 -65
  60. package/dist/at-rules/light.d.ts +0 -23
  61. package/dist/at-rules/light.js +0 -65
  62. package/dist/functions/spacing.d.ts +0 -1
  63. package/dist/functions/spacing.js +0 -6
  64. package/src/at-rules/dark.ts +0 -69
  65. package/src/at-rules/light.ts +0 -69
  66. package/src/functions/spacing.ts +0 -3
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = spacing;
4
- function spacing(multiplier) {
5
- return `${parseFloat(multiplier) * 1}rem`;
6
- }
@@ -1,69 +0,0 @@
1
- import { Rule, AtRule, ChildNode } from "postcss";
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
- */
24
- export default function dark(atRule: AtRule) {
25
- const clonedNodes: ChildNode[] = [];
26
-
27
- // Clone all child nodes inside the @dark block
28
- // (so we can reuse them in both generated rules).
29
- atRule.each((node: ChildNode) => {
30
- clonedNodes.push(node.clone());
31
- });
32
-
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({
39
- selector: `[data-mode="dark"] &`,
40
- });
41
- clonedNodes.forEach((node) => darkRule.append(node.clone()));
42
-
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
- */
50
- const mediaAtRule = new AtRule({
51
- name: "media",
52
- params: "(prefers-color-scheme: dark)",
53
- });
54
-
55
- // Wrap cloned rules under `[data-mode="system"]`
56
- const systemRule = new Rule({
57
- selector: `[data-mode="system"] &`,
58
- });
59
- clonedNodes.forEach((node) => systemRule.append(node.clone()));
60
-
61
- // Nest `[data-mode="system"]` inside the @media block
62
- mediaAtRule.append(systemRule);
63
-
64
- /**
65
- * Replace the original @dark rule in the CSS tree
66
- * with our two new generated rules.
67
- */
68
- atRule.replaceWith(mediaAtRule, darkRule);
69
- }
@@ -1,69 +0,0 @@
1
- import { Rule, AtRule, ChildNode } from "postcss";
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
- */
24
- export default function light(atRule: AtRule) {
25
- const clonedNodes: ChildNode[] = [];
26
-
27
- // Clone all child nodes inside the @light block
28
- // (so we can reuse them in both generated rules).
29
- atRule.each((node: ChildNode) => {
30
- clonedNodes.push(node.clone());
31
- });
32
-
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({
39
- selector: `[data-mode="light"] &`,
40
- });
41
- clonedNodes.forEach((node) => lightRule.append(node.clone()));
42
-
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
- */
50
- const mediaAtRule = new AtRule({
51
- name: "media",
52
- params: "(prefers-color-scheme: light)",
53
- });
54
-
55
- // Wrap cloned rules under `[data-mode="system"]`
56
- const systemRule = new Rule({
57
- selector: `[data-mode="system"] &`,
58
- });
59
- clonedNodes.forEach((node) => systemRule.append(node.clone()));
60
-
61
- // Nest `[data-mode="system"]` inside the @media block
62
- mediaAtRule.append(systemRule);
63
-
64
- /**
65
- * Replace the original @light rule in the CSS tree
66
- * with our two new generated rules.
67
- */
68
- atRule.replaceWith(mediaAtRule, lightRule);
69
- }
@@ -1,3 +0,0 @@
1
- export default function spacing(multiplier: string) {
2
- return `${parseFloat(multiplier) * 1}rem`;
3
- }