diff --git a/src/App.tsx b/src/App.tsx --- a/src/App.tsx +++ b/src/App.tsx @@ -2,6 +2,7 @@ import ServiceGrid from "./components/ServiceGrid"; import { HackerNews } from "./components/HackerNews"; import { Weather } from "./components/Weather"; +import { SearchBar } from "./components/SearchBar.tsx"; import { apps } from "./data/apps"; import { privateApps } from "./data/privateApps"; import { websites } from "./data/websites"; @@ -9,6 +10,10 @@ export function App() { return ( +
+ +
+
{" "} diff --git a/src/Layout.tsx b/src/Layout.tsx --- a/src/Layout.tsx +++ b/src/Layout.tsx @@ -2,7 +2,7 @@ export default function Layout({ children }: { children: React.ReactNode }) { return ( -
+
{/*

cute.haus

*/} diff --git a/src/components/HackerNews.tsx b/src/components/HackerNews.tsx --- a/src/components/HackerNews.tsx +++ b/src/components/HackerNews.tsx @@ -1,14 +1,5 @@ import { useState, useEffect } from "react"; -function timeAgo(timestamp: number): string { - const seconds = Math.floor(Date.now() / 1000 - timestamp); - - if (seconds < 60) return "1m"; - if (seconds < 3600) return `${Math.floor(seconds / 60)}m`; - if (seconds < 86400) return `${Math.floor(seconds / 3600)}h`; - return `${Math.floor(seconds / 86400)}d`; -} - export function HackerNews() { const [stories, setStories] = useState([]); diff --git a/src/components/SearchBar.tsx b/src/components/SearchBar.tsx new file mode 100644 --- /dev/null +++ b/src/components/SearchBar.tsx @@ -0,0 +1,49 @@ +import { useState } from "react"; + +const engines = [ + { name: "Google", url: "https://www.google.com/search?q=" }, + { name: "DuckDuckGo", url: "https://duckduckgo.com/?q=" }, + { name: "Kagi", url: "https://kagi.com/search?q=" }, +]; + +export function SearchBar() { + const [query, setQuery] = useState(""); + const [engine, setEngine] = useState( + engines.find((e) => e.name === "DuckDuckGo")!, + ); + + return ( +
{ + e.preventDefault(); + if (query.trim()) { + window.location.href = engine.url + encodeURIComponent(query); + } + }} + > +
+ + setQuery(e.target.value)} + placeholder="Search..." + className="flex-1 px-3 py-2 bg-zinc-900 border border-zinc-600 rounded text-white placeholder-zinc-500 focus:outline-none focus:border-zinc-500" + /> +
+
+ ); +}