Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
feat(web): make underlines animate into existence on page load
Elijah Potter3cdf6d021a25
diff --git a/packages/web/src/lib/Underlines.svelte b/packages/web/src/lib/Underlines.svelteindex 6a6f38749..76096cee2 100644--- a/packages/web/src/lib/Underlines.svelte+++ b/packages/web/src/lib/Underlines.svelte@@ -11,6 +11,27 @@export let content: string;export let focusLintIndex: number | undefined;+ import { quintOut } from 'svelte/easing';++ let loadTime = Date.now();++ function slideUnderline(node, { duration = 300 }) {+ return {+ duration,+ css: (t) => {+ if (Date.now() - loadTime > 2000) {+ t = 1;+ }++ return `+ transform: scaleX(${t});+ transform-origin: left;+ `;+ },+ easing: quintOut+ };+ }+let lints: [Lint, number][] = [];let lintHighlights: HTMLSpanElement[] = [];let linter = new WorkerLinter();@@ -49,6 +70,7 @@content: string;index: number;color: string;+ context: string;};type UnderlineToken = string | null | undefined | UnderlineDetails;@@ -75,7 +97,8 @@focused: lintIndex === focusLintIndex,index: lintIndex,content: lint.get_problem_text().replaceAll(' ', '\u00A0'),- color: lintKindColor(lint.lint_kind())+ color: lintKindColor(lint.lint_kind()),+ context: prevContent[prevContent.length - 1] ?? ''};return [...prevContent, lintContent];@@ -113,6 +136,7 @@<buttonclass={`underlinespecial transition-all rounded-sm ${chunk.focused ? 'animate-after-bigbounce text-white' : 'text-transparent'}`}bind:this={lintHighlights[chunk.index]}+ in:slideUnderlineon:click={() =>chunk != null && typeof chunk == 'object' && (focusLintIndex = chunk.index)}style={`--line-color: ${chunk.color}; --line-width: ${chunk.focused ? '4px' : '2px'}; --bg-color: ${chunk.focused ? '#dbafb3' : 'transparent'};`}