@ndla/preset-panda 0.0.1 → 0.0.2

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/dist/styles.css CHANGED
@@ -467,18 +467,23 @@
467
467
  --colors-icon-on-action: var(--colors-white);
468
468
  --colors-surface-brand-1: var(--colors-purple-500);
469
469
  --colors-surface-brand-1-subtle: var(--colors-purple-100);
470
+ --colors-surface-brand-1-moderate: var(--colors-purple-300);
470
471
  --colors-surface-brand-1-strong: var(--colors-purple-950);
471
472
  --colors-surface-brand-2: var(--colors-blue-500);
472
- --colors-surface-brand-2-subtle: var(--colors-blue-100);
473
+ --colors-surface-brand-2-subtle: var(--colors-blue-50);
474
+ --colors-surface-brand-2-moderate: var(--colors-blue-100);
473
475
  --colors-surface-brand-2-strong: var(--colors-blue-900);
474
476
  --colors-surface-brand-3: var(--colors-green-500);
475
477
  --colors-surface-brand-3-subtle: var(--colors-green-100);
478
+ --colors-surface-brand-3-moderate: var(--colors-green-300);
476
479
  --colors-surface-brand-3-strong: var(--colors-green-900);
477
480
  --colors-surface-brand-4: var(--colors-yellow-500);
478
481
  --colors-surface-brand-4-subtle: var(--colors-yellow-100);
482
+ --colors-surface-brand-4-moderate: var(--colors-yellow-300);
479
483
  --colors-surface-brand-4-strong: var(--colors-yellow-1100);
480
484
  --colors-surface-brand-5: var(--colors-pink-500);
481
485
  --colors-surface-brand-5-subtle: var(--colors-pink-100);
486
+ --colors-surface-brand-5-moderate: var(--colors-pink-300);
482
487
  --colors-surface-brand-5-strong: var(--colors-pink-900);
483
488
  --colors-surface-default: var(--colors-white);
484
489
  --colors-surface-hover: var(--colors-grey-100);
@@ -509,6 +514,12 @@
509
514
  --colors-surface-warning-subtle: var(--colors-yellow-100);
510
515
  --colors-surface-warning-subtle-hover: var(--colors-yellow-300);
511
516
  --colors-surface-warning-subtle-active: var(--colors-yellow-400);
517
+ --colors-surface-danger: var(--colors-pink-800);
518
+ --colors-surface-danger-hover: var(--colors-pink-900);
519
+ --colors-surface-danger-active: var(--colors-pink-950);
520
+ --colors-surface-danger-subtle: var(--colors-pink-100);
521
+ --colors-surface-danger-subtle-hover: var(--colors-pink-300);
522
+ --colors-surface-danger-subtle-active: var(--colors-pink-500);
512
523
  --colors-surface-error: var(--colors-pink-800);
513
524
  --colors-surface-error-hover: var(--colors-pink-900);
514
525
  --colors-surface-error-active: var(--colors-pink-950);
package/es/index.js CHANGED
@@ -43,4 +43,5 @@ const preset = definePreset({
43
43
  semanticTokens: semanticTokens
44
44
  }
45
45
  });
46
+ export { forwardCssPropPlugin } from "./plugins/forwardCssPropPlugin";
46
47
  export default preset;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Copyright (c) 2024-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ const supportedJsxFrameworks = ["react"];
10
+ export const forwardCssPropPlugin = () => {
11
+ return {
12
+ name: "forward-css-prop",
13
+ hooks: {
14
+ "config:resolved": args => {
15
+ const jsxFramework = args.config.jsxFramework;
16
+ if (!supportedJsxFrameworks.includes(jsxFramework)) {
17
+ throw new Error("[plugin:restrict-styled-props]: Unsupported jsxFramework: ".concat(jsxFramework, ". This Panda plugin only supports: ").concat(supportedJsxFrameworks.join(", ")));
18
+ }
19
+ },
20
+ "codegen:prepare": args => {
21
+ return transformStyledFn(args);
22
+ }
23
+ }
24
+ };
25
+ };
26
+ export const transformStyledFn = args => {
27
+ var _args$artifacts$find, _args$artifacts$find2;
28
+ const factoryArtifact = args.artifacts.find(art => art.id === "jsx-factory");
29
+ const factoryJs = factoryArtifact === null || factoryArtifact === void 0 ? void 0 : factoryArtifact.files.find(f => f.file.includes(".mjs") || f.file.includes(".js"));
30
+ const jsxTypes = (_args$artifacts$find = args.artifacts.find(art => art.id === "types-jsx")) === null || _args$artifacts$find === void 0 ? void 0 : _args$artifacts$find.files.find(f => f.file.includes("jsx"));
31
+ const systemTypes = (_args$artifacts$find2 = args.artifacts.find(art => art.id === "types-gen-system")) === null || _args$artifacts$find2 === void 0 ? void 0 : _args$artifacts$find2.files.find(f => f.file.includes("system-types"));
32
+ if (!(factoryJs !== null && factoryJs !== void 0 && factoryJs.code) || !(jsxTypes !== null && jsxTypes !== void 0 && jsxTypes.code) || !(systemTypes !== null && systemTypes !== void 0 && systemTypes.code)) {
33
+ return args.artifacts;
34
+ }
35
+ const propsCode = "const { as: Element = __base__, children, ...restProps } = props";
36
+ factoryJs.code = factoryJs.code.replace(propsCode, "const { as: Element = __base__, forwardCssProp, children, ...restProps } = props");
37
+ const cvaCode = "const cvaStyles = __cvaFn__.raw(variantProps)";
38
+ factoryJs.code = factoryJs.code.replace(cvaCode, "".concat(cvaCode, "\n if(options.forwardCssProp || forwardCssProp) {\n return css.raw(cvaStyles, propStyles, cssStyles)\n }"));
39
+ factoryJs.code = factoryJs.code.replace("className: classes()", "...(options.forwardCssProp || forwardCssProp ? { css: classes() } : { className: classes() })");
40
+ const shouldForwardPropCode = "shouldForwardProp?(prop: string, variantKeys: string[]): boolean";
41
+ jsxTypes.code = jsxTypes.code.replace(shouldForwardPropCode, "".concat(shouldForwardPropCode, "\n forwardCssProp?: boolean"));
42
+ const jsxStylePropsCode = "export type JsxStyleProps =";
43
+ systemTypes.code = systemTypes.code.replace(jsxStylePropsCode, "".concat(jsxStylePropsCode, " { forwardCssProp?: boolean } & "));
44
+ return args.artifacts;
45
+ };
@@ -206,6 +206,9 @@ export const semanticTokens = defineSemanticTokens({
206
206
  subtle: {
207
207
  value: "{colors.purple.100}"
208
208
  },
209
+ moderate: {
210
+ value: "{colors.purple.300}"
211
+ },
209
212
  strong: {
210
213
  value: "{colors.purple.950}"
211
214
  }
@@ -215,6 +218,9 @@ export const semanticTokens = defineSemanticTokens({
215
218
  value: "{colors.blue.500}"
216
219
  },
217
220
  subtle: {
221
+ value: "{colors.blue.50}"
222
+ },
223
+ moderate: {
218
224
  value: "{colors.blue.100}"
219
225
  },
220
226
  strong: {
@@ -228,6 +234,9 @@ export const semanticTokens = defineSemanticTokens({
228
234
  subtle: {
229
235
  value: "{colors.green.100}"
230
236
  },
237
+ moderate: {
238
+ value: "{colors.green.300}"
239
+ },
231
240
  strong: {
232
241
  value: "{colors.green.900}"
233
242
  }
@@ -239,6 +248,9 @@ export const semanticTokens = defineSemanticTokens({
239
248
  subtle: {
240
249
  value: "{colors.yellow.100}"
241
250
  },
251
+ moderate: {
252
+ value: "{colors.yellow.300}"
253
+ },
242
254
  strong: {
243
255
  value: "{colors.yellow.1100}"
244
256
  }
@@ -250,6 +262,9 @@ export const semanticTokens = defineSemanticTokens({
250
262
  subtle: {
251
263
  value: "{colors.pink.100}"
252
264
  },
265
+ moderate: {
266
+ value: "{colors.pink.300}"
267
+ },
253
268
  strong: {
254
269
  value: "{colors.pink.900}"
255
270
  }
@@ -360,6 +375,28 @@ export const semanticTokens = defineSemanticTokens({
360
375
  value: "{colors.yellow.400}"
361
376
  }
362
377
  },
378
+ danger: {
379
+ DEFAULT: {
380
+ value: "{colors.pink.800}"
381
+ },
382
+ hover: {
383
+ value: "{colors.pink.900}"
384
+ },
385
+ active: {
386
+ value: "{colors.pink.950}"
387
+ }
388
+ },
389
+ dangerSubtle: {
390
+ DEFAULT: {
391
+ value: "{colors.pink.100}"
392
+ },
393
+ hover: {
394
+ value: "{colors.pink.300}"
395
+ },
396
+ active: {
397
+ value: "{colors.pink.500}"
398
+ }
399
+ },
363
400
  error: {
364
401
  DEFAULT: {
365
402
  value: "{colors.pink.800}"
package/lib/index.d.ts CHANGED
@@ -6,4 +6,5 @@
6
6
  *
7
7
  */
8
8
  declare const preset: import("@pandacss/dev").Preset;
9
+ export { forwardCssPropPlugin } from "./plugins/forwardCssPropPlugin";
9
10
  export default preset;
package/lib/index.js CHANGED
@@ -4,6 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ Object.defineProperty(exports, "forwardCssPropPlugin", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _forwardCssPropPlugin.forwardCssPropPlugin;
11
+ }
12
+ });
7
13
  var _dev = require("@pandacss/dev");
8
14
  var _animations = require("./animations");
9
15
  var _boxShadows = require("./boxShadows");
@@ -16,6 +22,7 @@ var _semanticTokens = require("./semanticTokens");
16
22
  var _spacing = require("./spacing");
17
23
  var _typography = require("./typography");
18
24
  var _zIndex = require("./zIndex");
25
+ var _forwardCssPropPlugin = require("./plugins/forwardCssPropPlugin");
19
26
  /**
20
27
  * Copyright (c) 2024-present, NDLA.
21
28
  *
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright (c) 2024-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import { CodegenPrepareHookArgs, PandaPlugin } from "@pandacss/types";
9
+ export declare const forwardCssPropPlugin: () => PandaPlugin;
10
+ export declare const transformStyledFn: (args: CodegenPrepareHookArgs) => import("@pandacss/types").Artifact[];
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.transformStyledFn = exports.forwardCssPropPlugin = void 0;
7
+ /**
8
+ * Copyright (c) 2024-present, NDLA.
9
+ *
10
+ * This source code is licensed under the GPLv3 license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ *
13
+ */
14
+
15
+ const supportedJsxFrameworks = ["react"];
16
+ const forwardCssPropPlugin = () => {
17
+ return {
18
+ name: "forward-css-prop",
19
+ hooks: {
20
+ "config:resolved": args => {
21
+ const jsxFramework = args.config.jsxFramework;
22
+ if (!supportedJsxFrameworks.includes(jsxFramework)) {
23
+ throw new Error("[plugin:restrict-styled-props]: Unsupported jsxFramework: ".concat(jsxFramework, ". This Panda plugin only supports: ").concat(supportedJsxFrameworks.join(", ")));
24
+ }
25
+ },
26
+ "codegen:prepare": args => {
27
+ return transformStyledFn(args);
28
+ }
29
+ }
30
+ };
31
+ };
32
+ exports.forwardCssPropPlugin = forwardCssPropPlugin;
33
+ const transformStyledFn = args => {
34
+ var _args$artifacts$find, _args$artifacts$find2;
35
+ const factoryArtifact = args.artifacts.find(art => art.id === "jsx-factory");
36
+ const factoryJs = factoryArtifact === null || factoryArtifact === void 0 ? void 0 : factoryArtifact.files.find(f => f.file.includes(".mjs") || f.file.includes(".js"));
37
+ const jsxTypes = (_args$artifacts$find = args.artifacts.find(art => art.id === "types-jsx")) === null || _args$artifacts$find === void 0 ? void 0 : _args$artifacts$find.files.find(f => f.file.includes("jsx"));
38
+ const systemTypes = (_args$artifacts$find2 = args.artifacts.find(art => art.id === "types-gen-system")) === null || _args$artifacts$find2 === void 0 ? void 0 : _args$artifacts$find2.files.find(f => f.file.includes("system-types"));
39
+ if (!(factoryJs !== null && factoryJs !== void 0 && factoryJs.code) || !(jsxTypes !== null && jsxTypes !== void 0 && jsxTypes.code) || !(systemTypes !== null && systemTypes !== void 0 && systemTypes.code)) {
40
+ return args.artifacts;
41
+ }
42
+ const propsCode = "const { as: Element = __base__, children, ...restProps } = props";
43
+ factoryJs.code = factoryJs.code.replace(propsCode, "const { as: Element = __base__, forwardCssProp, children, ...restProps } = props");
44
+ const cvaCode = "const cvaStyles = __cvaFn__.raw(variantProps)";
45
+ factoryJs.code = factoryJs.code.replace(cvaCode, "".concat(cvaCode, "\n if(options.forwardCssProp || forwardCssProp) {\n return css.raw(cvaStyles, propStyles, cssStyles)\n }"));
46
+ factoryJs.code = factoryJs.code.replace("className: classes()", "...(options.forwardCssProp || forwardCssProp ? { css: classes() } : { className: classes() })");
47
+ const shouldForwardPropCode = "shouldForwardProp?(prop: string, variantKeys: string[]): boolean";
48
+ jsxTypes.code = jsxTypes.code.replace(shouldForwardPropCode, "".concat(shouldForwardPropCode, "\n forwardCssProp?: boolean"));
49
+ const jsxStylePropsCode = "export type JsxStyleProps =";
50
+ systemTypes.code = systemTypes.code.replace(jsxStylePropsCode, "".concat(jsxStylePropsCode, " { forwardCssProp?: boolean } & "));
51
+ return args.artifacts;
52
+ };
53
+ exports.transformStyledFn = transformStyledFn;
@@ -204,6 +204,9 @@ export declare const semanticTokens: {
204
204
  subtle: {
205
205
  value: string;
206
206
  };
207
+ moderate: {
208
+ value: string;
209
+ };
207
210
  strong: {
208
211
  value: string;
209
212
  };
@@ -215,6 +218,9 @@ export declare const semanticTokens: {
215
218
  subtle: {
216
219
  value: string;
217
220
  };
221
+ moderate: {
222
+ value: string;
223
+ };
218
224
  strong: {
219
225
  value: string;
220
226
  };
@@ -226,6 +232,9 @@ export declare const semanticTokens: {
226
232
  subtle: {
227
233
  value: string;
228
234
  };
235
+ moderate: {
236
+ value: string;
237
+ };
229
238
  strong: {
230
239
  value: string;
231
240
  };
@@ -237,6 +246,9 @@ export declare const semanticTokens: {
237
246
  subtle: {
238
247
  value: string;
239
248
  };
249
+ moderate: {
250
+ value: string;
251
+ };
240
252
  strong: {
241
253
  value: string;
242
254
  };
@@ -248,6 +260,9 @@ export declare const semanticTokens: {
248
260
  subtle: {
249
261
  value: string;
250
262
  };
263
+ moderate: {
264
+ value: string;
265
+ };
251
266
  strong: {
252
267
  value: string;
253
268
  };
@@ -358,6 +373,28 @@ export declare const semanticTokens: {
358
373
  value: string;
359
374
  };
360
375
  };
376
+ danger: {
377
+ DEFAULT: {
378
+ value: string;
379
+ };
380
+ hover: {
381
+ value: string;
382
+ };
383
+ active: {
384
+ value: string;
385
+ };
386
+ };
387
+ dangerSubtle: {
388
+ DEFAULT: {
389
+ value: string;
390
+ };
391
+ hover: {
392
+ value: string;
393
+ };
394
+ active: {
395
+ value: string;
396
+ };
397
+ };
361
398
  error: {
362
399
  DEFAULT: {
363
400
  value: string;
@@ -212,6 +212,9 @@ const semanticTokens = exports.semanticTokens = (0, _dev.defineSemanticTokens)({
212
212
  subtle: {
213
213
  value: "{colors.purple.100}"
214
214
  },
215
+ moderate: {
216
+ value: "{colors.purple.300}"
217
+ },
215
218
  strong: {
216
219
  value: "{colors.purple.950}"
217
220
  }
@@ -221,6 +224,9 @@ const semanticTokens = exports.semanticTokens = (0, _dev.defineSemanticTokens)({
221
224
  value: "{colors.blue.500}"
222
225
  },
223
226
  subtle: {
227
+ value: "{colors.blue.50}"
228
+ },
229
+ moderate: {
224
230
  value: "{colors.blue.100}"
225
231
  },
226
232
  strong: {
@@ -234,6 +240,9 @@ const semanticTokens = exports.semanticTokens = (0, _dev.defineSemanticTokens)({
234
240
  subtle: {
235
241
  value: "{colors.green.100}"
236
242
  },
243
+ moderate: {
244
+ value: "{colors.green.300}"
245
+ },
237
246
  strong: {
238
247
  value: "{colors.green.900}"
239
248
  }
@@ -245,6 +254,9 @@ const semanticTokens = exports.semanticTokens = (0, _dev.defineSemanticTokens)({
245
254
  subtle: {
246
255
  value: "{colors.yellow.100}"
247
256
  },
257
+ moderate: {
258
+ value: "{colors.yellow.300}"
259
+ },
248
260
  strong: {
249
261
  value: "{colors.yellow.1100}"
250
262
  }
@@ -256,6 +268,9 @@ const semanticTokens = exports.semanticTokens = (0, _dev.defineSemanticTokens)({
256
268
  subtle: {
257
269
  value: "{colors.pink.100}"
258
270
  },
271
+ moderate: {
272
+ value: "{colors.pink.300}"
273
+ },
259
274
  strong: {
260
275
  value: "{colors.pink.900}"
261
276
  }
@@ -366,6 +381,28 @@ const semanticTokens = exports.semanticTokens = (0, _dev.defineSemanticTokens)({
366
381
  value: "{colors.yellow.400}"
367
382
  }
368
383
  },
384
+ danger: {
385
+ DEFAULT: {
386
+ value: "{colors.pink.800}"
387
+ },
388
+ hover: {
389
+ value: "{colors.pink.900}"
390
+ },
391
+ active: {
392
+ value: "{colors.pink.950}"
393
+ }
394
+ },
395
+ dangerSubtle: {
396
+ DEFAULT: {
397
+ value: "{colors.pink.100}"
398
+ },
399
+ hover: {
400
+ value: "{colors.pink.300}"
401
+ },
402
+ active: {
403
+ value: "{colors.pink.500}"
404
+ }
405
+ },
369
406
  error: {
370
407
  DEFAULT: {
371
408
  value: "{colors.pink.800}"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/preset-panda",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Panda preset for NDLA",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -11,7 +11,8 @@
11
11
  "prepare": "panda codegen",
12
12
  "build": "node ../../scripts/build.js package",
13
13
  "build:types": "tsc -p tsconfig.build.json",
14
- "prepublish": "concurrently 'yarn build:types' 'mkdir -p dist' 'panda cssgen --outfile dist/styles.css' 'panda ship --outfile dist/panda.buildinfo.json'"
14
+ "prepublish": "concurrently 'yarn build:types' 'yarn build:css'",
15
+ "build:css": "mkdir -p dist && panda cssgen --outfile dist/styles.css"
15
16
  },
16
17
  "repository": {
17
18
  "type": "git",
@@ -35,5 +36,5 @@
35
36
  "publishConfig": {
36
37
  "access": "public"
37
38
  },
38
- "gitHead": "06462ea8a1e84faedef361152994b7d48d4cd6e3"
39
+ "gitHead": "c3c7ec99f9fa1bcd8e6d6f0c96d77f59773323cc"
39
40
  }
@@ -1,7 +0,0 @@
1
- {
2
- "schemaVersion": "0.40.1",
3
- "styles": {
4
- "atomic": [],
5
- "recipes": {}
6
- }
7
- }