web search done right
Accessibility overhaul (#231)
Mikkel Denkerf494a11a1a0f
diff --git a/crates/core/src/api/webgraph.rs b/crates/core/src/api/webgraph.rsindex 40155a0c..648cdcaf 100644--- a/crates/core/src/api/webgraph.rs+++ b/crates/core/src/api/webgraph.rs@@ -31,6 +31,7 @@ pub mod host {use url::Url;pub use crate::entrypoint::webgraph_server::ScoredHost;+ use crate::webpage::url_ext::UrlExt;use super::*;@@ -88,12 +89,21 @@ pub mod host {params(KnowsHostParams),responses((status = 200, description = "Whether the host is known", body = KnowsHost),+ (status = 400, description = "Invalid host", body = String),))]pub async fn knows(extract::State(state): extract::State<Arc<State>>,extract::Query(params): extract::Query<KnowsHostParams>,) -> std::result::Result<impl IntoResponse, StatusCode> {+ match Url::robust_parse(¶ms.host) {+ Ok(url) => match url.tld() {+ None | Some("") => return Err(StatusCode::BAD_REQUEST),+ Some(_) => (),+ },+ Err(_) => return Err(StatusCode::BAD_REQUEST),+ }+match state.host_webgraph.knows(params.host).await {Ok(Some(node)) => Ok(Json(KnowsHost::Known {host: node.as_str().to_string(),diff --git a/crates/core/src/webpage/url_ext.rs b/crates/core/src/webpage/url_ext.rsindex 0f4a74ce..56da87e8 100644--- a/crates/core/src/webpage/url_ext.rs+++ b/crates/core/src/webpage/url_ext.rs@@ -126,8 +126,15 @@ impl UrlExt for url::Url {fn tld(&self) -> Option<&str> {let host = self.host_str()?;- let suffix = std::str::from_utf8(ICANN_LIST.suffix(host.as_bytes())?.as_bytes()).ok()?;- Some(suffix)+ let suffix = ICANN_LIST.suffix(host.as_bytes())?;++ match suffix.typ() {+ Some(_) => {+ let tld = std::str::from_utf8(suffix.as_bytes()).ok()?;+ Some(tld)+ }+ None => None,+ }}}@@ -165,4 +172,19 @@ mod tests {let url: Url = Url::parse("http://example.com").unwrap();assert_eq!(url.tld().unwrap(), "com");}++ #[test]+ fn tld() {+ let url: Url = Url::parse("http://example.com").unwrap();+ assert_eq!(url.tld().unwrap(), "com");++ let url: Url = Url::parse("http://example.co.uk").unwrap();+ assert_eq!(url.tld().unwrap(), "co.uk");++ let url: Url = Url::parse("http://example.co.uk").unwrap();+ assert_eq!(url.tld().unwrap(), "co.uk");++ let url: Url = Url::parse("http://asdf").unwrap();+ assert_eq!(url.tld(), None);+ }}diff --git a/frontend/.eslintrc.cjs b/frontend/.eslintrc.cjsindex 291263ad..c4ac2daf 100644--- a/frontend/.eslintrc.cjs+++ b/frontend/.eslintrc.cjs@@ -16,13 +16,14 @@ module.exports = {plugins: ['@typescript-eslint'],parserOptions: {sourceType: 'module',- ecmaVersion: 2020,+ ecmaVersion: 2022,extraFileExtensions: ['.svelte'],},env: {browser: true,es2017: true,node: true,+ es6: true,},overrides: [{diff --git a/frontend/src/lib/components/Callout.svelte b/frontend/src/lib/components/Callout.svelteindex 526cb9da..a4276a26 100644--- a/frontend/src/lib/components/Callout.svelte+++ b/frontend/src/lib/components/Callout.svelte@@ -7,14 +7,22 @@import { twJoin } from 'tailwind-merge';export let kind: 'info' | 'success' | 'warning' | 'error' | 'neutral';- export let icon: null | ComponentType = {+ export let title: string = kind;++ let icon: null | ComponentType = {info: InformationCircle,success: CheckCircle,warning: ExclamationCircle,error: Fire,neutral: null,}[kind];- export let title: string = kind;+ let iconLabel = {+ info: 'Information',+ success: 'Success',+ warning: 'Warning',+ error: 'Error',+ neutral: 'Neutral',+ }[kind];</script><div@@ -30,7 +38,7 @@<div><slot name="title"><div class="flex items-center space-x-1.5 pb-1 font-bold capitalize tracking-wide">- <svelte:component this={icon} />+ <svelte:component this={icon} aria-label={iconLabel} /><span>{title}</span>diff --git a/frontend/src/lib/components/Header.svelte b/frontend/src/lib/components/Header.svelteindex ab7bc8d2..899475e3 100644--- a/frontend/src/lib/components/Header.svelte+++ b/frontend/src/lib/components/Header.svelte@@ -26,7 +26,17 @@] as const;</script>-<div class="relative grid w-full grid-cols-[2fr_1fr_2fr] px-4 text-sm">+<nav class="relative grid w-full grid-cols-[2fr_1fr_2fr] px-4 text-sm">+ <div class="absolute left-5 top-2 z-10">+ <a+ href="#main"+ tabindex="0"+ class="absolute -top-64 left-0 bg-black p-2 text-base-content focus:top-0"+ >+ Skip to content+ </a>+ </div>+<div class="flex space-x-4">{#each links as [url, name]}<a@@ -49,7 +59,7 @@{/if}</div>- <nav class="hidden items-center justify-end space-x-1 sm:flex md:space-x-2 lg:space-x-4">+ <div class="hidden items-center justify-end space-x-1 sm:flex md:space-x-2 lg:space-x-4">{#each nav as [url, name]}<Link href={url}>{name}@@ -57,14 +67,15 @@{/each}{#each social as [url, label, Icon]}<Link href={url} {label} round>- <Icon />+ <Icon aria-label={label} /></Link>{/each}- </nav>+ </div>- <nav class="group relative flex items-center justify-end text-lg sm:hidden">+ <div class="group relative flex items-center justify-end text-lg sm:hidden"><buttonclass="mx-1 aspect-square rounded-full bg-transparent px-3 text-neutral transition group-hover:text-neutral-focus"+ title="Toggle menu"><Bars2 /></button>@@ -82,17 +93,17 @@<div class="flex justify-around border-t pt-2">{#each social as [url, label, Icon]}<Link href={url} {label} round>- <Icon />+ <Icon aria-label={label} /></Link>{/each}</div></div></div>- </nav>+ </div>{#if showDivider}<divclass="absolute inset-x-0 -bottom-0 h-px bg-gradient-to-r from-primary via-primary-focus to-primary"/>{/if}-</div>+</nav>diff --git a/frontend/src/lib/components/Link.svelte b/frontend/src/lib/components/Link.svelteindex 1c7591b9..cface3b7 100644--- a/frontend/src/lib/components/Link.svelte+++ b/frontend/src/lib/components/Link.svelte@@ -18,8 +18,8 @@class={twMerge('flex justify-center rounded-full transition',round ? 'p-2' : 'px-2 py-1',- 'text-neutral-focus hover:bg-primary/10 hover:text-primary-focus active:bg-primary-focus/10',- isActive && 'bg-primary/20 text-primary-focus',+ 'text-neutral-focus hover:bg-primary-focus/5 hover:text-primary-focus active:bg-primary-focus/5',+ isActive && 'bg-primary-focus/5 text-primary-focus',)}><slot />diff --git a/frontend/src/lib/components/OpticSelector.svelte b/frontend/src/lib/components/OpticSelector.svelteindex db34cdda..913bdee5 100644--- a/frontend/src/lib/components/OpticSelector.svelte+++ b/frontend/src/lib/components/OpticSelector.svelte@@ -35,5 +35,6 @@submitOnChange={searchOnChange}bind:value={selected}{options}+ ariaLabel="Optic selector"/></div>diff --git a/frontend/src/lib/components/RegionSelect.svelte b/frontend/src/lib/components/RegionSelect.svelteindex 1dc3673a..a6c4e29f 100644--- a/frontend/src/lib/components/RegionSelect.svelte+++ b/frontend/src/lib/components/RegionSelect.svelte@@ -20,5 +20,6 @@submitOnChange={searchOnChange}bind:value={selected}{options}+ ariaLabel="Region selector"/></div>diff --git a/frontend/src/lib/components/Searchbar.svelte b/frontend/src/lib/components/Searchbar.svelteindex f1df8845..f06a469c 100644--- a/frontend/src/lib/components/Searchbar.svelte+++ b/frontend/src/lib/components/Searchbar.svelte@@ -10,8 +10,8 @@import { P, match } from 'ts-pattern';export let autofocus = false;-export let query = '';+let selected: 'none' | number = 'none';let suggestions: HighlightedFragment[][] = [];@@ -107,15 +107,15 @@aria-autocomplete="list"aria-expanded={suggestions.length > 0 && hasFocus}>- <MagnifyingGlass class="w-5 text-base-content" />+ <MagnifyingGlass class="w-5 text-base-content" aria-label="Magnifying glass" /><!-- svelte-ignore a11y-autofocus --><input- type="search"id="searchbar"name="q"{autofocus}placeholder="Search"autocomplete="off"+ aria-expanded={suggestions.length > 0 && hasFocus}class="border-none bg-transparent text-lg focus:ring-0"on:focus={() => {hasFocus = true;@@ -157,30 +157,34 @@role="listbox"bind:this={suggestionsDiv}>- {#each suggestions as s, index}- <button- class={twJoin(- 'flex space-x-3 py-1.5 pl-5 hover:bg-base-200',- selected == index && 'bg-base-200',- )}- on:click={() => {- selectSuggestion(s);- hasFocus = false;- }}- type="submit"- >- <MagnifyingGlass class="w-4 text-neutral" />- <span>- {#each s as fragment}- {#if fragment.kind == 'highlighted'}- <span class="font-medium">{fragment.text}</span>- {:else}- {fragment.text}- {/if}- {/each}- </span></button- >- {/each}+ <ul class="w-full">+ {#each suggestions as s, index}+ <li>+ <button+ class={twJoin(+ 'flex w-full space-x-3 py-1.5 pl-5 hover:bg-base-200',+ selected == index && 'bg-base-200',+ )}+ on:click={() => {+ selectSuggestion(s);+ hasFocus = false;+ }}+ type="submit"+ >+ <MagnifyingGlass class="w-4 text-neutral" aria-label="Magnifying glass" />+ <span>+ {#each s as fragment}+ {#if fragment.kind == 'highlighted'}+ <span class="font-medium">{fragment.text}</span>+ {:else}+ {fragment.text}+ {/if}+ {/each}+ </span></button+ >+ </li>+ {/each}+ </ul></div>{/if}</label>diff --git a/frontend/src/lib/components/Select.svelte b/frontend/src/lib/components/Select.svelteindex 08292187..6cdf0eb6 100644--- a/frontend/src/lib/components/Select.svelte+++ b/frontend/src/lib/components/Select.svelte@@ -10,13 +10,16 @@form?: string;submitOnChange?: boolean;options: Option[];+ ariaLabel?: string;+ id?: string;}export let value: T; // eslint-disable-line no-undefexport let form: string | undefined = void 0;export let submitOnChange = false;export let options: $$Props['options'];-+ export let ariaLabel: string | undefined = undefined;+ export let id: string | undefined = undefined;// eslint-disable-next-line no-undefconst dispatch = createEventDispatcher<{ change: T }>();</script>@@ -25,6 +28,8 @@<select{...$$restProps}{form}+ aria-label={ariaLabel}+ {id}on:change={(e) => {if (!e?.target || !(e.target instanceof HTMLSelectElement)) return;diff --git a/frontend/src/lib/components/Site.svelte b/frontend/src/lib/components/Site.svelteindex 145b61d2..fc2ec31f 100644--- a/frontend/src/lib/components/Site.svelte+++ b/frontend/src/lib/components/Site.svelte@@ -7,15 +7,15 @@const dispatch = createEventDispatcher<{ delete: null }>();</script>-<span class="group flex overflow-hidden rounded-lg bg-secondary transition">+<span class="group flex rounded-lg bg-secondary transition"><a{href}target="_blank"class={twMerge(- 'bg-secondary py-2',+ 'py-2','text-primary-content','transition hover:bg-secondary-focus',- 'pl-3 pr-2',+ 'rounded-l-lg pl-3 pr-2',)}><slot />@@ -25,12 +25,13 @@/><buttonclass={twMerge(- 'cursor-pointer bg-secondary px-2 text-sm',+ 'cursor-pointer text-sm','text-primary-content',- 'noscript:hidden transition hover:bg-secondary-focus',+ 'noscript:hidden rounded-r-lg transition hover:bg-secondary-focus',)}- on:click={() => dispatch('delete')}+ on:click|preventDefault={() => dispatch('delete')}+ title="Remove site">- ×+ <span class="px-2"> × </span></button></span>diff --git a/frontend/src/lib/components/ThemeSelect.svelte b/frontend/src/lib/components/ThemeSelect.svelteindex a3ec9f7d..7e772776 100644--- a/frontend/src/lib/components/ThemeSelect.svelte+++ b/frontend/src/lib/components/ThemeSelect.svelte@@ -10,5 +10,11 @@</script><div class="noscript:hidden">- <Select bind:value={$themeStore} class="text-neutral-focus" {options} />+ <Select+ bind:value={$themeStore}+ class="text-neutral-focus"+ {options}+ id="theme"+ ariaLabel="Select theme"+ /></div>diff --git a/frontend/src/lib/themes.ts b/frontend/src/lib/themes.tsindex 5cd3d5f2..14fefbcf 100644--- a/frontend/src/lib/themes.ts+++ b/frontend/src/lib/themes.ts@@ -11,6 +11,7 @@ export const THEMES = [theme('Primer Dark', 'theme-primer-dark'),theme('Nord', 'theme-nord'),theme('Ayu Mirage', 'theme-ayu-mirage'),+ theme('High Contrast', 'theme-high-contrast'),];/*@@ -35,7 +36,7 @@ export const getButtonTailwindStyle = (_class: string,) => {return twMerge(- 'rounded-full py-2 transition active:scale-[98%]',+ 'rounded-full py-2 transition active:scale-[98%] outline-accent',padding ? 'px-4' : 'px-2','border border-transparent',palediff --git a/frontend/src/routes/+layout.svelte b/frontend/src/routes/+layout.svelteindex 7316985a..61d1ae5e 100644--- a/frontend/src/routes/+layout.svelte+++ b/frontend/src/routes/+layout.svelte@@ -15,7 +15,9 @@<div class="grid min-h-screen grid-rows-[auto_1fr_auto] font-light"><Header />- <slot />+ <div id="main">+ <slot />+ </div><Footer /></div>diff --git a/frontend/src/routes/explore/+page.svelte b/frontend/src/routes/explore/+page.svelteindex d5b3d31c..a3a18437 100644--- a/frontend/src/routes/explore/+page.svelte+++ b/frontend/src/routes/explore/+page.svelte@@ -16,14 +16,15 @@import { page } from '$app/stores';import { goto } from '$app/navigation';import { browser } from '$app/environment';+ import { InvalidHostError, UnknownHostError } from '.';export let data: PageData;let inputWebsite = '';- let limit = data.limit;- let chosenHosts = data.chosenHosts;- let similarHosts = data.similarHosts;+ let limit = data.limit ?? LIMIT_OPTIONS[0];+ let chosenHosts = data.chosenHosts ?? [];+ let similarHosts = data.similarHosts ?? [];let errorMessage = data.errorMessage;$: chosenHostString = chosenHosts.join(',');@@ -66,21 +67,25 @@};const addWebsite = async (host: string, clear = false) => {- errorMessage = false;+ errorMessage = undefined;host = host.trim();if (!host) return;- const result = await api.webgraphHostKnows({ host }).data;- match(result)- .with({ _type: 'unknown' }, () => {- errorMessage = true;- })- .with({ _type: 'known' }, async ({ host }) => {- if (clear) inputWebsite = '';- if (!chosenHosts.includes(host)) chosenHosts = [...chosenHosts, host];- updateBrowserState();- })- .exhaustive();+ try {+ const result = await api.webgraphHostKnows({ host }).data;+ match(result)+ .with({ _type: 'unknown' }, () => {+ errorMessage = UnknownHostError;+ })+ .with({ _type: 'known' }, async ({ host }) => {+ if (clear) inputWebsite = '';+ if (!chosenHosts.includes(host)) chosenHosts = [...chosenHosts, host];+ updateBrowserState();+ })+ .exhaustive();+ } catch (_) {+ errorMessage = InvalidHostError;+ }};const exportAsOptic = async () => {@@ -133,11 +138,11 @@{#if errorMessage}<div class="my-2" transition:slide><Callout kind="warning" title="Unable to add page">- <button slot="top-right" on:click={() => (errorMessage = false)}>- <XMark />+ <button slot="top-right" on:click={() => (errorMessage = undefined)} title="Close">+ <XMark aria-label="X-mark" /></button>- Unfortunately, we don't know about that site yet.+ {errorMessage}</Callout></div>{/if}@@ -164,6 +169,7 @@class="cursor-pointer rounded border-none dark:bg-transparent"bind:value={limit}options={LIMIT_OPTIONS.map((value) => ({ value, label: value.toString() }))}+ title="Limit number of similar sites shown"/></div><div />@@ -172,7 +178,7 @@<table class="w-full border-separate border-spacing-y-1"><thead><tr class="text-left">- <th class="pb-2"></th>+ <th class="pb-2" aria-label="Add to search"></th><th class="pb-2">Similarity</th><th class="pb-2">Site</th></tr>@@ -197,6 +203,7 @@class={twJoin('text-xl text-success group-hover:scale-105 group-active:scale-95',)}+ aria-label="Plus-mark"/></button></td>@@ -211,7 +218,7 @@<div class="noscript:hidden flex w-full justify-center"><buttonclass="h-6 w-6 cursor-pointer rounded-full text-accent"- aria-label="Show more similar sites"+ title="Show more similar sites"on:click={() => {if (limit == LIMIT_OPTIONS[LIMIT_OPTIONS.length - 1]) {return;@@ -219,7 +226,7 @@limit = LIMIT_OPTIONS[LIMIT_OPTIONS.indexOf(limit) + 1];}}>- <ChevronDown />+ <ChevronDown aria-label="Chevron-down" /></button></div></div>diff --git a/frontend/src/routes/explore/+page.ts b/frontend/src/routes/explore/+page.tsindex c4631d1d..17594359 100644--- a/frontend/src/routes/explore/+page.ts+++ b/frontend/src/routes/explore/+page.ts@@ -2,11 +2,12 @@ import { api, type ScoredHost } from '$lib/api';import { match } from 'ts-pattern';import type { PageLoad } from './$types';import { LIMIT_OPTIONS } from './conf';+import { InvalidHostError, UnknownHostError } from '.';export const load: PageLoad = async (req) => {const host = req.url.searchParams.get('site');let chosenHosts: string[] = req.url.searchParams.get('chosenHosts')?.split(',') || [];- let errorMessage = false;+ let errorMessage: string | undefined = undefined;let limit = LIMIT_OPTIONS[0];@@ -16,16 +17,20 @@ export const load: PageLoad = async (req) => {}if (host && host.length > 0) {- const res = await api.webgraphHostKnows({ host }).data;-- match(res)- .with({ _type: 'unknown' }, () => {- errorMessage = true;- })- .with({ _type: 'known' }, async ({ host }) => {- if (host.length > 0 && !chosenHosts.includes(host)) chosenHosts = [...chosenHosts, host];- })- .exhaustive();+ try {+ const res = await api.webgraphHostKnows({ host }).data;++ match(res)+ .with({ _type: 'unknown' }, () => {+ errorMessage = UnknownHostError;+ })+ .with({ _type: 'known' }, async ({ host }) => {+ if (host.length > 0 && !chosenHosts.includes(host)) chosenHosts = [...chosenHosts, host];+ })+ .exhaustive();+ } catch (_) {+ errorMessage = InvalidHostError;+ }}let similarHosts: ScoredHost[] = [];diff --git a/frontend/src/routes/explore/index.ts b/frontend/src/routes/explore/index.tsnew file mode 100644index 00000000..12f183d8--- /dev/null+++ b/frontend/src/routes/explore/index.ts@@ -0,0 +1,3 @@+export const UnknownHostError = "Unfortunately, we don't know about that site yet.";+export const InvalidHostError = 'Please enter a valid site.';+export const InternalServerError = 'Oops! An error occurred. Please try again later.';diff --git a/frontend/src/routes/search/Discussions.svelte b/frontend/src/routes/search/Discussions.svelteindex 1d685a41..2f2d34dc 100644--- a/frontend/src/routes/search/Discussions.svelte+++ b/frontend/src/routes/search/Discussions.svelte@@ -34,7 +34,7 @@{#if shownDiscussions && shownDiscussions.length > 0}<div class="row-start-5 flex flex-col space-y-1.5 overflow-hidden"><div class="flex items-center space-x-1 text-lg">- <ChatBubbleLeftRight class="text-sm text-neutral" />+ <ChatBubbleLeftRight class="text-sm text-neutral" aria-label="Chat bubble" /><span>Discussions</span></div><div class="flex flex-col">@@ -55,7 +55,10 @@{discussion.title}</a><span>- <ChevronDown class="text-sm transition group-open:rotate-180" />+ <ChevronDown+ class="text-sm transition group-open:rotate-180"+ aria-label="Chevron down"+ /></span></summary>diff --git a/frontend/src/routes/search/Modal.svelte b/frontend/src/routes/search/Modal.svelteindex 8528cd05..6af25e2c 100644--- a/frontend/src/routes/search/Modal.svelte+++ b/frontend/src/routes/search/Modal.svelte@@ -33,6 +33,10 @@import { scale } from 'svelte/transition';import { match } from 'ts-pattern';import SignalInfo from './SignalInfo.svelte';+ import { onMount } from 'svelte';+ import { createEventDispatcher } from 'svelte';++ const dispatch = createEventDispatcher();export let modal: { top: number; left: number; site: DisplayedWebpage };@@ -174,11 +178,52 @@[site.site]: $rankings[site.site] == ranking ? void 0 : ranking,}));};++ let modalElement: HTMLDivElement | undefined;++ // eslint-disable-next-line no-undef+ let tabableElements: NodeListOf<HTMLElement> | undefined;++ const updateTab = () => {+ if (modalElement) {+ tabableElements = modalElement.querySelectorAll('button, input, textarea, select, a');+ if (tabableElements && tabableElements.length > 0) {+ tabableElements[0].focus();+ }+ }+ };++ $: {+ modal.site;+ updateTab();+ }++ onMount(() => {+ updateTab();+ });++ const onKeydown = (e: KeyboardEvent) => {+ if (e.key === 'Tab') {+ e.preventDefault();+ if (tabableElements && tabableElements.length > 0) {+ const index = Array.from(tabableElements).indexOf(document.activeElement as HTMLElement);+ let newIndex = (index + (e.shiftKey ? -1 : 1)) % tabableElements.length;+ if (newIndex < 0) {+ newIndex = tabableElements.length - 1;+ }++ tabableElements[newIndex].focus();+ }+ } else if (e.key === 'Escape') {+ e.preventDefault();+ modalElement?.remove();+ dispatch('close');+ }+ };</script><svelte:window bind:innerWidth />-<!-- svelte-ignore a11y-click-events-have-key-events --><!-- svelte-ignore a11y-no-static-element-interactions --><divclass={twJoin(@@ -188,6 +233,10 @@style="top: {top}px; left: calc({left}px); width: {widthPixels}px;"transition:scale={{ duration: 150 }}on:click|stopPropagation={() => {}}+ bind:this={modalElement}+ on:keydown={(e) => {+ onKeydown(e);+ }}><div><h2 class="w-full text-center">Do you like results from</h2>diff --git a/frontend/src/routes/search/Result.svelte b/frontend/src/routes/search/Result.svelteindex a3e1879e..dac83c92 100644--- a/frontend/src/routes/search/Result.svelte+++ b/frontend/src/routes/search/Result.svelte@@ -86,7 +86,7 @@bind:this={button}on:click|stopPropagation={() => dispatch('modal', button)}>- <AdjustVertical class="text-md" />+ <AdjustVertical class="text-md" aria-label="3 vertical bars" /></button></div></div>diff --git a/frontend/src/routes/search/Serp.svelte b/frontend/src/routes/search/Serp.svelteindex 409e0f4b..8dc6fcca 100644--- a/frontend/src/routes/search/Serp.svelte+++ b/frontend/src/routes/search/Serp.svelte@@ -63,10 +63,16 @@</script>{#if modal}- <Modal {modal} />+ <Modal+ {modal}+ on:close={() => {+ modal = void 0;+ }}+ />{/if}{#if results._type == 'websites'}+ <h1 class="sr-only">Search Results</h1><div class="col-start-1 flex min-w-0 max-w-2xl flex-col space-y-5">{#if results.spellCorrection}<SpellCorrection spellCorrection={results.spellCorrection} bind:this={spellCorrectElem} />@@ -79,7 +85,7 @@{#if results.webpages}<div class="grid w-full grid-cols-1 space-y-10 place-self-start">{#each results.webpages as webpage, resultIndex (`${query}-${resultIndex}-${webpage.url}`)}- <div animate:flip={{ duration: 150 }}>+ <div animate:flip={{ duration: 150 }} aria-expanded={modal?.site == webpage}><Resultbind:this={resultElems[resultIndex]}{webpage}@@ -97,19 +103,25 @@<div class="flex justify-center"><div class="grid grid-cols-[repeat(3,auto)] items-center justify-center gap-2">{#if prevPageSearchParams}- <a href="/search?{prevPageSearchParams}">- <ChevronLeft class="text-xl text-primary hover:text-primary-focus" />+ <a href="/search?{prevPageSearchParams}" aria-label="Previous page">+ <ChevronLeft+ class="text-xl text-primary hover:text-primary-focus"+ aria-label="Chevron left"+ /></a>{:else}- <ChevronLeft class="text-xl text-neutral" />+ <ChevronLeft class="text-xl text-neutral" aria-label="Chevron left" />{/if}<div>Page {currentPage}</div>{#if nextPageSearchParams}- <a href="/search?{nextPageSearchParams}">- <ChevronRight class="text-xl text-primary hover:text-primary-focus" />+ <a href="/search?{nextPageSearchParams}" aria-label="Next page">+ <ChevronRight+ class="text-xl text-primary hover:text-primary-focus"+ aria-label="Chevron right"+ /></a>{:else}- <ChevronRight class="text-xl text-neutral" />+ <ChevronRight class="text-xl text-neutral" aria-label="Chevron right" />{/if}</div></div>diff --git a/frontend/src/routes/settings/+page.svelte b/frontend/src/routes/settings/+page.svelteindex 669c3802..0e4db093 100644--- a/frontend/src/routes/settings/+page.svelte+++ b/frontend/src/routes/settings/+page.svelte@@ -58,7 +58,8 @@<h1 class="text-2xl font-medium">Preferences</h1><div class="flex flex-col space-y-5">{#each settings as setting}- <div class="flex flex-col pr-1 sm:flex-row sm:justify-between">+ <fieldset class="flex flex-col pr-1 sm:flex-row sm:justify-between">+ <legend class="sr-only">{setting.title}</legend><div class="flex flex-col pr-5"><h2 class="text-lg">{setting.title}</h2><p class="text-sm">{setting.description}</p>@@ -84,7 +85,7 @@{/if}</div></div>- </div>+ </fieldset>{/each}</div></div>diff --git a/frontend/src/routes/settings/PostSearchSelect.svelte b/frontend/src/routes/settings/PostSearchSelect.svelteindex 674dcdc1..5a1c301f 100644--- a/frontend/src/routes/settings/PostSearchSelect.svelte+++ b/frontend/src/routes/settings/PostSearchSelect.svelte@@ -9,5 +9,10 @@</script><div class="noscript:hidden">- <Select bind:value={$postSearchStore} class="text-neutral-focus" {options} />+ <Select+ bind:value={$postSearchStore}+ class="text-neutral-focus"+ {options}+ ariaLabel="Select request type"+ /></div>diff --git a/frontend/src/routes/settings/optics/+page.svelte b/frontend/src/routes/settings/optics/+page.svelteindex 63e07fab..ed48d8f0 100644--- a/frontend/src/routes/settings/optics/+page.svelte+++ b/frontend/src/routes/settings/optics/+page.svelte@@ -115,15 +115,17 @@name="Name"autocomplete="off"bind:value={name}+ lang="en"/>- <input type="url" required placeholder="Url" name="Url" bind:value={url} />- <Button title="Remove optic">Add</Button>+ <input type="url" required placeholder="Url" name="Url" bind:value={url} lang="en" />+ <Button title="Add optic">Add</Button><inputclass="col-span-2"type="text"name="Description"placeholder="Description"bind:value={description}+ lang="en"/></form>{#if error}@@ -146,20 +148,29 @@class="group flex w-6 items-start !bg-transparent"on:click={removeOptic(optic)}disabled={!removable}- title={removable ? 'Remove' : ''}+ title="Remove optic"><MinusCircleclass="text-neutral transition group-enabled:text-error group-enabled:group-hover:text-error"+ aria-label="Minus with circle around it"/></button><label class="flex w-6 items-start hover:cursor-pointer" title="Show/hide in UI">- <input- type="checkbox"- bind:checked={$opticsShowStore[opticKey(optic)]}- class="peer hidden"- />- <EyeSlash class="inline-flex text-neutral transition peer-checked:hidden" />- <Eye class="hidden text-neutral transition peer-checked:inline-flex" />+ <button class="m-0 flex w-6 p-0">+ <input+ type="checkbox"+ bind:checked={$opticsShowStore[opticKey(optic)]}+ class="peer hidden"+ />+ <EyeSlash+ class="inline-flex text-neutral transition peer-checked:hidden"+ aria-label="Eye slash"+ />+ <Eye+ class="hidden text-neutral transition peer-checked:inline-flex"+ aria-label="Eye"+ />+ </button></label><div class="text-sm">{optic.name}</div><div class="text-sm">diff --git a/frontend/src/routes/settings/sites/+page.svelte b/frontend/src/routes/settings/sites/+page.svelteindex 048a2fff..531a9310 100644--- a/frontend/src/routes/settings/sites/+page.svelte+++ b/frontend/src/routes/settings/sites/+page.svelte@@ -2,7 +2,6 @@import { api } from '$lib/api';import Button from '$lib/components/Button.svelte';import Site from '$lib/components/Site.svelte';- import { getButtonTailwindStyle } from '$lib/themes';import { Rankings, rankingsToRanked, type RankedSites, type Ranking } from '$lib/rankings';import { hostRankingsStore } from '$lib/stores';import { flip } from 'svelte/animate';@@ -121,16 +120,16 @@{#each buttons as { text, clear }}<Button on:click={clearAndExport({ clear })}>{text}</Button>{/each}- <input- type="file"- accept=".optic"- id="optic-import"- multiple- on:change={importOpticFile}- hidden- />- <label for="optic-import" class={getButtonTailwindStyle(false, false, 'primary', '')}>- Import from optic- </label>+ <Button>+ <input+ type="file"+ accept=".optic"+ id="optic-import"+ multiple+ on:change={importOpticFile}+ hidden+ />+ <label for="optic-import"> Import from optic </label>+ </Button></div></div>diff --git a/frontend/src/themes/high_contrast.ts b/frontend/src/themes/high_contrast.tsnew file mode 100644index 00000000..a842be65--- /dev/null+++ b/frontend/src/themes/high_contrast.ts@@ -0,0 +1,44 @@+import { base, theme } from './base';++export const highContrastTheme = theme({+ name: 'high-contrast',+ scheme: 'dark',+ colors: {+ primary: base.orange[500],+ primaryFocus: base.orange[600],+ primaryContent: '#000',++ secondary: base.island[500],+ secondaryFocus: base.island[400],+ secondaryContent: '#fff',++ accent: base.navy[500],+ accentFocus: base.navy[400],+ accentContent: '#fff',++ neutral: base.zinc[400],+ neutralFocus: base.zinc[300],+ neutralContent: base.zinc[300],++ base100: base.zinc[900],+ base200: base.zinc[800],+ base300: base.zinc[700],+ base400: base.zinc[600],+ baseContent: base.island[50],++ info: base.navy[600],+ infoContent: base.navy[100],++ success: base.green[600],+ successContent: base.green[100],++ warning: base.amber[600],+ warningContent: '#000',++ error: base.cerise2[600],+ errorContent: base.cerise2[100],++ link: base.sky[500],+ linkVisited: base.purple[400],+ },+});diff --git a/frontend/src/themes/index.ts b/frontend/src/themes/index.tsindex 60a81dc4..55e8578c 100644--- a/frontend/src/themes/index.ts+++ b/frontend/src/themes/index.ts@@ -5,6 +5,7 @@ import { lightTheme } from './light';import { nordLightTheme, nordTheme } from './nord';import { pastelTheme } from './pastel';import { uglyTheme } from './ugly';+import { highContrastTheme } from './high_contrast';export const themes = [lightTheme,@@ -15,4 +16,5 @@ export const themes = [ayuMirageTheme,primerDarkTheme,uglyTheme,+ highContrastTheme,];