-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e734ae
commit 6efe22e
Showing
8 changed files
with
154 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<script lang="ts"> | ||
import { matchingParts } from '$lib/utils'; | ||
interface Props { | ||
content?: string; | ||
ref?: string; | ||
caseInsensitive?: boolean; | ||
} | ||
let { content = '', ref = '', caseInsensitive = true }: Props = $props(); | ||
const parts = $derived(matchingParts(content, ref, { caseInsensitive })); | ||
</script> | ||
|
||
{#each parts as { match, part }} | ||
{#if match} | ||
<mark class="bg-accent text-accent-content outline-accent outline">{part}</mark> | ||
{:else} | ||
{part} | ||
{/if} | ||
{/each} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
<script lang="ts"> | ||
import { page } from '$app/stores'; | ||
import '../app.css'; | ||
import { capitalizeWords } from '$lib'; | ||
let {children} = $props(); | ||
const title = $derived(capitalizeWords($page.route.id?.slice(1).split('-').join(' ') ?? '')); | ||
</script> | ||
|
||
<main class="p-4 min-h-screen grid justify-center gap-2 items-start place-content-start"> | ||
<slot /> | ||
{#if title} | ||
<a class="m-auto mb-2" href="/"><btn class="btn w-fit btn-sm">Main Page</btn></a> | ||
<h1 class="text-2xl font-bold m-auto mb-4">{title}</h1> | ||
{/if} | ||
{@render children()} | ||
</main> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<script lang="ts"> | ||
import { isAlphaNumChar, shortcut } from '$lib'; | ||
import MatchHighlighter from '$lib/components/MatchHighlighter.svelte'; | ||
let ref = $state('dust'); | ||
let content = $state( | ||
"I'm blown away\n\ | ||
Like a layer of dust on the floor\n\ | ||
Of the hall where we first met\n\ | ||
Trust was the first thing we lost that day" | ||
); | ||
let refInput = $state<HTMLInputElement>(); | ||
</script> | ||
|
||
<input | ||
bind:this={refInput} | ||
bind:value={ref} | ||
placeholder="Reference" | ||
class="input input-bordered mb-4" | ||
use:shortcut={{ | ||
shortcuts(e) { | ||
if (e.ctrlKey || e.shiftKey || e.altKey) return false; | ||
return isAlphaNumChar(e.key) || e.key === 'Backspace' || e.key === ' '; | ||
}, | ||
action: (n, e) => { | ||
if (!refInput) return; | ||
if (e.key === 'Backspace') { | ||
refInput.value = refInput.value.slice(0, -1); | ||
} else refInput.value += e.key; | ||
refInput.focus(); | ||
} | ||
}} | ||
onkeydown={(e) => e.key === 'Escape' && refInput?.blur()} /> | ||
|
||
{#each content.split('\n') as line} | ||
<p class="italic text-lg"><MatchHighlighter content={line} {ref} /></p> | ||
{/each} |