-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: update dependencies and refine Svelte components for better props handling * chore: add caniuse-lite dependency for improved browser compatibility insights * chore: refactor imports for note types and improve metadata typing in Svelte components
- Loading branch information
1 parent
17f5b8e
commit e8a22c6
Showing
16 changed files
with
193 additions
and
149 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
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 |
---|---|---|
|
@@ -39,4 +39,4 @@ | |
</a> | ||
</li> | ||
</ul> | ||
<div class="flex space-x-1 sm:space-x-4" /> | ||
<div class="flex space-x-1 sm:space-x-4"></div> |
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,92 +1,99 @@ | ||
<script lang="ts"> | ||
let data: HTMLElement; | ||
let href = ''; | ||
let id = ''; | ||
import { run } from 'svelte/legacy'; | ||
export let depth: number; | ||
export let text: string; | ||
let data: HTMLElement | undefined = $state(); | ||
let href = $state(''); | ||
let id = $state(''); | ||
$: { | ||
if (typeof data?.innerText === 'string') { | ||
id = data?.innerText?.toLowerCase().trim().split(' ').join('-'); | ||
href = `#${id}`; | ||
} | ||
} | ||
interface Props { | ||
depth: number; | ||
text: string; | ||
children?: import('svelte').Snippet; | ||
} | ||
const focusElement = () => { | ||
data.scrollIntoView(); | ||
}; | ||
let { depth, text, children }: Props = $props(); | ||
run(() => { | ||
if (typeof data?.innerText === 'string') { | ||
id = data?.innerText?.toLowerCase().trim().split(' ').join('-'); | ||
href = `#${id}`; | ||
} | ||
}); | ||
const focusElement = () => { | ||
data?.scrollIntoView(); | ||
}; | ||
</script> | ||
|
||
{#if depth === 1} | ||
<h1 {id} class="font-body relative group py-2" bind:this={data}> | ||
<slot /> | ||
</h1> | ||
<h1 {id} class="font-body relative group py-2" bind:this={data}> | ||
{@render children?.()} | ||
</h1> | ||
{:else if depth === 2} | ||
<a class="no-underline" {href} on:click={focusElement}> | ||
<h2 {id} class="font-body relative group py-2" bind:this={data}> | ||
<span> | ||
<slot /> | ||
</span> | ||
<span | ||
class="invisible inline p-1 group-hover:visible bg-gray-200 font-bold rounded h-8 w-8 dark:bg-gray-600 dark:text-gray-200" | ||
> | ||
# | ||
</span> | ||
</h2> | ||
</a> | ||
<a class="no-underline" {href} onclick={focusElement}> | ||
<h2 {id} class="font-body relative group py-2" bind:this={data}> | ||
<span> | ||
{@render children?.()} | ||
</span> | ||
<span | ||
class="invisible inline p-1 group-hover:visible bg-gray-200 font-bold rounded h-8 w-8 dark:bg-gray-600 dark:text-gray-200" | ||
> | ||
# | ||
</span> | ||
</h2> | ||
</a> | ||
{:else if depth === 3} | ||
<a class="no-underline" {href} on:click={focusElement}> | ||
<h3 {id} class="font-body relative group py-2" bind:this={data}> | ||
<span> | ||
<slot /> | ||
</span> | ||
<span | ||
class="invisible inline p-1 group-hover:visible bg-gray-200 font-bold rounded h-8 w-8 dark:bg-gray-600 dark:text-gray-200" | ||
> | ||
# | ||
</span> | ||
</h3> | ||
</a> | ||
<a class="no-underline" {href} onclick={focusElement}> | ||
<h3 {id} class="font-body relative group py-2" bind:this={data}> | ||
<span> | ||
{@render children?.()} | ||
</span> | ||
<span | ||
class="invisible inline p-1 group-hover:visible bg-gray-200 font-bold rounded h-8 w-8 dark:bg-gray-600 dark:text-gray-200" | ||
> | ||
# | ||
</span> | ||
</h3> | ||
</a> | ||
{:else if depth === 4} | ||
<a class="no-underline" {href} on:click={focusElement}> | ||
<h4 {id} class="font-body relative group py-2" bind:this={data}> | ||
<span> | ||
<slot /> | ||
</span> | ||
<span | ||
class="invisible inline p-1 group-hover:visible bg-gray-200 font-bold rounded h-8 w-8 dark:bg-gray-600 dark:text-gray-200" | ||
> | ||
# | ||
</span> | ||
</h4> | ||
</a> | ||
<a class="no-underline" {href} onclick={focusElement}> | ||
<h4 {id} class="font-body relative group py-2" bind:this={data}> | ||
<span> | ||
{@render children?.()} | ||
</span> | ||
<span | ||
class="invisible inline p-1 group-hover:visible bg-gray-200 font-bold rounded h-8 w-8 dark:bg-gray-600 dark:text-gray-200" | ||
> | ||
# | ||
</span> | ||
</h4> | ||
</a> | ||
{:else if depth === 5} | ||
<a class="no-underline" {href} on:click={focusElement}> | ||
<h5 {id} class="font-body relative group py-2" bind:this={data}> | ||
<span> | ||
<slot /> | ||
</span> | ||
<span | ||
class="invisible inline p-1 group-hover:visible bg-gray-200 font-bold rounded h-8 w-8 dark:bg-gray-600 dark:text-gray-200" | ||
> | ||
# | ||
</span> | ||
</h5> | ||
</a> | ||
<a class="no-underline" {href} onclick={focusElement}> | ||
<h5 {id} class="font-body relative group py-2" bind:this={data}> | ||
<span> | ||
{@render children?.()} | ||
</span> | ||
<span | ||
class="invisible inline p-1 group-hover:visible bg-gray-200 font-bold rounded h-8 w-8 dark:bg-gray-600 dark:text-gray-200" | ||
> | ||
# | ||
</span> | ||
</h5> | ||
</a> | ||
{:else if depth === 6} | ||
<a class="no-underline" {href} on:click={focusElement}> | ||
<h6 {id} class="font-body relative group py-2" bind:this={data}> | ||
<span> | ||
<slot /> | ||
</span> | ||
<span | ||
class="invisible inline p-1 group-hover:visible bg-gray-200 font-bold rounded h-8 w-8 dark:bg-gray-600 dark:text-gray-200" | ||
> | ||
# | ||
</span> | ||
</h6> | ||
</a> | ||
<a class="no-underline" {href} onclick={focusElement}> | ||
<h6 {id} class="font-body relative group py-2" bind:this={data}> | ||
<span> | ||
{@render children?.()} | ||
</span> | ||
<span | ||
class="invisible inline p-1 group-hover:visible bg-gray-200 font-bold rounded h-8 w-8 dark:bg-gray-600 dark:text-gray-200" | ||
> | ||
# | ||
</span> | ||
</h6> | ||
</a> | ||
{:else} | ||
{text} | ||
{text} | ||
{/if} |
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
Oops, something went wrong.