diff --git a/packages/website/astro.config.mjs b/packages/website/astro.config.mjs
index ff46701..d41bc21 100644
--- a/packages/website/astro.config.mjs
+++ b/packages/website/astro.config.mjs
@@ -87,6 +87,10 @@ export default defineConfig({
})
],
vite: {
+ server: {
+ port: 3000,
+ hmr: { port: 3001 }
+ },
worker: { format: "es" },
ssr: { external: ["svgo"] },
plugins: [
diff --git a/packages/website/src/components/MainSection/SearchSection/SearchContainer.tsx b/packages/website/src/components/MainSection/SearchSection/SearchContainer.tsx
index 68ee189..6c1ab43 100644
--- a/packages/website/src/components/MainSection/SearchSection/SearchContainer.tsx
+++ b/packages/website/src/components/MainSection/SearchSection/SearchContainer.tsx
@@ -1,11 +1,10 @@
import { ComponentProps, onCleanup, onMount } from "solid-js";
import { createSignal } from "solid-js";
-import SearchInput from "./SearchInput";
+import SearchInput, { setQuery, getQuery } from "./SearchInput";
import SearchResults from "./SearchResults";
export function SearchContainer(props?: ComponentProps<'div'>) {
- const [getQuery, setQuery] = createSignal("");
const [open, setOpen] = createSignal(false);
let ref: HTMLDivElement & { open?: boolean } = null;
@@ -27,7 +26,7 @@ export function SearchContainer(props?: ComponentProps<'div'>) {
if (ref.contains(target)) {
if (!ref?.open) {
ref.open = true;
- setOpen(ref.open);
+ setOpen(ref.open);
ref.style.pointerEvents = "auto";
}
}
@@ -54,13 +53,14 @@ export function SearchContainer(props?: ComponentProps<'div'>) {
-
diff --git a/packages/website/src/components/MainSection/SearchSection/SearchInput.tsx b/packages/website/src/components/MainSection/SearchSection/SearchInput.tsx
index 27e15dd..5df2a90 100644
--- a/packages/website/src/components/MainSection/SearchSection/SearchInput.tsx
+++ b/packages/website/src/components/MainSection/SearchSection/SearchInput.tsx
@@ -1,26 +1,28 @@
+
+import type { ComponentProps, Setter } from "solid-js";
+import { createSignal, onCleanup, onMount } from "solid-js";
+
+import { ToolTip, SingletonToolTip } from "../../../hooks/tooltip";
import Button from "../../Button";
+
import IconSearch from "~icons/fluent/search-24-filled";
import IconClear from "~icons/fluent/dismiss-24-filled";
-import { ComponentProps, onCleanup, onMount, Setter } from "solid-js";
import { debounce } from "@bundlejs/core/src/util";
-import { ToolTip, SingletonToolTip } from "../../../hooks/tooltip";
-
-export function SearchInput(props: ComponentProps<'div'> & {
- query?: Setter;
-}) {
+export const [getQuery, setQuery] = createSignal("");
+export function SearchInput() {
let ref: HTMLInputElement;
function onClear() {
ref.value = "";
- props?.query?.("");
+ setQuery("");
}
const onKeyUp = debounce((e?: KeyboardEvent) => {
e?.stopPropagation?.();
let { value } = ref;
- props?.query?.(value);
+ setQuery(value);
}, 250);
return (
diff --git a/packages/website/src/components/MainSection/SearchSection/SearchResults.tsx b/packages/website/src/components/MainSection/SearchSection/SearchResults.tsx
index 6575a00..e71c363 100644
--- a/packages/website/src/components/MainSection/SearchSection/SearchResults.tsx
+++ b/packages/website/src/components/MainSection/SearchSection/SearchResults.tsx
@@ -2,20 +2,20 @@ import type { ComponentProps, Accessor } from "solid-js";
import type { SearchResultProps } from "./Result";
import { For, createResource, onMount, createEffect, on, onCleanup } from "solid-js";
+
+import { setQuery, getQuery } from "./SearchInput";
import { SearchResult, ErrorResult } from "./Result";
-import { getPackages } from "@bundlejs/core/src/util";
import { rovingIndex } from '../../../hooks/roving-index';
+import { getPackages } from "@bundlejs/core/src/util";
-export function SearchResults(props?: ComponentProps<'dialog'> & {
- query?: Accessor;
-}) {
+export function SearchResults(props?: ComponentProps<'dialog'>) {
let searchContainerEl: HTMLDivElement = null;
let ref: HTMLDivElement = null;
let heightRef: HTMLDivElement = null;
- const [data] = createResource(props?.query, async (source) => {
+ const [data] = createResource(getQuery, async (source) => {
if (ref) {
let anim = heightRef.animate({
opacity: "0"
diff --git a/packages/website/src/hooks/tooltip.tsx b/packages/website/src/hooks/tooltip.tsx
index 2698b5a..7116696 100644
--- a/packages/website/src/hooks/tooltip.tsx
+++ b/packages/website/src/hooks/tooltip.tsx
@@ -40,17 +40,18 @@ export function ToolTip(props?: ComponentProps & { mobile?: string, as?: ke
let [newProps, attrs] = splitProps(props, ["content", "allowHTML", "tooltip", "as"]);
let mergedProps = mergeProps({
as: "span",
+ mobile: "(max-width: 640px)"
}, newProps);
- // mobile: "(max-width: 640px)"
+ //
const title = mergedProps?.allowHTML ? "Tooltip" : newProps?.content?.toString();
- let media = ("document" in globalThis) && globalThis?.matchMedia(mergedProps?.mobile);
+ // let media = ("document" in globalThis) && globalThis?.matchMedia(mergedProps?.mobile);
function mediaQueryRun(e?: MediaQueryListEvent) {
- if (e?.matches)
+ // if (e?.matches)
instances?.forEach(instance => instance?.enable?.());
- else
- instances?.forEach(instance => instance?.disable?.());
+ // else
+ // instances?.forEach(instance => instance?.disable?.());
}
let tippyProps = mergeProps({
@@ -62,13 +63,14 @@ export function ToolTip(props?: ComponentProps & { mobile?: string, as?: ke
onMount(() => {
const children = Array.isArray(attrs.children) ? attrs.children : [attrs.children];
+ console.log({ children })
instances = tippy(children as HTMLElement[], tippyProps);
instances?.forEach(instance => instance?.enable?.());
- if (props.mobile) {
- mediaQueryRun(media as unknown as MediaQueryListEvent);
- media?.addEventListener?.("change", mediaQueryRun);
- }
+ // if (props.mobile) {
+ // mediaQueryRun(media as unknown as MediaQueryListEvent);
+ // media?.addEventListener?.("change", mediaQueryRun);
+ // }
});
createEffect(() => {
@@ -83,8 +85,8 @@ export function ToolTip(props?: ComponentProps & { mobile?: string, as?: ke
})
onCleanup(() => {
- if (props.mobile)
- media?.removeEventListener?.("change", mediaQueryRun);
+ // if (props.mobile)
+ // media?.removeEventListener?.("change", mediaQueryRun);
instances?.forEach(instance => instance?.destroy?.());
});