Skip to content

web search done right

Add mobile menu and more responsive tweaks

Oliver Bøving9012236ce622
diff --git a/frontend/src/components/Entity.astro b/frontend/src/components/Entity.astro
index 41b7a95b..d2cc620d 100644
--- a/frontend/src/components/Entity.astro
+++ b/frontend/src/components/Entity.astro
@@ -25,7 +25,7 @@ export interface Props {
}
<div class="text-xl mb-2">
<a href="https://en.wikipedia.org/wiki/{{ entity.title }}"
- >{askama`entity.title $ {{name.findName}}`}
+ >{askama`entity.title $ {{name.fullName}}`}
</a>
</div>
<div class="text-sm">
@@ -75,7 +75,7 @@ export interface Props {
<div class="text-center">
<a href="/search?q={{ entity.title|urlencode }}">
- {askama`entity.title $ {{name.findName}}`}
+ {askama`entity.title $ {{name.fullName}}`}
</a>
</div>
</div>
diff --git a/frontend/src/components/Header.astro b/frontend/src/components/Header.astro
index b831bb53..00d8002a 100644
--- a/frontend/src/components/Header.astro
+++ b/frontend/src/components/Header.astro
@@ -10,10 +10,12 @@ export interface Props {
const { icon = true, searchbar } = Astro.props;
---
-<div class="flex items-center h-24 shrink-0">
+<div
+ class="grid items-center h-24 grid-cols-[auto_1fr_auto] sm:grid-cols-[3.5rem_1fr_auto] gap-4 p-4 lg:gap-8 lg:px-8"
+>
{
icon && (
- <div class="ml-14 mr-14 h-12 w-12">
+ <div class="col-start-1">
<a href="/">
<img src="/assets/images/logo.svg" class="h-full w-full" />
</a>
@@ -22,10 +24,14 @@ const { icon = true, searchbar } = Astro.props;
}
{
searchbar && (
- <Searchbar
- query={typeof searchbar == "object" ? searchbar.query : void 0}
- />
+ <div class="col-start-2 w-full max-w-xl">
+ <Searchbar
+ query={typeof searchbar == "object" ? searchbar.query : void 0}
+ />
+ </div>
)
}
- <Navbar />
+ <div class="col-start-3">
+ <Navbar />
+ </div>
</div>
diff --git a/frontend/src/components/Navbar.astro b/frontend/src/components/Navbar.astro
index 4a48f625..e5c75fdf 100644
--- a/frontend/src/components/Navbar.astro
+++ b/frontend/src/components/Navbar.astro
@@ -1,22 +1,79 @@
---
+import Hero from "./Hero.astro";
import { Icon } from "astro-icon";
+
+const links = [
+ { url: "/goggles", title: "Goggles" },
+ { url: "/about", title: "About" },
+];
+const icons = [
+ {
+ url: "https://discord.gg/BmzKHffWJM",
+ title: "Discord",
+ icon: "simple-icons:discord",
+ },
+ {
+ url: "https://github.com/cuely/cuely",
+ title: "GitHub",
+ icon: "simple-icons:github",
+ },
+];
---
-<navbar class="flex-grow flex justify-end items-center pr-10 space-x-10">
- <a href="/goggles">Goggles</a>
- <a href="/about">About</a>
- <a href="https://discord.gg/BmzKHffWJM">
- <Icon
- title="Discord"
- class="w-6 text-gray-500 hover:text-gray-900 transition"
- name="simple-icons:discord"
- />
- </a>
- <a href="https://github.com/cuely/cuely">
- <Icon
- title="GitHub"
- class="w-6 text-gray-500 hover:text-gray-900 transition"
- name="simple-icons:github"
- />
- </a>
+<navbar class="hidden sm:flex items-center space-x-2 md:space-x-4 lg:space-x-8">
+ {
+ links.map((l) => (
+ <a class="link rounded-full px-2 py-1" href={l.url}>
+ {l.title}
+ </a>
+ ))
+ }
+ {
+ icons.map((i) => (
+ <a class="icon" href={i.url}>
+ <Icon class="w-6" title={i.title} name={i.icon} />
+ </a>
+ ))
+ }
</navbar>
+
+<nav class="sm:hidden items-center flex group relative text-lg">
+ <button
+ class="px-3 mx-1 text-gray-400 bg-transparent rounded-full transition aspect-square group-hover:text-brand/30"
+ >
+ <Hero class="w-6" icon="menu" />
+ </button>
+ <div
+ class="absolute z-50 opacity-0 bottom-0 pt-1 right-0 translate-y-full pointer-events-none group-hover:pointer-events-auto group-hover:flex group-hover:opacity-100 flex-col transition"
+ >
+ <div class="p-2 bg-white shadow-xl rounded-xl border">
+ <div class="pb-2 flex flex-col space-y-1">
+ {
+ links.map((l) => (
+ <a class="link rounded py-1 pl-2 pr-10" href={l.url}>
+ {l.title}
+ </a>
+ ))
+ }
+ </div>
+ <div class="flex border-t pt-2 justify-around">
+ {
+ icons.map((i) => (
+ <a class="icon" href={i.url}>
+ <Icon class="w-7" title={i.title} name={i.icon} />
+ </a>
+ ))
+ }
+ </div>
+ </div>
+ </div>
+</nav>
+
+<style>
+ .link {
+ @apply transition hover:bg-brand/5 hover:text-brand hover:no-underline;
+ }
+ .icon {
+ @apply flex justify-center rounded-full p-2 text-gray-500 transition hover:bg-brand/10 hover:text-brand;
+ }
+</style>
diff --git a/frontend/src/components/Searchbar.astro b/frontend/src/components/Searchbar.astro
index fde6c8ad..dd5b32dd 100644
--- a/frontend/src/components/Searchbar.astro
+++ b/frontend/src/components/Searchbar.astro
@@ -27,7 +27,7 @@ const { autofocus, query } = Astro.props;
</style>
<form
- class="w-full md:max-w-2xl relative"
+ class="w-full relative"
id="searchbar-form"
method="GET"
action="/search"
diff --git a/frontend/src/layouts/Layout.astro b/frontend/src/layouts/Layout.astro
index f573da24..b06f90fe 100644
--- a/frontend/src/layouts/Layout.astro
+++ b/frontend/src/layouts/Layout.astro
@@ -13,7 +13,7 @@ const { title } = Astro.props;
<html lang="en">
<head>
<meta charset="UTF-8" />
- <meta name="viewport" content="width=device-width" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- <link rel="icon" type="image/svg+xml" href="/favicon.svg" /> -->
<link rel="icon" type="image/x-icon" href="/assets/favicon.ico" />
<title>{title}</title>
diff --git a/frontend/src/pages/index.astro b/frontend/src/pages/index.astro
index 607e1134..9ff0cf74 100644
--- a/frontend/src/pages/index.astro
+++ b/frontend/src/pages/index.astro
@@ -8,17 +8,19 @@ import Layout from "../layouts/Layout.astro";
<Layout title="Cuely">
<div class="grid grid-rows-[auto_1fr_auto] h-full relative">
<Header icon={false} />
- <div
- class="flex flex-col justify-center items-center absolute top-1/4 w-full"
- >
- <div class="flex">
- <h1 class="text-5xl uppercase mb-1 text-brand">cuely</h1>
- <span class="text-gray-500">BETA</span>
- </div>
+ <div class="absolute top-1/4 w-full grid place-items-center">
+ <div
+ class="flex flex-col justify-center items-center w-full px-2 md:px-0 md:max-w-2xl"
+ >
+ <div class="flex">
+ <h1 class="text-5xl uppercase mb-1 text-brand">cuely</h1>
+ <span class="text-gray-500">BETA</span>
+ </div>
- <h2 class="mb-8 text-gray-500">Completely Open Search Engine</h2>
+ <h2 class="mb-8 text-gray-500">Completely Open Search Engine</h2>
- <Searchbar autofocus />
+ <Searchbar autofocus />
+ </div>
</div>
<div class="row-start-3">
diff --git a/frontend/src/pages/search.astro b/frontend/src/pages/search.astro
index 78f49f5d..c9a8d65f 100644
--- a/frontend/src/pages/search.astro
+++ b/frontend/src/pages/search.astro
@@ -15,8 +15,11 @@ import Header from "../components/Header.astro";
</div>
<div class="flex">
- <div class="flex pl-40 flex-col">
- <div class="flex mt-1 pl-3 pt-2 max-w-3xl pr-24 w-full justify-between">
+ <div class="hidden md:block max-w-[10rem] w-1/6"></div>
+ <div class="flex flex-col">
+ <div
+ class="flex mt-1 pl-3 pt-2 md:max-w-3xl shrink-0 md:min-w-[50ch] pr-24 w-full justify-between mx-auto"
+ >
<div
class="flex flex-col h-full justify-center text-sm text-gray-600"
>
@@ -135,7 +138,7 @@ import Header from "../components/Header.astro";
}
</div>
- <div class="flex w-full justify-center items-center pr-24 mt-5">
+ <div class="flex w-full justify-center items-center mt-5">
{
askama.if_(
"let Some(url) = prev_page_url",
@@ -155,7 +158,9 @@ import Header from "../components/Header.astro";
</div>
</div>
- {askama.if_("let Some(entity) = entity", <Entity entity="entity" />)}
+ <div class="hidden md:block">
+ {askama.if_("let Some(entity) = entity", <Entity entity="entity" />)}
+ </div>
</div>
</main>
@@ -167,7 +172,7 @@ import Header from "../components/Header.astro";
@apply w-6 text-gray-500;
}
.change-page-active {
- @apply text-brand/80 hover:text-brand w-6;
+ @apply w-6 text-brand/80 hover:text-brand;
}
.title-link {