feat(tests): add fresh-testing-library tests (#1990)
This commit is contained in:
@@ -8,6 +8,7 @@ import VersionSelect from "../islands/VersionSelect.tsx";
|
||||
import { type VersionLink } from "../routes/docs/[...slug].tsx";
|
||||
import { Logo } from "$fresh/www/components/Header.tsx";
|
||||
import DocsTitle from "$fresh/www/components/DocsTitle.tsx";
|
||||
import docsearch from "https://esm.sh/@docsearch/js@3?target=es2020";
|
||||
|
||||
export default function DocsSidebar(
|
||||
props: {
|
||||
@@ -27,7 +28,7 @@ export default function DocsSidebar(
|
||||
</div>
|
||||
<hr />
|
||||
</div>
|
||||
<SearchButton class="mr-4 sm:mr-0" />
|
||||
<SearchButton class="mr-4 sm:mr-0" docsearch={docsearch} />
|
||||
<div class="mb-4">
|
||||
<VersionSelect
|
||||
selectedVersion={props.selectedVersion}
|
||||
|
||||
+3
-1
@@ -15,7 +15,9 @@
|
||||
"@preact/signals-core": "https://esm.sh/@preact/signals-core@1.2.3",
|
||||
"$std/": "https://deno.land/std@0.205.0/",
|
||||
"$ga4": "https://raw.githubusercontent.com/denoland/ga4/main/mod.ts",
|
||||
"$marked-mangle": "https://esm.sh/marked-mangle@1.0.1"
|
||||
"$marked-mangle": "https://esm.sh/marked-mangle@1.0.1",
|
||||
"$fresh-testing-library": "https://deno.land/x/fresh_testing_library@0.8.0/mod.ts",
|
||||
"$fresh-testing-library/": "https://deno.land/x/fresh_testing_library@0.8.0/"
|
||||
},
|
||||
"compilerOptions": {
|
||||
"jsx": "react-jsx",
|
||||
|
||||
@@ -1,12 +1,21 @@
|
||||
import { Head } from "$fresh/runtime.ts";
|
||||
import { useEffect, useRef } from "preact/hooks";
|
||||
import docsearch from "https://esm.sh/@docsearch/js@3?target=es2020";
|
||||
|
||||
export default function SearchButton(props: { class?: string }) {
|
||||
// Copied from algolia source code
|
||||
type DocSearchProps = {
|
||||
appId: string;
|
||||
apiKey: string;
|
||||
indexName: string;
|
||||
container: HTMLElement | string;
|
||||
};
|
||||
|
||||
export default function SearchButton(
|
||||
props: { docsearch: (args: DocSearchProps) => void; class?: string },
|
||||
) {
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
useEffect(() => {
|
||||
if (ref.current) {
|
||||
docsearch({
|
||||
props.docsearch({
|
||||
appId: "CWUS37S0PK",
|
||||
apiKey: "caa591b6dcb2c9308551361d954a728b",
|
||||
indexName: "fresh",
|
||||
@@ -22,7 +31,12 @@ export default function SearchButton(props: { class?: string }) {
|
||||
href="/docsearch.css"
|
||||
/>
|
||||
</Head>
|
||||
<div class={"h-9 mb-6 " + (props.class ?? "")} ref={ref}></div>
|
||||
<div
|
||||
title="Search Button"
|
||||
class={"h-9 mb-6 " + (props.class ?? "")}
|
||||
ref={ref}
|
||||
>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user