@reykjavik/webtools 0.1.31 → 0.1.33
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 +20 -0
- package/README.md +309 -169
- package/errorhandling.d.ts +99 -0
- package/errorhandling.js +107 -0
- package/esm/errorhandling.d.ts +99 -0
- package/esm/errorhandling.js +102 -0
- package/esm/index.d.ts +1 -0
- package/esm/vanillaExtract.d.ts +109 -5
- package/esm/vanillaExtract.js +43 -3
- package/index.d.ts +1 -0
- package/package.json +5 -1
- package/vanillaExtract.d.ts +109 -5
- package/vanillaExtract.js +43 -3
package/vanillaExtract.js
CHANGED
|
@@ -31,15 +31,55 @@ function vanillaClass(cssOrDebugId, css) {
|
|
|
31
31
|
exports.vanillaClass = vanillaClass;
|
|
32
32
|
// ---------------------------------------------------------------------------
|
|
33
33
|
/**
|
|
34
|
+
* @deprecated (Will be removed in v0.2)
|
|
35
|
+
*
|
|
34
36
|
* Replaces all `&` tokens with the given selector string, in a direct
|
|
35
37
|
* (read. "dumb") way. It's mainly useful when used with style-mixins, etc.
|
|
36
38
|
*
|
|
37
|
-
* NOTE
|
|
38
|
-
* It will also replace
|
|
39
|
+
* **NOTE:** `vanillaNest` does NOT support deeply nested blocks, or anything
|
|
40
|
+
* so fancy. It will also replace `&` characters inside values, comments, etc.
|
|
39
41
|
* If you need something more sophisticated, use a custom `postcss` config.
|
|
40
42
|
*
|
|
43
|
+
* ```ts
|
|
44
|
+
* // someCssHelper.ts
|
|
45
|
+
* import { vanillaNest } from '@reykjavik/webtools/vanillaExtract';
|
|
46
|
+
*
|
|
47
|
+
* export const hoverGlow = (
|
|
48
|
+
* ampSelector: string,
|
|
49
|
+
* glowiness?: 'normal' | 'insane'
|
|
50
|
+
* ) =>
|
|
51
|
+
* vanillaNest(
|
|
52
|
+
* ampSelector,
|
|
53
|
+
* `
|
|
54
|
+
* &:hover {
|
|
55
|
+
* box-shadow: 0 0 20px 5px ${
|
|
56
|
+
* glowiness === 'insane' ? 'hotpink' : 'salmon'
|
|
57
|
+
* };
|
|
58
|
+
* }
|
|
59
|
+
* `
|
|
60
|
+
* );
|
|
61
|
+
*
|
|
62
|
+
* // ...then, somewhere else in a *.css.ts file:
|
|
63
|
+
*
|
|
64
|
+
* import { hoverGlow } from '~/someCssHelper.js';
|
|
65
|
+
* import { vanillaGlobal } from '@reykjavik/webtools/vanillaExtract';
|
|
66
|
+
*
|
|
67
|
+
* vanillaGlobal(`
|
|
68
|
+
* .MyComponent {
|
|
69
|
+
* border: 1px solid #ccc;
|
|
70
|
+
* padding: 1em;
|
|
71
|
+
* }
|
|
72
|
+
* ${hoverGlow('.MyComponent')}
|
|
73
|
+
*
|
|
74
|
+
* .MyOtherComponent {
|
|
75
|
+
* border: 1px solid #ccc;
|
|
76
|
+
* padding: 1em;
|
|
77
|
+
* }
|
|
78
|
+
* ${hoverGlow('.MyOtherComponent', 'insane')}
|
|
79
|
+
* `);
|
|
80
|
+
* ```
|
|
41
81
|
*
|
|
42
|
-
*
|
|
82
|
+
* (This low-level utility function is used internally by `vanillaClassNested`.
|
|
43
83
|
*/
|
|
44
84
|
const vanillaNest = (ampSelector, css) => css.replace(/&/g, ampSelector);
|
|
45
85
|
exports.vanillaNest = vanillaNest;
|