From 50255d5ad30c47faf3c5ed6947a9ed74ece34a17 Mon Sep 17 00:00:00 2001 From: Roman Mahotskyi Date: Mon, 23 May 2022 20:33:10 +0300 Subject: [PATCH 1/2] Add possibility to change caret type by clicking on it --- src/components/symbol/symbol.svelte | 38 ++++++++++++++++++++--------- src/components/word/word.svelte | 5 ++++ src/helpers/caret-type.ts | 1 + src/routes/index.svelte | 34 ++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 11 deletions(-) create mode 100644 src/helpers/caret-type.ts diff --git a/src/components/symbol/symbol.svelte b/src/components/symbol/symbol.svelte index 6b22a40..9bbce85 100644 --- a/src/components/symbol/symbol.svelte +++ b/src/components/symbol/symbol.svelte @@ -1,31 +1,47 @@ -
+
active && dispatch('caretChange')} class:cursor-pointer={active} class="flex relative"> + {#if active} + {#if caretType === 'box'} +
+ {:else if caretType === 'background'} +
+ {:else if caretType === 'line'} +
+ {:else} +
+ {/if} + {/if} + {#if isCapsLock && active} -
-
- -

Caps Lock

+
+
+ +

Caps Lock

+
+
-
-
- {/if} -

+

{#if space} {#if invalid}
diff --git a/src/components/word/word.svelte b/src/components/word/word.svelte index ee67b62..69bfd50 100644 --- a/src/components/word/word.svelte +++ b/src/components/word/word.svelte @@ -1,4 +1,6 @@ @@ -24,6 +27,8 @@ active={caretIndex === symbolIndex} typed={typed} isCapsLock={isCapsLock} + caretType={caretType} + on:caretChange /> {/each}
diff --git a/src/helpers/caret-type.ts b/src/helpers/caret-type.ts new file mode 100644 index 0000000..4d7afe2 --- /dev/null +++ b/src/helpers/caret-type.ts @@ -0,0 +1 @@ +export type CaretType = 'box' | 'background' | 'line' | 'underline' \ No newline at end of file diff --git a/src/routes/index.svelte b/src/routes/index.svelte index c8754b9..5342a95 100644 --- a/src/routes/index.svelte +++ b/src/routes/index.svelte @@ -1,10 +1,42 @@