Skip to content

web search done right

make sure each result uses full width of result div

Mikkel Denkercea98843955b
diff --git a/frontend/src/routes/search/+page.svelte b/frontend/src/routes/search/+page.svelte
index 867a90f1..32c2d928 100644
--- a/frontend/src/routes/search/+page.svelte
+++ b/frontend/src/routes/search/+page.svelte
@@ -49,7 +49,7 @@
// | x <--
// +---+
modal = {
- top: window.scrollY + rect.top + rect.height/2,
+ top: window.scrollY + rect.top + rect.height / 2,
left: window.scrollX + rect.right,
site,
};
@@ -66,7 +66,6 @@
$: {
if (browser && results.type == 'websites') updateQueryId({ query, webpages: results.webpages });
}
-
</script>
{#if modal}
@@ -75,7 +74,7 @@
{#if results.type == 'websites'}
<div
- class="m-0 grid w-full gap-y-5 px-5 pt-4 md:grid-cols-[minmax(50ch,48rem)_1fr] grid-rows-[auto_1fr] md:gap-x-12 md:pl-20 lg:pl-28"
+ class="m-0 grid w-full grid-rows-[auto_1fr] gap-y-5 px-5 pt-4 md:grid-cols-[minmax(50ch,48rem)_1fr] md:gap-x-12 md:pl-20 lg:pl-28"
style="text-rendering:optimizeLegibility;font-smooth:always;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;"
>
<div class="flex max-w-2xl flex-col space-y-1">
@@ -83,14 +82,16 @@
<Searchbar {query} />
</div>
<div class="mx-auto flex w-full justify-end sm:justify-between">
- <div class="hidden sm:flex h-full flex-col space-x-2 text-xs text-neutral">
+ <div class="text-neutral hidden h-full flex-col space-x-2 text-xs sm:flex">
<p class="h-fit">
{#if results.numHits != null}
- Found <span class="font-medium">{results.numHits.toLocaleString()}</span> results in <span class="font-medium">{(
- (results.searchDurationMs ?? 0) / 1000
- ).toFixed(2)}s</span>
+ Found <span class="font-medium">{results.numHits.toLocaleString()}</span> results in
+ <span class="font-medium">{((results.searchDurationMs ?? 0) / 1000).toFixed(2)}s</span
+ >
{:else}
- Search took <span class="font-medium">{((results.searchDurationMs ?? 0) / 1000).toFixed(2)}s</span>
+ Search took <span class="font-medium"
+ >{((results.searchDurationMs ?? 0) / 1000).toFixed(2)}s</span
+ >
{/if}
</p>
</div>
@@ -123,7 +124,7 @@
{/if}
{#if results.webpages}
- <div class="grid grid-cols-1 space-y-10 place-self-start">
+ <div class="grid w-full grid-cols-1 space-y-10 place-self-start">
{#each results.webpages as webpage, resultIndex (`${query}-${webpage.url}`)}
<div animate:flip={{ duration: 150 }}>
<Result {webpage} {resultIndex} on:modal={openSearchModal(webpage)} />
@@ -139,18 +140,18 @@
<div class="grid grid-cols-[repeat(3,auto)] items-center justify-center gap-2">
{#if data.prevPageSearchParams}
<a href="/search?{data.prevPageSearchParams}">
- <ChevronLeft class="text-xl text-primary hover:text-primary-focus" />
+ <ChevronLeft class="text-primary hover:text-primary-focus text-xl" />
</a>
{:else}
- <ChevronLeft class="text-xl text-neutral" />
+ <ChevronLeft class="text-neutral text-xl" />
{/if}
<div>Page {data.currentPage}</div>
{#if data.nextPageSearchParams}
<a href="/search?{data.nextPageSearchParams}">
- <ChevronRight class="text-xl text-primary hover:text-primary-focus" />
+ <ChevronRight class="text-primary hover:text-primary-focus text-xl" />
</a>
{:else}
- <ChevronRight class="text-xl text-neutral" />
+ <ChevronRight class="text-neutral text-xl" />
{/if}
</div>
</div>
@@ -158,7 +159,7 @@
{#if results.sidebar}
<div
- class="row-start-2 mx-auto max-w-[90vw] md:max-w-[30vw] justify-center md:col-start-2 md:row-span-2 md:row-start-1 md:pt-5"
+ class="row-start-2 mx-auto max-w-[90vw] justify-center md:col-start-2 md:row-span-2 md:row-start-1 md:max-w-[30vw] md:pt-5"
>
<Sidebar sidebar={results.sidebar} />
</div>
diff --git a/frontend/src/routes/search/Result.svelte b/frontend/src/routes/search/Result.svelte
index e6fe395d..fc7ed9d1 100644
--- a/frontend/src/routes/search/Result.svelte
+++ b/frontend/src/routes/search/Result.svelte
@@ -2,12 +2,19 @@
import AdjustVertical from '~icons/heroicons/adjustments-vertical';
import type { DisplayedWebpage } from '$lib/api';
import { createEventDispatcher } from 'svelte';
- import { clearSummary, summariesStore, markPagesWithAdsStore, markPagesWithPaywallStore } from '$lib/stores';
+ import {
+ clearSummary,
+ summariesStore,
+ markPagesWithAdsStore,
+ markPagesWithPaywallStore,
+ } from '$lib/stores';
import Summary from './Summary.svelte';
import { derived } from 'svelte/store';
import { improvements } from '$lib/improvements';
import TextSnippet from '$lib/components/TextSnippet.svelte';
import StackOverflowSnippet from './StackOverflowSnippet.svelte';
+ import Article from '$lib/components/Article.svelte';
+ import BiglogoBeta from '$lib/images/BiglogoBeta.svelte';
export let webpage: DisplayedWebpage;
export let resultIndex: number;
@@ -24,7 +31,7 @@
<div class="flex min-w-0 grow flex-col space-y-0.5">
<div class="flex items-center text-sm">
<a
- class="max-w-[calc(100%-100px)] truncate text-neutral-focus"
+ class="text-neutral-focus max-w-[calc(100%-100px)] truncate"
href={webpage.url}
use:improvements={resultIndex}
>
@@ -32,7 +39,7 @@
</a>
</div>
<a
- class="max-w-[calc(100%-30px)] truncate text-xl font-medium text-link visited:text-link-visited hover:underline"
+ class="text-link visited:text-link-visited max-w-[calc(100%-30px)] truncate text-xl font-medium hover:underline"
title={webpage.title}
href={webpage.url}
use:improvements={resultIndex}
@@ -41,14 +48,14 @@
</a>
</div>
<button
- class="noscript:hidden flex w-5 min-w-fit items-center justify-center bg-transparent text-neutral hover:cursor-pointer hover:text-neutral-focus"
+ class="noscript:hidden text-neutral hover:text-neutral-focus flex w-5 min-w-fit items-center justify-center bg-transparent hover:cursor-pointer"
bind:this={button}
on:click|stopPropagation={() => dispatch('modal', button)}
>
<AdjustVertical class="text-md" />
</button>
</div>
- <div class="text-sm font-normal text-neutral-focus [&>b]:font-bold">
+ <div class="text-neutral-focus text-sm font-normal [&>b]:font-bold">
{#if $summary}
<Summary url={webpage.url} on:hide={() => clearSummary(webpage)} />
{:else if webpage.snippet.type == 'normal'}
@@ -56,19 +63,28 @@
<div class="line-clamp-3">
<div class="inline">
<span id="snippet-text" class="snippet-text">
- {#if (webpage.likelyHasAds && $markPagesWithAdsStore ) && (webpage.likelyHasPaywall && $markPagesWithPaywallStore)}
- <span class="text-neutral text-center border p-0.5 rounded border-primary text-xs" title="page likely has ads and paywall">
+ {#if webpage.likelyHasAds && $markPagesWithAdsStore && webpage.likelyHasPaywall && $markPagesWithPaywallStore}
+ <span
+ class="text-neutral border-primary rounded border p-0.5 text-center text-xs"
+ title="page likely has ads and paywall"
+ >
has ads + paywall
</span>
- {:else if (webpage.likelyHasAds && $markPagesWithAdsStore)}
- <span class="text-neutral text-center border p-0.5 rounded border-primary text-xs" title="page likely has ads">
+ {:else if webpage.likelyHasAds && $markPagesWithAdsStore}
+ <span
+ class="text-neutral border-primary rounded border p-0.5 text-center text-xs"
+ title="page likely has ads"
+ >
has ads
</span>
- {:else if (webpage.likelyHasPaywall && $markPagesWithPaywallStore)}
- <span class="text-neutral text-center border p-0.5 rounded border-primary text-xs" title="page likely has paywall" >
+ {:else if webpage.likelyHasPaywall && $markPagesWithPaywallStore}
+ <span
+ class="text-neutral border-primary rounded border p-0.5 text-center text-xs"
+ title="page likely has paywall"
+ >
paywall
</span>
- {/if}
+ {/if}
{#if webpage.snippet.date}
<span class="text-neutral">
{webpage.snippet.date}