diff --git a/src/components/channel.tsx b/src/components/channel.tsx
index 6f6bc7a..646fdf0 100644
--- a/src/components/channel.tsx
+++ b/src/components/channel.tsx
@@ -16,7 +16,7 @@ export function ChannelComponent({
navigate(channel.url || "");
}}
shadow="none"
- className="md:col-span-2 xl:col-span-3 2xl:col-span-4 gap-2 p-1 md:p-4"
+ className="md:col-span-2 xl:col-span-4 2xl:col-span-5 gap-2 p-1 md:p-4"
>
@@ -27,18 +27,17 @@ export function ChannelComponent({
{channel.verified && }
-
- {channel.description || "No description"}
-
- {(channel.videos || -1) >= 0 && (
-
+
+
+ {channel.description || "No description"}
+ {(channel.videos || -1) >= 0 && (
{`${shortenNumber(channel.videos || -1)} videos`}
-
- )}
+ )}
+
);
}
diff --git a/src/components/item.tsx b/src/components/item.tsx
index f0ba042..914d6db 100644
--- a/src/components/item.tsx
+++ b/src/components/item.tsx
@@ -14,10 +14,7 @@ export function ItemComponent({ item, channel }: ItemComponentProps) {
);
} else if (item.type === "channel") {
item = item as Channel;
- return [
- ,
-
,
- ];
+ return ;
} else {
Idk how to render this
diff --git a/src/components/navbar.tsx b/src/components/navbar.tsx
index 37453ab..2a47f86 100644
--- a/src/components/navbar.tsx
+++ b/src/components/navbar.tsx
@@ -8,14 +8,20 @@ import {
NavbarMenu,
NavbarMenuItem,
Input,
+ Button,
} from "@nextui-org/react";
import { useState } from "react";
import { Link, useNavigate, useSearchParams } from "react-router-dom";
export function NavbarComponent() {
- const [search, setSearch] = useState("");
+ const [search, setSearch] = useState(undefined as string | undefined);
const navigate = useNavigate();
const [searchParams] = useSearchParams();
+ const [suggestions, setSuggestions] = useState([] as string[]);
+ async function updateSuggestions(query) {
+ const res = await window.piped_api.suggestions(query);
+ setSuggestions(res);
+ }
return (
@@ -30,19 +36,49 @@ export function NavbarComponent() {
- }
- onChange={(e) => setSearch(e.target.value)}
- onKeyDown={(e) => {
- if (e.key === "Enter") {
- navigate(`/search?q=${search}`);
+
+
}
+ onChange={(e) => {
+ updateSuggestions(e.target.value);
+ setSearch(e.target.value);
+ }}
+ onKeyDown={async (e) => {
+ if (e.key === "Enter") {
+ await setSuggestions([]);
+ await navigate(`/search?q=${search}`);
+ }
+ }}
+ onClear={() => {
+ setSuggestions([]);
+ setSearch("");
+ }}
+ value={
+ (search !== undefined ? search : searchParams.get("q")) || ""
}
- }}
- defaultValue={searchParams.get("q") || ""}
- />
+ />
+
+ {suggestions.length > 0 &&
+ suggestions.map((suggestion) => (
+
+ ))}
+
+