Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
feat(chrome-ext): bring the selections closer to the cursor (#1283)
Elijah Potter219abb7992b8
diff --git a/packages/chrome-plugin/assets/book-down.svg b/packages/chrome-plugin/assets/book-down.svgnew file mode 100644index 000000000..cf8bb0a27--- /dev/null+++ b/packages/chrome-plugin/assets/book-down.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-book-down-icon lucide-book-down"><path d="M12 13V7"/><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20"/><path d="m9 10 3 3 3-3"/></svg>diff --git a/packages/chrome-plugin/src/Highlights.ts b/packages/chrome-plugin/src/Highlights.tsindex 79f2d6b8b..70a128507 100644--- a/packages/chrome-plugin/src/Highlights.ts+++ b/packages/chrome-plugin/src/Highlights.ts@@ -105,6 +105,7 @@ export default class Highlights {pointerEvents: 'none',zIndex: 10,borderBottom: `2px solid ${lintKindColor(box.lint.lint_kind)}`,+ backgroundColor: `${lintKindColor(box.lint.lint_kind)}22`,},id: 'harper-highlight',},diff --git a/packages/chrome-plugin/src/SuggestionBox.ts b/packages/chrome-plugin/src/SuggestionBox.tsindex d6b164c72..349808e6a 100644--- a/packages/chrome-plugin/src/SuggestionBox.ts+++ b/packages/chrome-plugin/src/SuggestionBox.ts@@ -1,4 +1,5 @@import h from 'virtual-dom/h';+import bookDownSvg from '../assets/book-down.svg?raw';import type { IgnorableLintBox, LintBox } from './Box';import ProtocolClient from './ProtocolClient';import lintKindColor from './lintKindColor';@@ -46,13 +47,19 @@ function footer(leftChildren: any, rightChildren: any) {}function addToDictionary(box: LintBox): any {- return button(- 'Add to Dictionary',- { background: '#8250DF', color: '#FFFFFF' },- () => {- ProtocolClient.addToUserDictionary(box.lint.problem_text);+ console.log(bookDownSvg);+ return h(+ 'button',+ {+ className: 'harper-btn',+ onclick: () => {+ ProtocolClient.addToUserDictionary(box.lint.problem_text);+ },+ title: 'Add word to user dictionary',+ 'aria-label': 'Add word to user dictionary',+ innerHTML: bookDownSvg,},- 'Add word to user dictionary',+ [],);}@@ -71,7 +78,7 @@ function styleTag() {return h('style', { id: 'harper-suggestion-style' }, [`code {background-color: #e3eccf;- padding: 0.25rem;+ padding: 0.125rem;border-radius: 0.25rem;}@@ -83,7 +90,7 @@ function styleTag() {border: 1px solid #d0d7de;border-radius: 8px;box-shadow: 0 4px 12px rgba(140, 149, 159, 0.3);- padding: 16px;+ padding: 8px;display: flex;flex-direction: column;z-index: 5000;@@ -99,8 +106,8 @@ function styleTag() {font-size: 14px;line-height: 20px;color: #1f2328;- padding-bottom: 8px;- margin-bottom: 8px;+ padding-bottom: 4px;+ margin-bottom: 4px;user-select: none;}@@ -118,7 +125,7 @@ function styleTag() {cursor: pointer;border: none;border-radius: 6px;- padding: 6px 12px;+ padding: 3px 6px;min-height: 28px;font-size: 13px;font-weight: 600;@@ -145,7 +152,7 @@ function styleTag() {display: flex;flex-wrap: wrap;justify-content: space-between;- padding: 4px;+ padding: 2px;gap: 16px;}`,]);@@ -154,7 +161,7 @@ function styleTag() {function ignoreLint(onIgnore: () => void): any {return button('Ignore',- { background: '#6e7781', color: '#ffffff' },+ { background: '#e5e5e5', color: '#000000', fontWeight: 'lighter' },onIgnore,'Ignore this lint',);@@ -181,14 +188,14 @@ export default function SuggestionBox(box: IgnorableLintBox, close: () => void)header(box.lint.lint_kind_pretty, lintKindColor(box.lint.lint_kind)),body(box.lint.message_html),footer(- [- box.lint.lint_kind === 'Spelling' ? addToDictionary(box) : undefined,- ignoreLint(box.ignoreLint),- ],suggestions(box.lint.suggestions, (v) => {box.applySuggestion(v);close();}),+ [+ box.lint.lint_kind === 'Spelling' ? addToDictionary(box) : undefined,+ ignoreLint(box.ignoreLint),+ ],),]);}