Skip to content

web search done right

new ui design

Mikkel Denkerad984251b46c
diff --git a/core/src/api/autosuggest.rs b/core/src/api/autosuggest.rs
index ff387dcb..01cfc97f 100644
--- a/core/src/api/autosuggest.rs
+++ b/core/src/api/autosuggest.rs
@@ -16,7 +16,7 @@
use std::{collections::HashMap, sync::Arc};
-use axum::{extract, response::IntoResponse, Extension, Json};
+use axum::{extract, response::IntoResponse, Json};
use serde::Serialize;
use super::State;
@@ -46,8 +46,8 @@ struct Suggestion {
#[allow(clippy::unused_async)]
pub async fn route(
+ extract::State(state): extract::State<Arc<State>>,
extract::Query(params): extract::Query<HashMap<String, String>>,
- Extension(state): Extension<Arc<State>>,
) -> impl IntoResponse {
if let Some(query) = params.get("q") {
let mut suggestions = Vec::new();
@@ -68,8 +68,8 @@ pub async fn route(
#[allow(clippy::unused_async)]
pub async fn browser(
+ extract::State(state): extract::State<Arc<State>>,
extract::Query(params): extract::Query<HashMap<String, String>>,
- Extension(state): Extension<Arc<State>>,
) -> impl IntoResponse {
if let Some(query) = params.get("q") {
Json((query.clone(), state.autosuggest.suggestions(query).unwrap()))
diff --git a/frontend/src/components/Discussions.astro b/frontend/src/components/Discussions.astro
index a8c37d33..34a47ccf 100644
--- a/frontend/src/components/Discussions.astro
+++ b/frontend/src/components/Discussions.astro
@@ -11,7 +11,7 @@ export interface Props {
{
askama.if_("let Some(discussions) = discussions", () => (
<div
- class="discussions relative flex flex-col space-y-1.5 overflow-hidden"
+ class="discussions flex flex-col space-y-1.5 overflow-hidden"
id="discussions"
>
<div class="mb flex space-x-1 text-lg" id="discussions-header">
diff --git a/frontend/src/components/OpticSelector.astro b/frontend/src/components/OpticSelector.astro
index c467a604..5b698f85 100644
--- a/frontend/src/components/OpticSelector.astro
+++ b/frontend/src/components/OpticSelector.astro
@@ -13,7 +13,7 @@ import { askama } from "$/askama";
id="optics-selector"
name="optic"
onchange="document.getElementById('searchbar-form').submit()"
- class="m-0 max-w-[100px] border-0 bg-transparent p-0 text-sm hover:cursor-pointer"
+ class="styled-selector m-0"
>
<option value="">Optic</option>
{
diff --git a/frontend/src/components/Searchbar.astro b/frontend/src/components/Searchbar.astro
index bd575bfd..6d2c22cb 100644
--- a/frontend/src/components/Searchbar.astro
+++ b/frontend/src/components/Searchbar.astro
@@ -12,7 +12,7 @@ const { autofocus, query } = Astro.props;
<style is:global>
.suggestion-item {
@apply hidden group-focus-within:flex group-focus-within:peer-placeholder-shown:hidden;
- @apply col-span-3 py-2 pl-5;
+ @apply col-span-3 py-1.5 pl-5;
}
.suggestion-item:nth-child(4) {
@apply relative;
@@ -33,10 +33,10 @@ const { autofocus, query } = Astro.props;
action="/search"
autocomplete="off"
>
- <div class="relative h-12">
+ <div class="h-10">
<div
id="searchbar"
- class="group absolute inset-x-0 top-0 grid grid-cols-[auto_1fr_auto] grid-rows-[3rem] rounded-3xl border bg-white transition-shadow focus-within:shadow"
+ class="group absolute inset-x-0 top-0 grid grid-cols-[auto_1fr_auto] grid-rows-[2.5rem] rounded-3xl border bg-white transition-shadow focus-within:shadow"
>
<Hero
class="col-[1/2] row-start-1 w-5 self-center ml-5 text-gray-400"
@@ -50,25 +50,14 @@ const { autofocus, query } = Astro.props;
class="searchbar-input peer inset-y-0 col-[1/3] row-start-1 flex h-full w-full grow border-none bg-transparent py-0 pl-12 outline-none focus:ring-0"
placeholder="Search"
/>
- <div class="flex w-12 items-center justify-center">
+ <div class="flex items-center justify-center p-[2px]">
<button
type="submit"
- class="m-0 bg-transparent p-0"
+ class="rounded-full group-focus-within:rounded-b-none h-full px-5 bg-brand opacity-75 text-white hover:opacity-100 transition-colors duration-50"
style="border: none"
title="Search"
>
- <svg
- xmlns="http://www.w3.org/2000/svg"
- fill="none"
- viewBox="0 0 24 24"
- stroke-width="1.5"
- class="w-7 cursor-pointer bg-transparent stroke-brand"
- >
- <path
- stroke-linecap="round"
- stroke-linejoin="round"
- d="M8.25 4.5l7.5 7.5-7.5 7.5"></path>
- </svg>
+ search
</button>
</div>
</div>
diff --git a/frontend/src/layouts/Layout.astro b/frontend/src/layouts/Layout.astro
index fdf17e2a..6ae84441 100644
--- a/frontend/src/layouts/Layout.astro
+++ b/frontend/src/layouts/Layout.astro
@@ -65,6 +65,22 @@ const { title } = Astro.props;
pre > code {
font-size: 0.8rem;
}
+
+ </style>
+ <style is:inline>
+ .styled-selector {
+ background-color: none;
+ background-color: rgba(0, 0, 0, 0);
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='currentColor'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7' /%3E%3C/svg%3E");
+ background-position: right;
+ padding-right: 1.5em;
+ background-repeat: no-repeat;
+ cursor: pointer;
+ font-size: 0.9rem;
+ background-size: 1em 1em;
+ border: none;
+ appearance: none;
+ }
</style>
</body>
</html>
diff --git a/frontend/src/pages/search.astro b/frontend/src/pages/search.astro
index 69635c49..fb7a86ff 100644
--- a/frontend/src/pages/search.astro
+++ b/frontend/src/pages/search.astro
@@ -15,12 +15,11 @@ import { askama } from "../askama";
<Layout title="{{ query }} - Stract">
<main class="flex w-full flex-col">
- <div class="border-b bg-neutral-50">
- <Header searchbar={{ query: askama`query` }} />
- </div>
+ <Header searchbar={{ query: askama`query` }} />
+ <div class="w-full h-[1px] bg-gradient-to-r from-cyan-400 via-brand to-cyan-400"></div>
<div
- class="search-content mx-1 grid gap-y-6 pt-3 sm:px-5 md:grid-cols-[minmax(50ch,48rem)_1fr] md:grid-rows-[auto_1fr] md:gap-x-12 md:pl-20 lg:mx-0 lg:px-36"
+ class="search-content mx-1 grid gap-y-6 pt-4 px-5 md:grid-cols-[minmax(50ch,48rem)_1fr] md:grid-rows-[auto_1fr] md:gap-x-12 md:pl-20 lg:mx-0 lg:px-36"
>
<!-- Stats and settings -->
<div class="mx-auto flex w-full justify-between">
@@ -31,7 +30,7 @@ import { askama } from "../askama";
} seconds
</p>
</div>
- <div class="flex">
+ <div class="flex space-x-2">
<OpticSelector
current_optic_url="current_optic_url"
default_optics="default_optics"
@@ -41,7 +40,7 @@ import { askama } from "../askama";
form="searchbar-form"
name="gl"
onchange="document.getElementById('searchbar-form').submit()"
- class="max-w-[100px] border-0 bg-transparent text-sm hover:cursor-pointer"
+ class="styled-selector"
>
{
askama.for_("region_selection in all_regions", () =>
@@ -159,7 +158,7 @@ import { askama } from "../askama";
{
askama.if_(
"let Some(sidebar) = sidebar",
- <div class="row-start-2 flex justify-center pt-10 md:col-start-2 md:row-span-2 md:row-start-1">
+ <div class="row-start-2 flex justify-center md:pt-10 md:col-start-2 md:row-span-2 md:row-start-1">
<Sidebar sidebar="sidebar" />
</div>
)
@@ -201,7 +200,8 @@ import { askama } from "../askama";
.search-content {
text-rendering: optimizeLegibility;
- font-smooth: grayscale;
+ font-smooth: always;
+ -webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
diff --git a/frontend/tailwind.config.cjs b/frontend/tailwind.config.cjs
index be01ab99..c47f79cd 100644
--- a/frontend/tailwind.config.cjs
+++ b/frontend/tailwind.config.cjs
@@ -11,8 +11,6 @@ module.exports = {
},
fontFamily: {
sans: [
- // "MontserratVariable",
- // "Montserrat",
"Helvetica",
"Arial",
"sans-serif",