Skip to content

web search done right

minor frontend improvements mobile * [ios] discussion widget had two icons as <summary> list-none was not respected on safari. * [ios] added a viewport width to remove horizontal scrolling. * [ios] increased font size of searchbar to prevent ios from zooming when searchbar gets selected. * 'found x results' was ugly on mobile. now only shown on desktop * decreased font size of optic and language selector to not remove attention from results. hopefully they are still noticed. * added og:title and og:image to improve experience when stract is linked from somewhere.

Mikkel Denkere71570e7f774
diff --git a/frontend/package.json b/frontend/package.json
index 3c2aece2..40eff060 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -60,4 +60,4 @@
"tailwind-merge": "^2.1.0",
"ts-pattern": "^5.0.6"
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/lib/components/OpticSelector.svelte b/frontend/src/lib/components/OpticSelector.svelte
index 5fbec60c..9ebf0e39 100644
--- a/frontend/src/lib/components/OpticSelector.svelte
+++ b/frontend/src/lib/components/OpticSelector.svelte
@@ -31,7 +31,7 @@
form="searchbar-form"
id="optics-selector"
name="optic"
- class="m-0 text-neutral-focus text-sm cursor-pointer"
+ class="m-0 text-neutral-focus text-xs cursor-pointer"
submitOnChange={searchOnChange}
bind:value={selected}
{options}
diff --git a/frontend/src/lib/components/RegionSelect.svelte b/frontend/src/lib/components/RegionSelect.svelte
index c330b47a..50f8ca68 100644
--- a/frontend/src/lib/components/RegionSelect.svelte
+++ b/frontend/src/lib/components/RegionSelect.svelte
@@ -16,7 +16,7 @@
form="searchbar-form"
id="region-selector"
name="gl"
- class="m-0 text-neutral-focus text-sm cursor-pointer"
+ class="m-0 text-neutral-focus text-xs cursor-pointer"
submitOnChange={searchOnChange}
bind:value={selected}
{options}
diff --git a/frontend/src/lib/components/Searchbar.svelte b/frontend/src/lib/components/Searchbar.svelte
index 815dac86..50a9e1b5 100644
--- a/frontend/src/lib/components/Searchbar.svelte
+++ b/frontend/src/lib/components/Searchbar.svelte
@@ -107,7 +107,7 @@
{autofocus}
placeholder="Search"
autocomplete="off"
- class="border-none bg-transparent focus:ring-0"
+ class="border-none bg-transparent focus:ring-0 text-lg"
on:focus={() => {
hasFocus = true;
}}
@@ -116,7 +116,14 @@
// don't blur yet since the clicked element would disapper
if (e.relatedTarget instanceof Node && suggestionsDiv?.contains(e.relatedTarget)) return;
- requestIdleCallback(() => (hasFocus = false));
+ // requestIdleCallback is not supported in Safari
+ // https://caniuse.com/requestidlecallback
+ // @ts-ignore
+ if (window.requestIdleCallback) {
+ requestIdleCallback(() => (hasFocus = false));
+ } else {
+ hasFocus = false;
+ }
}}
bind:value={query}
on:keydown={onKeydown}
diff --git a/frontend/src/routes/+layout.svelte b/frontend/src/routes/+layout.svelte
index c8a84baa..98aeb859 100644
--- a/frontend/src/routes/+layout.svelte
+++ b/frontend/src/routes/+layout.svelte
@@ -7,6 +7,9 @@
<svelte:head>
<title>{$page.data.globals?.title || 'Stract'}</title>
+ <meta property="og:title" content="Stract" />
+ <meta property="og:image" content="https://stract.com/images/biglogo-with-text.png" />
+ <meta name="viewport" content="width=device-width">
</svelte:head>
<div class="grid min-h-screen grid-rows-[auto_1fr_auto] font-light">
diff --git a/frontend/src/routes/+page.svelte b/frontend/src/routes/+page.svelte
index adc33641..cb7c0663 100644
--- a/frontend/src/routes/+page.svelte
+++ b/frontend/src/routes/+page.svelte
@@ -11,7 +11,7 @@
<div class="px-3 w-full md:mx-0 md:max-w-xl">
<Searchbar autofocus={true} />
</div>
- <div class="px-5 mt-3 flex space-x-2 text-neutral">
+ <div class="px-5 mt-3 flex space-x-2 text-neutral text-sm md:text-sm">
<div>
Customise your search with an{' '}
<a class="font-medium underline" href="/settings/optics">optic</a>:
diff --git a/frontend/src/routes/search/+page.svelte b/frontend/src/routes/search/+page.svelte
index 8c279aab..7ecf34f3 100644
--- a/frontend/src/routes/search/+page.svelte
+++ b/frontend/src/routes/search/+page.svelte
@@ -150,8 +150,8 @@
<div class="w-full">
<Searchbar {query} />
</div>
- <div class="mx-auto flex w-full justify-between">
- <div class="flex h-full flex-col justify-center space-x-2 text-sm text-neutral">
+ <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">
<p class="h-fit">
{#if results.numHits != null}
Found <span class="font-medium">{results.numHits.toLocaleString()}</span> results in <span class="font-medium">{(
diff --git a/frontend/src/routes/search/Discussions.svelte b/frontend/src/routes/search/Discussions.svelte
index cab85cfc..286ab087 100644
--- a/frontend/src/routes/search/Discussions.svelte
+++ b/frontend/src/routes/search/Discussions.svelte
@@ -57,3 +57,10 @@
</div>
</div>
</div>
+
+<style>
+ /* hide marker in safari */
+ summary::-webkit-details-marker {
+ display: none;
+ }
+</style>
\ No newline at end of file
diff --git a/frontend/src/routes/search/Entity.svelte b/frontend/src/routes/search/Entity.svelte
index 14069d4d..fd718c34 100644
--- a/frontend/src/routes/search/Entity.svelte
+++ b/frontend/src/routes/search/Entity.svelte
@@ -10,11 +10,13 @@
{#if entity.imageId}
<div class="w-lg mb-5">
<a href="https://en.wikipedia.org/wiki/{encodeURI(entity.title)}">
+ <div class="h-40">
<img
alt="Image of {entity.title}"
- class="h-full w-full max-h-40 object-scale-down rounded-full"
+ class="h-full w-full object-contain rounded-full"
src="{getApiBase()}/beta/api/entity_image?imageId={entity.imageId}"
/>
+ </div>
</a>
</div>
{/if}
@@ -54,15 +56,15 @@
{#each entity.relatedEntities as related (related.title)}
<div class="flex flex-col items-center p-4">
{#if related.imageId != null}
- <div class="mb-3 h-20 w-20">
- <a href="/search?q={encodeURIComponent(related.title)}">
+ <a href="/search?q={encodeURIComponent(related.title)}">
+ <div class="h-20 w-20">
<img
alt="Image of {related.title}"
class="h-full w-full rounded-full object-cover"
src="{getApiBase()}/beta/api/entity_image?imageId={related.imageId}&maxWidth=200&maxHeight=200"
/>
- </a>
- </div>
+ </div>
+ </a>
{/if}
<div class="line-clamp-3 text-center">
diff --git a/frontend/static/images/biglogo-with-text.png b/frontend/static/images/biglogo-with-text.png
new file mode 100644
index 00000000..4e2ff84e
Binary files /dev/null and b/frontend/static/images/biglogo-with-text.png differ