Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
feat: added dark mode to web client
Elijah Potter70c365dabbde
diff --git a/demo.md b/demo.mdindex 3fbdd5e7c..83fbe3b49 100644--- a/demo.md+++ b/demo.md@@ -1,11 +1,14 @@Harper is a language checker for artists. it can detect-improper capitalization and misspelled words. There are some cases,-where the the standard grammar checkers don't cut it.+improper capitalization and misspelled words. There are+some cases, where the the standard grammar checkers+don't cut it.That s where Harper comes in handy.-Harper works everywhere, even offline. Since you r data never leaves your device,-you don't ned to worry aout us selling it or using it to train LLMs.+Harper works everywhere, even offline. Since you r data+never leaves your device, you don't ned to worry aout us+selling it or using it to train LLMs.The best part: Harper can give you feedback instantly.-For most documents, Harper can serve up suggestions in under 10 ms.+For most documents, Harper can serve up suggestions in+under 10 ms.diff --git a/harper-core/dictionary.dict b/harper-core/dictionary.dictindex 73f0fe208..018c22c40 100644--- a/harper-core/dictionary.dict+++ b/harper-core/dictionary.dict@@ -49596,3 +49596,4 @@ Grammarly/MLanguageTool/MWebAssembly/MNeovim/M+quartile/sdiff --git a/harper-core/src/linting/matcher.rs b/harper-core/src/linting/matcher.rsindex f9e46064c..d0e9eee41 100644--- a/harper-core/src/linting/matcher.rs+++ b/harper-core/src/linting/matcher.rs@@ -93,6 +93,8 @@ pub struct Matcher {impl Matcher {pub fn new() -> Self {let mut triggers = pt! {+ "stdin" => "standard input",+ "stdout" => "standard output","your","doing" => "you're doing","no","to" => "not to","No","to" => "not to",diff --git a/harper-ls/src/backend.rs b/harper-ls/src/backend.rsindex 66b0cb03f..99b06ee6d 100644--- a/harper-ls/src/backend.rs+++ b/harper-ls/src/backend.rs@@ -58,7 +58,10 @@ impl Backend {};let mut linter = self.linter.lock().await;- let lints = linter.lint(document);+ let mut lints = linter.lint(document);++ lints.sort_by_key(|l| l.priority);+let source_chars = document.get_full_content();// Find lints whose span overlaps with rangediff --git a/web/src/app.html b/web/src/app.htmlindex 01fedb1f7..2f3ac1fa1 100644--- a/web/src/app.html+++ b/web/src/app.html@@ -10,7 +10,7 @@<script data-goatcounter="https://harper.goatcounter.com/count" async src="//gc.zgo.at/count.js"></script></head>-<body data-sveltekit-preload-data="hover" class="m-0 p-0 w-full h-full">+<body data-sveltekit-preload-data="hover" class="m-0 p-0 w-full h-full dark:bg-gray-800"><div style="display: contents" class="m-0 p-0">%sveltekit.body%</div></body>diff --git a/web/src/lib/Editor.svelte b/web/src/lib/Editor.svelteindex 4573e3f6b..1dee89b4f 100644--- a/web/src/lib/Editor.svelte+++ b/web/src/lib/Editor.svelte@@ -56,7 +56,7 @@<div class="flex flex-col overflow-y-scroll overflow-x-hidden m-0 p-0">{#each lints as lint, i}<div- class="block max-w-sm p-6 bg-white border border-gray-200 rounded-lg shadow m-1 hover:translate-x-1 transition-all"+ class="block max-w-sm p-6 bg-white dark:bg-gray-800 border border-gray-200 rounded-lg shadow m-1 hover:translate-x-1 transition-all"on:click={() => (focused = i)}bind:this={lintCards[i]}>diff --git a/web/src/lib/Underlines.svelte b/web/src/lib/Underlines.svelteindex 4f9bbeea2..6b9b5ad09 100644--- a/web/src/lib/Underlines.svelte+++ b/web/src/lib/Underlines.svelte@@ -1,4 +1,9 @@<script lang="ts">+ // This is some of the shittiest code I've ever written.+ // It is quite hard to look at.+ // Someday, I'll return to it and spruce it up.+ // For now, it works.+import type { Lint } from '$lib/analysis';import { lintText, spanContent } from '$lib/analysis';@@ -54,7 +59,6 @@let lintContent = [spanContent(lint.span, content).replaceAll(' ', '\u00A0'),- '#0B2545',lintIndex === focusLintIndex,lintIndex];@@ -92,10 +96,11 @@{:else}<span class="pointer-events-auto" style={`margin-right: -4px;`}><span- class={`underlinespecial transition-all rounded-sm ${chunk[2] ? 'animate-after-bigbounce text-white' : ''}`}- bind:this={lintHighlights[chunk[3]]}- on:click={() => (focusLintIndex = chunk[3]) && console.log('hit')}- style={`--line-color: ${chunk[1]}; --line-width: ${chunk[2] ? '4px' : '2px'}; --bg-color: ${chunk[2] ? '#8DA9C4' : 'transparent'};`}+ class={`underlinespecial transition-all rounded-sm ${chunk[1] ? 'animate-after-bigbounce text-white' : ''}`}+ bind:this={lintHighlights[chunk[2]]}+ on:click={() => (focusLintIndex = chunk[2])}+ style={`--line-color: #DB2B39; --line-width: ${chunk[1] ? '4px' : '2px'}; --bg-color: ${chunk[1] ? '#dbafb3' : 'transparent'};`}+ l>{chunk[0]}</span>diff --git a/web/src/routes/+page.svelte b/web/src/routes/+page.svelteindex a9f5d7375..ec7ae2940 100644--- a/web/src/routes/+page.svelte+++ b/web/src/routes/+page.svelte@@ -1,6 +1,7 @@<script>import Editor from '$lib/Editor.svelte';import GutterCenter from '$lib/GutterCenter.svelte';+ import { DarkMode } from 'flowbite-svelte';let width = window.innerWidth;@@ -12,16 +13,30 @@<div class="h-16" /><GutterCenter>- <h1 class="text-5xl font-bold text-center">Hi. I'm Harper.</h1>- <h2 class="text-3xl text-center">The Grammar Checker for Developers</h2>- <h2 class="text-2xl font-light italic text-center">Private. Free. Unobtrusive.</h2>+ <h1 class="text-5xl font-bold text-center dark:text-white">Hi. I'm Harper.</h1>+ <h2 class="text-3xl text-center dark:text-white">The Grammar Checker for Developers</h2>+ <h2 class="text-2xl font-light italic text-center dark:text-white">+ Private. Free. Unobtrusive.+ </h2><div class="flex flex-row justify-evenly mt-5">- <a href="https://github.com/chilipepperhott/harper" class="hover:scale-105 transition-all"- ><img width="40" height="40" src="/icons/github.svg" alt="Project Repository" /></a+ <a href="https://github.com/chilipepperhott/harper"+ ><img+ width="40"+ height="40"+ class="hover:scale-105 transition-all bg-white rounded-full"+ src="/icons/github.svg"+ alt="Project Repository"+ /></a>- <a href="https://elijahpotter.dev" class="hover:scale-105 transition-all"- ><img width="40" height="40" src="/icons/profile.svg" alt="Author" /></a+ <a href="https://elijahpotter.dev"+ ><img+ width="40"+ height="40"+ class="hover:scale-105 transition-all"+ src="/icons/profile.svg"+ alt="Author"+ /></a></div>@@ -29,9 +44,11 @@{#if width > 1080}<Editor />{:else}- <p class="italic text-lg w-full text-center">+ <p class="italic text-lg w-full text-center dark:text-white">Open this page on a bigger screen to start checking your work.</p>{/if}</div></GutterCenter>++<div class="absolute top-8 right-8"><DarkMode /></div>diff --git a/web/static/icons/github.svg b/web/static/icons/github.svgindex 0215e057c..ba75c5af2 100644--- a/web/static/icons/github.svg+++ b/web/static/icons/github.svg@@ -1,3 +1,3 @@-<svg width="32px" height="32px" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">+<svg width="32px" height="32px" viewBox="1 1 30 30" xmlns="http://www.w3.org/2000/svg"><path d="M16 0.396c-8.839 0-16 7.167-16 16 0 7.073 4.584 13.068 10.937 15.183 0.803 0.151 1.093-0.344 1.093-0.772 0-0.38-0.009-1.385-0.015-2.719-4.453 0.964-5.391-2.151-5.391-2.151-0.729-1.844-1.781-2.339-1.781-2.339-1.448-0.989 0.115-0.968 0.115-0.968 1.604 0.109 2.448 1.645 2.448 1.645 1.427 2.448 3.744 1.74 4.661 1.328 0.14-1.031 0.557-1.74 1.011-2.135-3.552-0.401-7.287-1.776-7.287-7.907 0-1.751 0.62-3.177 1.645-4.297-0.177-0.401-0.719-2.031 0.141-4.235 0 0 1.339-0.427 4.4 1.641 1.281-0.355 2.641-0.532 4-0.541 1.36 0.009 2.719 0.187 4 0.541 3.043-2.068 4.381-1.641 4.381-1.641 0.859 2.204 0.317 3.833 0.161 4.235 1.015 1.12 1.635 2.547 1.635 4.297 0 6.145-3.74 7.5-7.296 7.891 0.556 0.479 1.077 1.464 1.077 2.959 0 2.14-0.020 3.864-0.020 4.385 0 0.416 0.28 0.916 1.104 0.755 6.4-2.093 10.979-8.093 10.979-15.156 0-8.833-7.161-16-16-16z"/></svg>