@reykjavik/webtools 0.1.36 → 0.2.0
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 +19 -6
- package/CookieHubConsent.d.ts +2 -2
- package/CookieHubConsent.js +2 -2
- package/README.md +9 -5
- package/SiteImprove.d.ts +6 -7
- package/SiteImprove.js +23 -37
- package/async.d.ts +2 -2
- package/async.js +1 -1
- package/errorhandling.d.ts +10 -10
- package/errorhandling.js +7 -7
- package/esm/CookieHubConsent.d.ts +2 -2
- package/esm/CookieHubConsent.js +2 -2
- package/esm/SiteImprove.d.ts +6 -7
- package/esm/SiteImprove.js +23 -14
- package/esm/async.d.ts +2 -2
- package/esm/async.js +1 -1
- package/esm/errorhandling.d.ts +10 -10
- package/esm/errorhandling.js +7 -7
- package/esm/http.d.ts +5 -5
- package/esm/http.js +4 -4
- package/esm/index.d.ts +2 -3
- package/esm/next/http.d.ts +2 -2
- package/esm/next/http.js +3 -3
- package/{remix → esm/react-router}/Wait.d.ts +2 -2
- package/esm/{remix → react-router}/Wait.js +2 -2
- package/esm/{remix → react-router}/http.d.ts +1 -1
- package/esm/{remix → react-router}/http.js +1 -1
- package/esm/vanillaExtract.d.ts +3 -132
- package/esm/vanillaExtract.js +2 -67
- package/http.d.ts +5 -5
- package/http.js +4 -4
- package/index.d.ts +2 -3
- package/next/http.d.ts +2 -2
- package/next/http.js +3 -3
- package/package.json +13 -17
- package/{esm/remix → react-router}/Wait.d.ts +2 -2
- package/{remix → react-router}/Wait.js +3 -3
- package/{remix → react-router}/http.d.ts +1 -1
- package/{remix → react-router}/http.js +1 -1
- package/vanillaExtract.d.ts +3 -132
- package/vanillaExtract.js +3 -70
- package/esm/next/SiteImprove.d.ts +0 -10
- package/esm/next/SiteImprove.js +0 -7
- package/next/SiteImprove.d.ts +0 -10
- package/next/SiteImprove.js +0 -10
package/index.d.ts
CHANGED
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
/// <reference path="./async.d.ts" />
|
|
4
4
|
/// <reference path="./fixIcelandicLocale.d.ts" />
|
|
5
5
|
/// <reference path="./errorhandling.d.ts" />
|
|
6
|
-
/// <reference path="./
|
|
6
|
+
/// <reference path="./react-router/http.d.ts" />
|
|
7
7
|
/// <reference path="./SiteImprove.d.tsx" />
|
|
8
8
|
/// <reference path="./CookieHubConsent.d.tsx" />
|
|
9
|
-
/// <reference path="./
|
|
10
|
-
/// <reference path="./next/SiteImprove.d.tsx" />
|
|
9
|
+
/// <reference path="./react-router/Wait.d.tsx" />
|
|
11
10
|
/// <reference path="./next/http.d.tsx" />
|
|
12
11
|
|
|
13
12
|
export {};
|
package/next/http.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export type InferErrorPageProps<SEP extends ShowErrorPageFn<any>> = Cleanup<Retu
|
|
|
26
26
|
* cases when `getServerSideProps` returns an `__error` prop with `statusCode`
|
|
27
27
|
* and optional friendly `message`.
|
|
28
28
|
*
|
|
29
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
29
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-nextjs.md#makeerrorizeapphoc
|
|
30
30
|
*/
|
|
31
31
|
export declare const makeErrorizeAppHOC: <EP extends Partial<ErrorProps>>(ErrorPage: React.FunctionComponent<EP>) => {
|
|
32
32
|
<P extends {
|
|
@@ -48,7 +48,7 @@ export declare const makeErrorizeAppHOC: <EP extends Partial<ErrorProps>>(ErrorP
|
|
|
48
48
|
* to return an `HTTP_304_NotModified` response with an empty props object,
|
|
49
49
|
* in a way that doesn't make TypeScript shout at you.
|
|
50
50
|
*
|
|
51
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
51
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-nextjs.md#notmodified304-helper
|
|
52
52
|
*/
|
|
53
53
|
export declare const notModified304: (response: ServerResponse | NextContextLike) => {
|
|
54
54
|
readonly props: any;
|
package/next/http.js
CHANGED
|
@@ -29,7 +29,7 @@ __exportStar(require("../http.js"), exports);
|
|
|
29
29
|
* Use this method inside a `getServerSideProps` method (or API route)
|
|
30
30
|
* to return an error page with proper HTTP status code and all the shit.
|
|
31
31
|
*
|
|
32
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
32
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-nextjs.md#showerrorpage-helper
|
|
33
33
|
*/
|
|
34
34
|
const showErrorPage = (response, error, ttl = '2s') => {
|
|
35
35
|
error =
|
|
@@ -53,7 +53,7 @@ const showErrorPage = (response, error, ttl = '2s') => {
|
|
|
53
53
|
* cases when `getServerSideProps` returns an `__error` prop with `statusCode`
|
|
54
54
|
* and optional friendly `message`.
|
|
55
55
|
*
|
|
56
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
56
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-nextjs.md#makeerrorizeapphoc
|
|
57
57
|
*/
|
|
58
58
|
const makeErrorizeAppHOC = (ErrorPage) => {
|
|
59
59
|
// the HOC
|
|
@@ -83,7 +83,7 @@ exports.makeErrorizeAppHOC = makeErrorizeAppHOC;
|
|
|
83
83
|
* to return an `HTTP_304_NotModified` response with an empty props object,
|
|
84
84
|
* in a way that doesn't make TypeScript shout at you.
|
|
85
85
|
*
|
|
86
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
86
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-nextjs.md#notmodified304-helper
|
|
87
87
|
*/
|
|
88
88
|
const notModified304 = (response) => {
|
|
89
89
|
response = 'res' in response ? response.res : response;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reykjavik/webtools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Misc. JS/TS helpers used by Reykjavík City's web dev teams.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": "ssh://git@github.com:reykjavikcity/webtools.git",
|
|
@@ -14,16 +14,13 @@
|
|
|
14
14
|
"@reykjavik/hanna-utils": "^0.2.16"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@remix-run/react": "^2.6.0",
|
|
18
17
|
"@vanilla-extract/css": "^1.14.1",
|
|
19
18
|
"next": ">=11",
|
|
20
19
|
"react": ">=16.8.0",
|
|
21
|
-
"react-dom": ">=16.8.0"
|
|
20
|
+
"react-dom": ">=16.8.0",
|
|
21
|
+
"react-router": "^7.0.2"
|
|
22
22
|
},
|
|
23
23
|
"peerDependenciesMeta": {
|
|
24
|
-
"@remix-run/react": {
|
|
25
|
-
"optional": true
|
|
26
|
-
},
|
|
27
24
|
"@vanilla-extract/css": {
|
|
28
25
|
"optional": true
|
|
29
26
|
},
|
|
@@ -35,10 +32,13 @@
|
|
|
35
32
|
},
|
|
36
33
|
"react-dom": {
|
|
37
34
|
"optional": true
|
|
35
|
+
},
|
|
36
|
+
"react-router": {
|
|
37
|
+
"optional": true
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
41
|
-
"node": ">=
|
|
41
|
+
"node": ">=20"
|
|
42
42
|
},
|
|
43
43
|
"sideEffects": [
|
|
44
44
|
"**/fixIcelandicLocale.js"
|
|
@@ -68,9 +68,9 @@
|
|
|
68
68
|
"import": "./esm/errorhandling.js",
|
|
69
69
|
"require": "./errorhandling.js"
|
|
70
70
|
},
|
|
71
|
-
"./
|
|
72
|
-
"import": "./esm/
|
|
73
|
-
"require": "./
|
|
71
|
+
"./react-router/http": {
|
|
72
|
+
"import": "./esm/react-router/http.js",
|
|
73
|
+
"require": "./react-router/http.js"
|
|
74
74
|
},
|
|
75
75
|
"./SiteImprove": {
|
|
76
76
|
"import": "./esm/SiteImprove.js",
|
|
@@ -80,13 +80,9 @@
|
|
|
80
80
|
"import": "./esm/CookieHubConsent.js",
|
|
81
81
|
"require": "./CookieHubConsent.js"
|
|
82
82
|
},
|
|
83
|
-
"./
|
|
84
|
-
"import": "./esm/
|
|
85
|
-
"require": "./
|
|
86
|
-
},
|
|
87
|
-
"./next/SiteImprove": {
|
|
88
|
-
"import": "./esm/next/SiteImprove.js",
|
|
89
|
-
"require": "./next/SiteImprove.js"
|
|
83
|
+
"./react-router/Wait": {
|
|
84
|
+
"import": "./esm/react-router/Wait.js",
|
|
85
|
+
"require": "./react-router/Wait.js"
|
|
90
86
|
},
|
|
91
87
|
"./next/http": {
|
|
92
88
|
"import": "./esm/next/http.js",
|
|
@@ -31,7 +31,7 @@ export type WaitProps<T> = WaitPropsBase<T> & WaitFallbacks;
|
|
|
31
31
|
* custom properties for `meanwhile` and `error` fallbacks, and/or other
|
|
32
32
|
* behaviors.
|
|
33
33
|
*
|
|
34
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
34
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-rr.md#type-waitcomponent
|
|
35
35
|
*/
|
|
36
36
|
export type WaitComponent<CustomProps extends Record<string, unknown> = Record<never, never>> = (<T>(props: WaitPropsBase<T> & CustomProps) => ReactElement) & {
|
|
37
37
|
displayName?: string;
|
|
@@ -43,7 +43,7 @@ export type WaitComponent<CustomProps extends Record<string, unknown> = Record<n
|
|
|
43
43
|
* If the awaited promise (`props.for`) resolves to an object with a truthy
|
|
44
44
|
* `$error` property, the `$error` will be thrown.
|
|
45
45
|
*
|
|
46
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
46
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-rr.md#wait-component
|
|
47
47
|
*/
|
|
48
48
|
export declare const Wait: WaitComponent<WaitFallbacks>;
|
|
49
49
|
export {};
|
|
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.Wait = void 0;
|
|
27
27
|
const react_1 = __importStar(require("react"));
|
|
28
|
-
const
|
|
28
|
+
const react_router_1 = require("react-router");
|
|
29
29
|
/**
|
|
30
30
|
* A thin wrapper around [Remix's `Await`](https://remix.run/docs/en/2/components/await)
|
|
31
31
|
* component, to provide a more ergonomic API.
|
|
@@ -33,10 +33,10 @@ const react_2 = require("@remix-run/react");
|
|
|
33
33
|
* If the awaited promise (`props.for`) resolves to an object with a truthy
|
|
34
34
|
* `$error` property, the `$error` will be thrown.
|
|
35
35
|
*
|
|
36
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
36
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-rr.md#wait-component
|
|
37
37
|
*/
|
|
38
38
|
const Wait = (props) => (react_1.default.createElement(react_1.Suspense, { fallback: props.meanwhile || 'Loading...' },
|
|
39
|
-
react_1.default.createElement(
|
|
39
|
+
react_1.default.createElement(react_router_1.Await, { resolve: props.for, errorElement: props.error || 'An error occurred.' }, (value) => {
|
|
40
40
|
if (value && // eslint-disable-line @typescript-eslint/no-unnecessary-condition
|
|
41
41
|
typeof value === 'object' &&
|
|
42
42
|
'$error' in value &&
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* Detects if the request is a client fetch, or an initial/full-page load.
|
|
3
3
|
* Useful for deciding whether to defer data fetching or not.
|
|
4
4
|
*
|
|
5
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
5
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-rr.md#isclientfetch
|
|
6
6
|
*/
|
|
7
7
|
export declare const isClientFetch: (request: Request) => boolean;
|
|
@@ -5,7 +5,7 @@ exports.isClientFetch = void 0;
|
|
|
5
5
|
* Detects if the request is a client fetch, or an initial/full-page load.
|
|
6
6
|
* Useful for deciding whether to defer data fetching or not.
|
|
7
7
|
*
|
|
8
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
8
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-rr.md#isclientfetch
|
|
9
9
|
*/
|
|
10
10
|
const isClientFetch = (request) =>
|
|
11
11
|
// For info about this detection method:
|
package/vanillaExtract.d.ts
CHANGED
|
@@ -2,14 +2,14 @@ import { GlobalStyleRule } from '@vanilla-extract/css';
|
|
|
2
2
|
/**
|
|
3
3
|
* Adds free-form CSS as a globalStyle
|
|
4
4
|
*
|
|
5
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
5
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#vanillaglobal
|
|
6
6
|
*/
|
|
7
7
|
export declare const vanillaGlobal: (css: string) => void;
|
|
8
8
|
/**
|
|
9
9
|
* Spreads the return value into a style object, to inject free-form CSS
|
|
10
10
|
* properties (or nested blocks)
|
|
11
11
|
*
|
|
12
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
12
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#vanillaprops
|
|
13
13
|
*/
|
|
14
14
|
export declare const vanillaProps: (css: string) => GlobalStyleRule;
|
|
15
15
|
type ClassNameCallback = (
|
|
@@ -27,137 +27,8 @@ classNameSelector: string) => string;
|
|
|
27
27
|
*
|
|
28
28
|
* To opt out of the `&&` replacement, use the callback function signature.
|
|
29
29
|
*
|
|
30
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
30
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#vanillaclass
|
|
31
31
|
*/
|
|
32
32
|
export declare function vanillaClass(css: string | ClassNameCallback): string;
|
|
33
33
|
export declare function vanillaClass(debugId: string, css: string | ClassNameCallback): string;
|
|
34
|
-
/**
|
|
35
|
-
* @deprecated (Will be removed in v0.2)
|
|
36
|
-
*
|
|
37
|
-
* Replaces all `&` tokens with the given selector string, in a direct
|
|
38
|
-
* (read. "dumb") way. It's mainly useful when used with style-mixins, etc.
|
|
39
|
-
*
|
|
40
|
-
* **NOTE:** `vanillaNest` does NOT support deeply nested blocks, or anything
|
|
41
|
-
* so fancy. It will also replace `&` characters inside values, comments, etc.
|
|
42
|
-
* If you need something more sophisticated, use a custom `postcss` config.
|
|
43
|
-
*
|
|
44
|
-
* ```ts
|
|
45
|
-
* // someCssHelper.ts
|
|
46
|
-
* import { vanillaNest } from '@reykjavik/webtools/vanillaExtract';
|
|
47
|
-
*
|
|
48
|
-
* export const hoverGlow = (
|
|
49
|
-
* ampSelector: string,
|
|
50
|
-
* glowiness?: 'normal' | 'insane'
|
|
51
|
-
* ) =>
|
|
52
|
-
* vanillaNest(
|
|
53
|
-
* ampSelector,
|
|
54
|
-
* `
|
|
55
|
-
* &:hover {
|
|
56
|
-
* box-shadow: 0 0 20px 5px ${
|
|
57
|
-
* glowiness === 'insane' ? 'hotpink' : 'salmon'
|
|
58
|
-
* };
|
|
59
|
-
* }
|
|
60
|
-
* `
|
|
61
|
-
* );
|
|
62
|
-
*
|
|
63
|
-
* // ...then, somewhere else in a *.css.ts file:
|
|
64
|
-
*
|
|
65
|
-
* import { hoverGlow } from '~/someCssHelper.js';
|
|
66
|
-
* import { vanillaGlobal } from '@reykjavik/webtools/vanillaExtract';
|
|
67
|
-
*
|
|
68
|
-
* vanillaGlobal(`
|
|
69
|
-
* .MyComponent {
|
|
70
|
-
* border: 1px solid #ccc;
|
|
71
|
-
* padding: 1em;
|
|
72
|
-
* }
|
|
73
|
-
* ${hoverGlow('.MyComponent')}
|
|
74
|
-
*
|
|
75
|
-
* .MyOtherComponent {
|
|
76
|
-
* border: 1px solid #ccc;
|
|
77
|
-
* padding: 1em;
|
|
78
|
-
* }
|
|
79
|
-
* ${hoverGlow('.MyOtherComponent', 'insane')}
|
|
80
|
-
* `);
|
|
81
|
-
* ```
|
|
82
|
-
*
|
|
83
|
-
* (This low-level utility function is used internally by `vanillaClassNested`.
|
|
84
|
-
*/
|
|
85
|
-
export declare const vanillaNest: (ampSelector: string, css: string) => string;
|
|
86
|
-
/**
|
|
87
|
-
* @deprecated (Will be removed in v0.2)
|
|
88
|
-
*
|
|
89
|
-
* Returns a scoped cssClassName styled with free-form CSS.
|
|
90
|
-
*
|
|
91
|
-
* It also automatically replaces all `&`-tokens with
|
|
92
|
-
* the selector for the auto-generated class-name.
|
|
93
|
-
*
|
|
94
|
-
* ```ts
|
|
95
|
-
* // someFile.css.ts
|
|
96
|
-
* import { vanillaClassNested } from '@reykjavik/webtools/vanillaExtract';
|
|
97
|
-
*
|
|
98
|
-
* export const myClass = vanillaClassNested(`
|
|
99
|
-
* background-color: #ccc;
|
|
100
|
-
* padding: .5em 1em;
|
|
101
|
-
*
|
|
102
|
-
* /* Nested blocks begin: */
|
|
103
|
-
* &:hover {
|
|
104
|
-
* background-color: #666;
|
|
105
|
-
* color: white;
|
|
106
|
-
* }
|
|
107
|
-
* & > strong {
|
|
108
|
-
* color: maroon;
|
|
109
|
-
* }
|
|
110
|
-
* html[data-color-theme="unicorn"] & {
|
|
111
|
-
* background-color: pink;
|
|
112
|
-
* }
|
|
113
|
-
* `);
|
|
114
|
-
* ```
|
|
115
|
-
*
|
|
116
|
-
* **NOTE:** All "bare" (un-nested) style properties **must come first**,
|
|
117
|
-
* before any nested blocks.
|
|
118
|
-
*
|
|
119
|
-
* **NOTE 2:** `vanillaClassNested` does NOT support deeply nested blocks, or
|
|
120
|
-
* anything so fancy. It will also replace `&` characters inside values,
|
|
121
|
-
* comments, etc. If you need something more sophisticated, use a custom
|
|
122
|
-
* `postcss` config.
|
|
123
|
-
*/
|
|
124
|
-
export declare function vanillaClassNested(css: string): string;
|
|
125
|
-
/** @deprecated (Will be removed in v0.2) */
|
|
126
|
-
/**
|
|
127
|
-
* Returns a scoped cssClassName styled with free-form CSS.
|
|
128
|
-
*
|
|
129
|
-
* It also automatically replaces all `&`-tokens with
|
|
130
|
-
* the selector for the auto-generated class-name.
|
|
131
|
-
*
|
|
132
|
-
* ```ts
|
|
133
|
-
* // someFile.css.ts
|
|
134
|
-
* import { vanillaClassNested } from '@reykjavik/webtools/vanillaExtract';
|
|
135
|
-
*
|
|
136
|
-
* export const myClass = vanillaClassNested(`
|
|
137
|
-
* background-color: #ccc;
|
|
138
|
-
* padding: .5em 1em;
|
|
139
|
-
*
|
|
140
|
-
* /* Nested blocks begin: */
|
|
141
|
-
* &:hover {
|
|
142
|
-
* background-color: #666;
|
|
143
|
-
* color: white;
|
|
144
|
-
* }
|
|
145
|
-
* & > strong {
|
|
146
|
-
* color: maroon;
|
|
147
|
-
* }
|
|
148
|
-
* html[data-color-theme="unicorn"] & {
|
|
149
|
-
* background-color: pink;
|
|
150
|
-
* }
|
|
151
|
-
* `);
|
|
152
|
-
* ```
|
|
153
|
-
*
|
|
154
|
-
* **NOTE:** All "bare" (un-nested) style properties **must come first**,
|
|
155
|
-
* before any nested blocks.
|
|
156
|
-
*
|
|
157
|
-
* **NOTE 2:** `vanillaClassNested` does NOT support deeply nested blocks, or
|
|
158
|
-
* anything so fancy. It will also replace `&` characters inside values,
|
|
159
|
-
* comments, etc. If you need something more sophisticated, use a custom
|
|
160
|
-
* `postcss` config.
|
|
161
|
-
*/
|
|
162
|
-
export declare function vanillaClassNested(debugId: string, css: string): string;
|
|
163
34
|
export {};
|
package/vanillaExtract.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.vanillaClass = exports.vanillaProps = exports.vanillaGlobal = void 0;
|
|
4
4
|
const css_1 = require("@vanilla-extract/css");
|
|
5
5
|
/**
|
|
6
6
|
* Adds free-form CSS as a globalStyle
|
|
7
7
|
*
|
|
8
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
8
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#vanillaglobal
|
|
9
9
|
*/
|
|
10
10
|
const vanillaGlobal = (css) => (0, css_1.globalStyle)('x', { x: `} ${css} x{x:` });
|
|
11
11
|
exports.vanillaGlobal = vanillaGlobal;
|
|
@@ -14,7 +14,7 @@ exports.vanillaGlobal = vanillaGlobal;
|
|
|
14
14
|
* Spreads the return value into a style object, to inject free-form CSS
|
|
15
15
|
* properties (or nested blocks)
|
|
16
16
|
*
|
|
17
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
17
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#vanillaprops
|
|
18
18
|
*/
|
|
19
19
|
const vanillaProps = (css) => ({ x: `; ${css}` });
|
|
20
20
|
exports.vanillaProps = vanillaProps;
|
|
@@ -31,70 +31,3 @@ function vanillaClass(cssOrDebugId, css) {
|
|
|
31
31
|
return className;
|
|
32
32
|
}
|
|
33
33
|
exports.vanillaClass = vanillaClass;
|
|
34
|
-
// ---------------------------------------------------------------------------
|
|
35
|
-
/**
|
|
36
|
-
* @deprecated (Will be removed in v0.2)
|
|
37
|
-
*
|
|
38
|
-
* Replaces all `&` tokens with the given selector string, in a direct
|
|
39
|
-
* (read. "dumb") way. It's mainly useful when used with style-mixins, etc.
|
|
40
|
-
*
|
|
41
|
-
* **NOTE:** `vanillaNest` does NOT support deeply nested blocks, or anything
|
|
42
|
-
* so fancy. It will also replace `&` characters inside values, comments, etc.
|
|
43
|
-
* If you need something more sophisticated, use a custom `postcss` config.
|
|
44
|
-
*
|
|
45
|
-
* ```ts
|
|
46
|
-
* // someCssHelper.ts
|
|
47
|
-
* import { vanillaNest } from '@reykjavik/webtools/vanillaExtract';
|
|
48
|
-
*
|
|
49
|
-
* export const hoverGlow = (
|
|
50
|
-
* ampSelector: string,
|
|
51
|
-
* glowiness?: 'normal' | 'insane'
|
|
52
|
-
* ) =>
|
|
53
|
-
* vanillaNest(
|
|
54
|
-
* ampSelector,
|
|
55
|
-
* `
|
|
56
|
-
* &:hover {
|
|
57
|
-
* box-shadow: 0 0 20px 5px ${
|
|
58
|
-
* glowiness === 'insane' ? 'hotpink' : 'salmon'
|
|
59
|
-
* };
|
|
60
|
-
* }
|
|
61
|
-
* `
|
|
62
|
-
* );
|
|
63
|
-
*
|
|
64
|
-
* // ...then, somewhere else in a *.css.ts file:
|
|
65
|
-
*
|
|
66
|
-
* import { hoverGlow } from '~/someCssHelper.js';
|
|
67
|
-
* import { vanillaGlobal } from '@reykjavik/webtools/vanillaExtract';
|
|
68
|
-
*
|
|
69
|
-
* vanillaGlobal(`
|
|
70
|
-
* .MyComponent {
|
|
71
|
-
* border: 1px solid #ccc;
|
|
72
|
-
* padding: 1em;
|
|
73
|
-
* }
|
|
74
|
-
* ${hoverGlow('.MyComponent')}
|
|
75
|
-
*
|
|
76
|
-
* .MyOtherComponent {
|
|
77
|
-
* border: 1px solid #ccc;
|
|
78
|
-
* padding: 1em;
|
|
79
|
-
* }
|
|
80
|
-
* ${hoverGlow('.MyOtherComponent', 'insane')}
|
|
81
|
-
* `);
|
|
82
|
-
* ```
|
|
83
|
-
*
|
|
84
|
-
* (This low-level utility function is used internally by `vanillaClassNested`.
|
|
85
|
-
*/
|
|
86
|
-
const vanillaNest = (ampSelector, css) => css.replace(/&/g, ampSelector);
|
|
87
|
-
exports.vanillaNest = vanillaNest;
|
|
88
|
-
function vanillaClassNested(cssOrDebugId, css) {
|
|
89
|
-
const debugId = css != null ? cssOrDebugId : undefined;
|
|
90
|
-
css = css != null ? css : cssOrDebugId;
|
|
91
|
-
const nestPoint = css.indexOf('&');
|
|
92
|
-
const bareStyles = nestPoint > -1 ? css.slice(0, nestPoint) : css;
|
|
93
|
-
const nestedStyles = nestPoint > -1 ? css.slice(nestPoint) : undefined;
|
|
94
|
-
const className = (0, css_1.style)((0, exports.vanillaProps)(bareStyles), debugId);
|
|
95
|
-
if (nestedStyles) {
|
|
96
|
-
(0, exports.vanillaGlobal)((0, exports.vanillaNest)(`.${className}`, nestedStyles));
|
|
97
|
-
}
|
|
98
|
-
return className;
|
|
99
|
-
}
|
|
100
|
-
exports.vanillaClassNested = vanillaClassNested;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" resolution-mode="require"/>
|
|
2
|
-
import { SiteImproveProps as _SiteImproveProps } from '../SiteImprove.js';
|
|
3
|
-
/** @deprecated Instead import from `@reykjavik/webtools/SiteImprove` (Will be removed in v0.2) */
|
|
4
|
-
export type SiteImproveProps = _SiteImproveProps;
|
|
5
|
-
/** @deprecated Instead import from `@reykjavik/webtools/SiteImprove` (Will be removed in v0.2) */
|
|
6
|
-
export declare const SiteImprove: (props: _SiteImproveProps) => import("react").JSX.Element | null;
|
|
7
|
-
/** @deprecated Instead import from `@reykjavik/webtools/SiteImprove` (Will be removed in v0.2) */
|
|
8
|
-
export declare const pingSiteImprove: (category: string, action: string, label?: string | undefined) => void;
|
|
9
|
-
/** @deprecated Instead import from `@reykjavik/webtools/SiteImprove` (Will be removed in v0.2) */
|
|
10
|
-
export declare const pingSiteImproveOutbound: (ourl: string) => void;
|
package/esm/next/SiteImprove.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { pingSiteImprove as _pingSiteImprove, pingSiteImproveOutbound as _pingSiteImproveOutbound, SiteImprove as _SiteImprove, } from '../SiteImprove.js';
|
|
2
|
-
/** @deprecated Instead import from `@reykjavik/webtools/SiteImprove` (Will be removed in v0.2) */
|
|
3
|
-
export const SiteImprove = _SiteImprove;
|
|
4
|
-
/** @deprecated Instead import from `@reykjavik/webtools/SiteImprove` (Will be removed in v0.2) */
|
|
5
|
-
export const pingSiteImprove = _pingSiteImprove;
|
|
6
|
-
/** @deprecated Instead import from `@reykjavik/webtools/SiteImprove` (Will be removed in v0.2) */
|
|
7
|
-
export const pingSiteImproveOutbound = _pingSiteImproveOutbound;
|
package/next/SiteImprove.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { SiteImproveProps as _SiteImproveProps } from '../SiteImprove.js';
|
|
3
|
-
/** @deprecated Instead import from `@reykjavik/webtools/SiteImprove` (Will be removed in v0.2) */
|
|
4
|
-
export type SiteImproveProps = _SiteImproveProps;
|
|
5
|
-
/** @deprecated Instead import from `@reykjavik/webtools/SiteImprove` (Will be removed in v0.2) */
|
|
6
|
-
export declare const SiteImprove: (props: _SiteImproveProps) => import("react").JSX.Element | null;
|
|
7
|
-
/** @deprecated Instead import from `@reykjavik/webtools/SiteImprove` (Will be removed in v0.2) */
|
|
8
|
-
export declare const pingSiteImprove: (category: string, action: string, label?: string | undefined) => void;
|
|
9
|
-
/** @deprecated Instead import from `@reykjavik/webtools/SiteImprove` (Will be removed in v0.2) */
|
|
10
|
-
export declare const pingSiteImproveOutbound: (ourl: string) => void;
|
package/next/SiteImprove.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pingSiteImproveOutbound = exports.pingSiteImprove = exports.SiteImprove = void 0;
|
|
4
|
-
const SiteImprove_js_1 = require("../SiteImprove.js");
|
|
5
|
-
/** @deprecated Instead import from `@reykjavik/webtools/SiteImprove` (Will be removed in v0.2) */
|
|
6
|
-
exports.SiteImprove = SiteImprove_js_1.SiteImprove;
|
|
7
|
-
/** @deprecated Instead import from `@reykjavik/webtools/SiteImprove` (Will be removed in v0.2) */
|
|
8
|
-
exports.pingSiteImprove = SiteImprove_js_1.pingSiteImprove;
|
|
9
|
-
/** @deprecated Instead import from `@reykjavik/webtools/SiteImprove` (Will be removed in v0.2) */
|
|
10
|
-
exports.pingSiteImproveOutbound = SiteImprove_js_1.pingSiteImproveOutbound;
|