@reykjavik/webtools 0.1.26 → 0.1.27
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 +8 -0
- package/README.md +24 -3
- package/esm/vanillaExtract.d.ts +2 -2
- package/esm/vanillaExtract.js +5 -0
- package/package.json +1 -1
- package/vanillaExtract.d.ts +2 -2
- package/vanillaExtract.js +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
- ... <!-- Add new lines here. -->
|
|
6
6
|
|
|
7
|
+
## 0.1.27
|
|
8
|
+
|
|
9
|
+
_2024-07-18_
|
|
10
|
+
|
|
11
|
+
- `@reykjavik/webtools/next/vanillaExtract`:
|
|
12
|
+
- feat: `vanillaClass` now accepts a function that receives the generated
|
|
13
|
+
`className` as parameter
|
|
14
|
+
|
|
7
15
|
## 0.1.26
|
|
8
16
|
|
|
9
17
|
_2024-05-25_
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @reykjavik/webtools
|
|
1
|
+
# @reykjavik/webtools <!-- omit from toc -->
|
|
2
2
|
|
|
3
3
|
Miscellaneous JavaScript/TypeScript helpers used by Reykjavík City's web dev
|
|
4
4
|
teams.
|
|
@@ -530,8 +530,10 @@ const myStyle = style({
|
|
|
530
530
|
|
|
531
531
|
### `vanillaClass`
|
|
532
532
|
|
|
533
|
-
**Syntax:**
|
|
534
|
-
|
|
533
|
+
**Syntax:**
|
|
534
|
+
`vanillaClass(css: string | ((className: string) => string)): string`
|
|
535
|
+
**Syntax:**
|
|
536
|
+
`vanillaClass(debugId: string, css: string | ((className: string) => string)): string`
|
|
535
537
|
|
|
536
538
|
Returns a scoped cssClassName styled with free-form CSS. This function is a
|
|
537
539
|
thin wrapper around vanilla-extract's `style` function.
|
|
@@ -545,6 +547,25 @@ export const myClass = vanillaClass(`
|
|
|
545
547
|
padding: .5em 1em;
|
|
546
548
|
`);
|
|
547
549
|
|
|
550
|
+
// Passing a function to get the generated class name for
|
|
551
|
+
// more complex styles.
|
|
552
|
+
export const myOtherClass = vanillaClass(
|
|
553
|
+
(className) => `
|
|
554
|
+
.${className} {
|
|
555
|
+
background-color: #ccc;
|
|
556
|
+
padding: .5em 1em;
|
|
557
|
+
}
|
|
558
|
+
.${className} > strong {
|
|
559
|
+
color: #c00;
|
|
560
|
+
}
|
|
561
|
+
@media (min-width: 800px) {
|
|
562
|
+
.${className} {
|
|
563
|
+
background-color: #eee;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
`
|
|
567
|
+
);
|
|
568
|
+
|
|
548
569
|
export const humanReadableClass = vanillaClass(
|
|
549
570
|
'HumanReadable',
|
|
550
571
|
`
|
package/esm/vanillaExtract.d.ts
CHANGED
|
@@ -17,8 +17,8 @@ export declare const vanillaProps: (css: string) => GlobalStyleRule;
|
|
|
17
17
|
*
|
|
18
18
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#vanillaclass
|
|
19
19
|
*/
|
|
20
|
-
export declare function vanillaClass(css: string): string;
|
|
21
|
-
export declare function vanillaClass(debugId: string, css: string): string;
|
|
20
|
+
export declare function vanillaClass(css: string | ((className: string) => string)): string;
|
|
21
|
+
export declare function vanillaClass(debugId: string, css: string | ((className: string) => string)): string;
|
|
22
22
|
/**
|
|
23
23
|
* Replaces all `&` tokens with the given selector string, in a direct
|
|
24
24
|
* (read. "dumb") way. It's mainly useful when used with style-mixins, etc.
|
package/esm/vanillaExtract.js
CHANGED
|
@@ -16,6 +16,11 @@ export const vanillaProps = (css) => ({ x: `; ${css}` });
|
|
|
16
16
|
export function vanillaClass(cssOrDebugId, css) {
|
|
17
17
|
const debugId = css != null ? cssOrDebugId : undefined;
|
|
18
18
|
css = css != null ? css : cssOrDebugId;
|
|
19
|
+
if (typeof css === 'function') {
|
|
20
|
+
const className = style({}, debugId);
|
|
21
|
+
vanillaGlobal(css(className));
|
|
22
|
+
return className;
|
|
23
|
+
}
|
|
19
24
|
return style(vanillaProps(css), debugId);
|
|
20
25
|
}
|
|
21
26
|
// ---------------------------------------------------------------------------
|
package/package.json
CHANGED
package/vanillaExtract.d.ts
CHANGED
|
@@ -17,8 +17,8 @@ export declare const vanillaProps: (css: string) => GlobalStyleRule;
|
|
|
17
17
|
*
|
|
18
18
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#vanillaclass
|
|
19
19
|
*/
|
|
20
|
-
export declare function vanillaClass(css: string): string;
|
|
21
|
-
export declare function vanillaClass(debugId: string, css: string): string;
|
|
20
|
+
export declare function vanillaClass(css: string | ((className: string) => string)): string;
|
|
21
|
+
export declare function vanillaClass(debugId: string, css: string | ((className: string) => string)): string;
|
|
22
22
|
/**
|
|
23
23
|
* Replaces all `&` tokens with the given selector string, in a direct
|
|
24
24
|
* (read. "dumb") way. It's mainly useful when used with style-mixins, etc.
|
package/vanillaExtract.js
CHANGED
|
@@ -21,6 +21,11 @@ exports.vanillaProps = vanillaProps;
|
|
|
21
21
|
function vanillaClass(cssOrDebugId, css) {
|
|
22
22
|
const debugId = css != null ? cssOrDebugId : undefined;
|
|
23
23
|
css = css != null ? css : cssOrDebugId;
|
|
24
|
+
if (typeof css === 'function') {
|
|
25
|
+
const className = (0, css_1.style)({}, debugId);
|
|
26
|
+
(0, exports.vanillaGlobal)(css(className));
|
|
27
|
+
return className;
|
|
28
|
+
}
|
|
24
29
|
return (0, css_1.style)((0, exports.vanillaProps)(css), debugId);
|
|
25
30
|
}
|
|
26
31
|
exports.vanillaClass = vanillaClass;
|