diff --git a/build.sh b/build.sh index 7a8710b..8c3b9e1 100755 --- a/build.sh +++ b/build.sh @@ -1,7 +1,13 @@ #!/bin/sh +# Exit on error +set -e + # This is kind of like a shim that makes sure the frontend is rebuilt when running a build. For example you can run `./build.sh cargo build --release` +# Remove old files +rm -rf src/static + # Frontend cd web/ diff --git a/web/bun.lockb b/web/bun.lockb index 998f07f..36929c2 100755 Binary files a/web/bun.lockb and b/web/bun.lockb differ diff --git a/web/src/App.tsx b/web/src/App.tsx index c9ded3b..e43ca65 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -7,9 +7,11 @@ import Loading from "./components/Loading"; import { Data } from "./types"; import { theme } from "./theme"; import RefreshButton from "./components/RefreshButton"; +import Search from "./components/Search"; function App() { const [data, setData] = useState(null); + const [searchQuery, setSearchQuery] = useState(""); if (!data) return ; return (
+
    - {Object.entries(data.images).map(([name, status]) => ( + {Object.entries(data.images).filter(([name]) => name.includes(searchQuery)).map(([name, status]) => ( ))}
diff --git a/web/src/components/Search.tsx b/web/src/components/Search.tsx new file mode 100644 index 0000000..28e7a95 --- /dev/null +++ b/web/src/components/Search.tsx @@ -0,0 +1,51 @@ +import { ChangeEvent, useState } from "react"; +import { theme } from "../theme"; +import { IconSearch, IconX } from "@tabler/icons-react"; + +export default function Search({ + onChange, +}: { + onChange: (value: string) => void; +}) { + const [searchQuery, setSearchQuery] = useState(""); + const [showClear, setShowClear] = useState(false); + const handleChange = (event: ChangeEvent) => { + const value = (event.target as HTMLInputElement).value; + setSearchQuery(value); + onChange(value); + if (value !== "") { + setShowClear(true); + } else setShowClear(false); + }; + const handleClear = () => { + setShowClear(false); + setSearchQuery(""); + onChange(""); + }; + return ( +
+
+ +
+ +
+ {showClear && ( + + )} +
+
+
+ ); +} diff --git a/web/tailwind.config.js b/web/tailwind.config.js index eefd6bd..8d292ac 100644 --- a/web/tailwind.config.js +++ b/web/tailwind.config.js @@ -24,10 +24,11 @@ export default { }, { pattern: /text-(gray|neutral)-400/, + variants: ["hover"] }, { pattern: /text-(gray|neutral)-500/, - variants: ["dark"], + variants: ["dark", "placeholder"], }, { pattern: /divide-(gray|neutral)-800/, @@ -37,7 +38,7 @@ export default { pattern: /border-(gray|neutral)-200/, }, { - pattern: /border-(gray|neutral)-800/, + pattern: /border-(gray|neutral)-700/, variants: ["dark"], }, ],