@netlify/spark-ui 0.0.33 → 0.0.35
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/components/preact/SearchModal/components/SearchModal/SearchModal.js +44 -88
- package/dist/components/preact/SearchModal/hooks/useSearch.js +13 -13
- package/package.json +2 -4
- package/packages/components/Tabs.astro +4 -4
- package/packages/components/preact/SearchModal/components/SearchModal/SearchModal.tsx +1 -2
- package/packages/components/preact/SearchModal/hooks/useSearch.ts +3 -1
- package/packages/styles/buttons.css +24 -7
- package/packages/styles/tabs.css +18 -8
- package/packages/styles/tokens.css +5 -0
|
@@ -1,106 +1,62 @@
|
|
|
1
|
-
import { u as
|
|
2
|
-
import { A as
|
|
1
|
+
import { u as e } from "../../../../../chunks/jsxRuntime.module.Bzuv3cXw.js";
|
|
2
|
+
import { A as N, y as u, d as v } from "../../../../../chunks/hooks.module.BFfOesdf.js";
|
|
3
3
|
import T from "../../../Modal/Modal.js";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { useSearch as
|
|
8
|
-
import { useKeyboardNav as
|
|
9
|
-
import { useSearchHotkeys as
|
|
10
|
-
import { useSearchParams as
|
|
11
|
-
import { useSearchToggles as
|
|
12
|
-
import '../../../../../assets/SearchModal.css';function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
Copyright (c) 2018 Jed Watson.
|
|
18
|
-
Licensed under the MIT License (MIT), see
|
|
19
|
-
http://jedwatson.github.io/classnames
|
|
20
|
-
*/
|
|
21
|
-
var w;
|
|
22
|
-
function C() {
|
|
23
|
-
return w || (w = 1, function(t) {
|
|
24
|
-
(function() {
|
|
25
|
-
var s = {}.hasOwnProperty;
|
|
26
|
-
function o() {
|
|
27
|
-
for (var e = "", r = 0; r < arguments.length; r++) {
|
|
28
|
-
var a = arguments[r];
|
|
29
|
-
a && (e = l(e, c(a)));
|
|
30
|
-
}
|
|
31
|
-
return e;
|
|
32
|
-
}
|
|
33
|
-
function c(e) {
|
|
34
|
-
if (typeof e == "string" || typeof e == "number")
|
|
35
|
-
return e;
|
|
36
|
-
if (typeof e != "object")
|
|
37
|
-
return "";
|
|
38
|
-
if (Array.isArray(e))
|
|
39
|
-
return o.apply(null, e);
|
|
40
|
-
if (e.toString !== Object.prototype.toString && !e.toString.toString().includes("[native code]"))
|
|
41
|
-
return e.toString();
|
|
42
|
-
var r = "";
|
|
43
|
-
for (var a in e)
|
|
44
|
-
s.call(e, a) && e[a] && (r = l(r, a));
|
|
45
|
-
return r;
|
|
46
|
-
}
|
|
47
|
-
function l(e, r) {
|
|
48
|
-
return r ? e ? e + " " + r : e + r : e;
|
|
49
|
-
}
|
|
50
|
-
t.exports ? (o.default = o, t.exports = o) : window.classNames = o;
|
|
51
|
-
})();
|
|
52
|
-
}(h)), h.exports;
|
|
53
|
-
}
|
|
54
|
-
var M = C();
|
|
55
|
-
const A = /* @__PURE__ */ x(M);
|
|
56
|
-
function K(t) {
|
|
57
|
-
const s = O(null);
|
|
58
|
-
return v(() => {
|
|
59
|
-
function o(c) {
|
|
60
|
-
s.current && !s.current.contains(c.target) && t();
|
|
4
|
+
import d from "../../../KeyboardKey/KeyboardKey.js";
|
|
5
|
+
import k from "../SearchWindow.js";
|
|
6
|
+
import w from "../SearchInput.js";
|
|
7
|
+
import { useSearch as I } from "../../hooks/useSearch.js";
|
|
8
|
+
import { useKeyboardNav as L } from "../../hooks/useKeyboardNav.js";
|
|
9
|
+
import { useSearchHotkeys as O } from "../../hooks/useSearchHotkeys.js";
|
|
10
|
+
import { useSearchParams as P } from "../../hooks/useSearchParams.js";
|
|
11
|
+
import { useSearchToggles as E } from "../../hooks/useSearchToggles.js";
|
|
12
|
+
import '../../../../../assets/SearchModal.css';function K(s) {
|
|
13
|
+
const r = N(null);
|
|
14
|
+
return u(() => {
|
|
15
|
+
function t(i) {
|
|
16
|
+
r.current && !r.current.contains(i.target) && s();
|
|
61
17
|
}
|
|
62
|
-
return document.addEventListener("mousedown",
|
|
63
|
-
document.removeEventListener("mousedown",
|
|
18
|
+
return document.addEventListener("mousedown", t), () => {
|
|
19
|
+
document.removeEventListener("mousedown", t);
|
|
64
20
|
};
|
|
65
|
-
}, [
|
|
21
|
+
}, [s]), r;
|
|
66
22
|
}
|
|
67
|
-
function
|
|
68
|
-
const [
|
|
69
|
-
|
|
70
|
-
let
|
|
71
|
-
const
|
|
72
|
-
window.pagefind && (
|
|
23
|
+
function j(s = { className: "", children: null }) {
|
|
24
|
+
const [r, t] = v(!1);
|
|
25
|
+
u(() => {
|
|
26
|
+
let c;
|
|
27
|
+
const S = () => {
|
|
28
|
+
window.pagefind && (t(!0), c && clearInterval(c));
|
|
73
29
|
};
|
|
74
|
-
return
|
|
30
|
+
return S(), c = setInterval(S, 100), () => clearInterval(c);
|
|
75
31
|
}, []);
|
|
76
|
-
const { children:
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
}, [
|
|
80
|
-
/* @__PURE__ */
|
|
81
|
-
/* @__PURE__ */
|
|
82
|
-
|
|
32
|
+
const { children: i, className: f, ...g } = s, { state: n, actions: h } = I(), [o, p] = v(!1), l = () => p(!0), m = () => p(!1), a = N(null), y = K(m);
|
|
33
|
+
return E(r, l), P(r, h.setSearchTerm, l), O(r, o, l, m), L(r, a, o, m), u(() => {
|
|
34
|
+
a.current && (o ? a.current.showModal() : a.current.close());
|
|
35
|
+
}, [o]), /* @__PURE__ */ e(T, { ref: a, className: `n-search-modal ${f || ""}`, ...g, children: /* @__PURE__ */ e("div", { ref: y, className: "n-search-container", children: [
|
|
36
|
+
/* @__PURE__ */ e(w, { setSearchTerm: h.setSearchTerm, initialValue: n.searchTerm }),
|
|
37
|
+
/* @__PURE__ */ e(
|
|
38
|
+
k,
|
|
83
39
|
{
|
|
84
|
-
searchLoading:
|
|
85
|
-
searchTerm:
|
|
86
|
-
results:
|
|
87
|
-
children:
|
|
40
|
+
searchLoading: n.isLoading,
|
|
41
|
+
searchTerm: n.searchTerm,
|
|
42
|
+
results: n.results,
|
|
43
|
+
children: i
|
|
88
44
|
}
|
|
89
45
|
),
|
|
90
|
-
/* @__PURE__ */
|
|
91
|
-
/* @__PURE__ */
|
|
92
|
-
/* @__PURE__ */
|
|
46
|
+
/* @__PURE__ */ e("div", { className: "n-search-footer", children: [
|
|
47
|
+
/* @__PURE__ */ e("p", { className: "n-search-footer-tip", children: [
|
|
48
|
+
/* @__PURE__ */ e(d, { keyNames: ["Esc"] }),
|
|
93
49
|
"to close"
|
|
94
50
|
] }),
|
|
95
|
-
/* @__PURE__ */
|
|
96
|
-
/* @__PURE__ */
|
|
97
|
-
/* @__PURE__ */
|
|
98
|
-
/* @__PURE__ */
|
|
51
|
+
/* @__PURE__ */ e("p", { className: "n-search-footer-tip", children: [
|
|
52
|
+
/* @__PURE__ */ e(d, { keyNames: ["Tab"] }),
|
|
53
|
+
/* @__PURE__ */ e("span", { children: "or" }),
|
|
54
|
+
/* @__PURE__ */ e(d, { keyNames: ["↑", "↓"] }),
|
|
99
55
|
"to navigate"
|
|
100
56
|
] })
|
|
101
57
|
] })
|
|
102
58
|
] }) });
|
|
103
59
|
}
|
|
104
60
|
export {
|
|
105
|
-
|
|
61
|
+
j as default
|
|
106
62
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { A as u, y as
|
|
2
|
-
import { getSiteIcon as
|
|
3
|
-
function
|
|
1
|
+
import { A as u, y as w, d as T } from "../../../../chunks/hooks.module.BFfOesdf.js";
|
|
2
|
+
import { getSiteIcon as L } from "../utils/index.js";
|
|
3
|
+
function b(s, r) {
|
|
4
4
|
const t = u(null), c = u("");
|
|
5
|
-
return
|
|
5
|
+
return w(() => () => {
|
|
6
6
|
t.current && clearTimeout(t.current);
|
|
7
7
|
}, []), { reset: () => {
|
|
8
8
|
t.current && clearTimeout(t.current);
|
|
@@ -13,12 +13,12 @@ function T(s, r) {
|
|
|
13
13
|
);
|
|
14
14
|
} };
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
const [s, r] =
|
|
16
|
+
function _() {
|
|
17
|
+
const [s, r] = T({
|
|
18
18
|
searchTerm: "",
|
|
19
19
|
results: [],
|
|
20
20
|
isLoading: !1
|
|
21
|
-
}), t = u(/* @__PURE__ */ new Map()), { reset: c, run: l } =
|
|
21
|
+
}), t = u(/* @__PURE__ */ new Map()), { reset: c, run: l } = b((e) => {
|
|
22
22
|
(e.length > 2 || e.length === 0) && o(e);
|
|
23
23
|
}, 150), o = async (e) => {
|
|
24
24
|
if (!(window != null && window.pagefind)) return;
|
|
@@ -30,22 +30,22 @@ function x() {
|
|
|
30
30
|
}));
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
const i = await window.pagefind.debouncedSearch(e),
|
|
33
|
+
const i = await window.pagefind.debouncedSearch(e), p = await Promise.all(
|
|
34
34
|
i.results.slice(0, 15).map(async (n) => {
|
|
35
35
|
var m, f, d;
|
|
36
|
-
const a = await n.data();
|
|
36
|
+
const a = await n.data(), g = (S) => S.replace("#", "");
|
|
37
37
|
return {
|
|
38
|
-
icon:
|
|
38
|
+
icon: L((m = a.meta) == null ? void 0 : m.content_type),
|
|
39
39
|
content_type: (f = a.meta) == null ? void 0 : f.content_type,
|
|
40
40
|
label: (d = a.meta) == null ? void 0 : d.title,
|
|
41
41
|
url: a.url,
|
|
42
|
-
excerpt: a.excerpt
|
|
42
|
+
excerpt: g(a.excerpt)
|
|
43
43
|
};
|
|
44
44
|
})
|
|
45
45
|
);
|
|
46
46
|
r((n) => ({
|
|
47
47
|
...n,
|
|
48
|
-
results:
|
|
48
|
+
results: p,
|
|
49
49
|
isLoading: !1
|
|
50
50
|
}));
|
|
51
51
|
};
|
|
@@ -60,5 +60,5 @@ function x() {
|
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
export {
|
|
63
|
-
|
|
63
|
+
_ as useSearch
|
|
64
64
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/spark-ui",
|
|
3
3
|
"description": "Assets, design tokens, components, and utilities",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.35",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/components/preact/index.js",
|
|
7
7
|
"types": "dist/components/preact/index.d.ts",
|
|
@@ -32,7 +32,6 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@preact/preset-vite": "^2.10.1",
|
|
35
|
-
"classnames": "^2.5.1",
|
|
36
35
|
"glob": "^11.0.1",
|
|
37
36
|
"preact": "^10.26.4",
|
|
38
37
|
"vite": "^6.2.5",
|
|
@@ -54,8 +53,7 @@
|
|
|
54
53
|
"eslint-config-prettier": "^10.1.1",
|
|
55
54
|
"eslint-plugin-astro": "^1.3.1",
|
|
56
55
|
"preact": "^10.26.4",
|
|
57
|
-
"classnames": "^2.5.1",
|
|
58
56
|
"prettier": "^3.5.3",
|
|
59
57
|
"prettier-plugin-astro": "^0.14.1"
|
|
60
58
|
}
|
|
61
|
-
}
|
|
59
|
+
}
|
|
@@ -7,14 +7,14 @@ interface Props {
|
|
|
7
7
|
const { id, class: className, ...rest } = Astro.props;
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
<
|
|
10
|
+
<n-tabs id={id} class={className} {...rest}>
|
|
11
11
|
<slot />
|
|
12
|
-
</
|
|
12
|
+
</n-tabs>
|
|
13
13
|
|
|
14
14
|
<script>
|
|
15
15
|
/**
|
|
16
16
|
* Slightly altered version of another tabs component
|
|
17
|
-
* Adds "tabs-change" event that
|
|
17
|
+
* Adds "tabs-change" event that returns selected tab info
|
|
18
18
|
* {@link https://www.mayank.co/blog/tabs}
|
|
19
19
|
*/
|
|
20
20
|
class Tabs extends HTMLElement {
|
|
@@ -102,5 +102,5 @@ const { id, class: className, ...rest } = Astro.props;
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
customElements.define('
|
|
105
|
+
customElements.define('n-tabs', Tabs);
|
|
106
106
|
</script>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type ComponentChildren } from 'preact';
|
|
2
2
|
import { useState, useEffect, useRef } from 'preact/hooks';
|
|
3
|
-
import cn from "classnames"
|
|
4
3
|
|
|
5
4
|
import Modal from '../../../../preact/Modal/Modal';
|
|
6
5
|
import KeyboardKey from '../../../../preact/KeyboardKey/KeyboardKey';
|
|
@@ -66,7 +65,7 @@ function SearchModal(props: Props = {className: '', children: null}) {
|
|
|
66
65
|
}, [searchOpen]);
|
|
67
66
|
|
|
68
67
|
return (
|
|
69
|
-
<Modal ref={modalRef} className={
|
|
68
|
+
<Modal ref={modalRef} className={`n-search-modal ${className ? className : ''}`} {...rest}>
|
|
70
69
|
<div ref={containerRef} className="n-search-container">
|
|
71
70
|
<SearchInput setSearchTerm={actions.setSearchTerm} initialValue={state.searchTerm} />
|
|
72
71
|
|
|
@@ -44,12 +44,14 @@ export function useSearch() {
|
|
|
44
44
|
const results = await Promise.all(
|
|
45
45
|
search.results.slice(0, 15).map(async (result: any) => {
|
|
46
46
|
const data = await result.data();
|
|
47
|
+
const removeAnchorLink = (text: string) => text.replace("#", '')
|
|
48
|
+
|
|
47
49
|
return {
|
|
48
50
|
icon: getSiteIcon(data.meta?.content_type),
|
|
49
51
|
content_type: data.meta?.content_type,
|
|
50
52
|
label: data.meta?.title,
|
|
51
53
|
url: data.url,
|
|
52
|
-
excerpt: data.excerpt,
|
|
54
|
+
excerpt: removeAnchorLink(data.excerpt),
|
|
53
55
|
};
|
|
54
56
|
})
|
|
55
57
|
);
|
|
@@ -16,20 +16,25 @@ button,
|
|
|
16
16
|
border: 1px solid var(--color-border);
|
|
17
17
|
border-radius: var(--radius-m);
|
|
18
18
|
|
|
19
|
-
/* Button press */
|
|
20
|
-
&:active:not(:disabled) {
|
|
21
|
-
top: 1px;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
19
|
/* Button icons */
|
|
25
20
|
svg {
|
|
26
21
|
flex: none;
|
|
27
22
|
height: var(--button-icon-size, 1.2cap);
|
|
28
23
|
width: auto;
|
|
29
24
|
}
|
|
30
|
-
}
|
|
31
25
|
|
|
32
|
-
|
|
26
|
+
/* Button states */
|
|
27
|
+
&:active:not(:disabled) {
|
|
28
|
+
top: 1px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&:disabled {
|
|
32
|
+
color: var(--color-disabled-bg);
|
|
33
|
+
background-color: var(--color-disabled-bg);
|
|
34
|
+
border-color: var(--color-disabled-bg);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* Button variants */
|
|
33
38
|
&[data-button-variant='primary'] {
|
|
34
39
|
color: var(--color-text-inverse);
|
|
35
40
|
background-color: var(--color-brand);
|
|
@@ -40,4 +45,16 @@ button,
|
|
|
40
45
|
background-color: var(--color-brand-alt);
|
|
41
46
|
border-color: var(--color-brand-alt);
|
|
42
47
|
}
|
|
48
|
+
|
|
49
|
+
&[data-button-variant='text'] {
|
|
50
|
+
color: currentColor;
|
|
51
|
+
background-color: transparent;
|
|
52
|
+
border-color: transparent;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&[data-button-variant='ghost'] {
|
|
56
|
+
color: currentColor;
|
|
57
|
+
background-color: transparent;
|
|
58
|
+
border-color: currentColor;
|
|
59
|
+
}
|
|
43
60
|
}
|
package/packages/styles/tabs.css
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
|
-
[role='tablist'] {
|
|
1
|
+
.tabs [role='tablist'] {
|
|
2
2
|
display: flex;
|
|
3
|
-
|
|
3
|
+
isolation: isolate;
|
|
4
|
+
border: var(--_border);
|
|
4
5
|
}
|
|
5
6
|
|
|
6
|
-
[role='tab'] {
|
|
7
|
-
|
|
7
|
+
.tabs [role='tab'] {
|
|
8
|
+
position: relative;
|
|
9
|
+
border-color: transparent;
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
/* Remove button push/click style */
|
|
12
|
+
&:active:not(:disabled) {
|
|
13
|
+
top: unset;
|
|
11
14
|
}
|
|
12
15
|
}
|
|
13
16
|
|
|
14
|
-
[role='
|
|
15
|
-
|
|
17
|
+
.tabs [role='tab'][aria-selected='true'] {
|
|
18
|
+
/* Bring selected tab to layer above others to avoid clipping outline styles */
|
|
19
|
+
z-index: 1;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.tabs [role='tabpanel'] {
|
|
23
|
+
border: var(--_border);
|
|
24
|
+
border-block-start: unset;
|
|
25
|
+
padding: var(--_padding);
|
|
16
26
|
}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
--color-bg-1: var(--neutral-000);
|
|
17
17
|
--color-bg-2: var(--neutral-100);
|
|
18
18
|
--color-bg-3: var(--neutral-200);
|
|
19
|
+
--color-border: var(--neutral-200);
|
|
19
20
|
--color-brand: var(--blue-700);
|
|
20
21
|
--color-disabled-bg: var(--neutral-200);
|
|
21
22
|
--color-disabled-border: var(--neutral-400);
|
|
@@ -146,6 +147,7 @@
|
|
|
146
147
|
--color-bg-1: var(--neutral-000);
|
|
147
148
|
--color-bg-2: var(--neutral-100);
|
|
148
149
|
--color-bg-3: var(--neutral-200);
|
|
150
|
+
--color-border: var(--neutral-200);
|
|
149
151
|
--color-brand: var(--blue-700);
|
|
150
152
|
--color-disabled-bg: var(--neutral-200);
|
|
151
153
|
--color-disabled-border: var(--neutral-400);
|
|
@@ -180,6 +182,7 @@
|
|
|
180
182
|
--color-bg-1: var(--neutral-000);
|
|
181
183
|
--color-bg-2: var(--neutral-100);
|
|
182
184
|
--color-bg-3: var(--neutral-200);
|
|
185
|
+
--color-border: var(--neutral-200);
|
|
183
186
|
--color-brand: var(--blue-700);
|
|
184
187
|
--color-disabled-bg: var(--neutral-200);
|
|
185
188
|
--color-disabled-border: var(--neutral-400);
|
|
@@ -214,6 +217,7 @@
|
|
|
214
217
|
--color-bg-1: var(--neutral-800);
|
|
215
218
|
--color-bg-2: var(--neutral-700);
|
|
216
219
|
--color-bg-3: var(--neutral-600);
|
|
220
|
+
--color-border: var(--neutral-200);
|
|
217
221
|
--color-brand: var(--teal-200);
|
|
218
222
|
--color-disabled-bg: var(--neutral-600);
|
|
219
223
|
--color-disabled-border: var(--neutral-400);
|
|
@@ -248,6 +252,7 @@
|
|
|
248
252
|
--color-bg-1: var(--neutral-800);
|
|
249
253
|
--color-bg-2: var(--neutral-700);
|
|
250
254
|
--color-bg-3: var(--neutral-600);
|
|
255
|
+
--color-border: var(--neutral-200);
|
|
251
256
|
--color-brand: var(--teal-200);
|
|
252
257
|
--color-disabled-bg: var(--neutral-600);
|
|
253
258
|
--color-disabled-border: var(--neutral-400);
|