-
Notifications
You must be signed in to change notification settings - Fork 5
chore: Breadcrumb cleanup #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+208
−89
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
66a12a6
breadcrumb cleanup
LucHeart b1473b2
fix format...
LucHeart a99aa45
add breadcrumb stuff, and edit button to public shares
LucHeart 64a969d
Merge develop into feature/breadcrumb-cleanup
hhvrc 6b1fdf5
add share copy input
LucHeart a5e2ee9
format
LucHeart 5e00660
Merge branch 'develop' into feature/breadcrumb-cleanup
hhvrc 0730ddd
yeet
hhvrc ec88a7c
Improve breadcrumb store
hhvrc 3a994fa
Update +page.svelte
hhvrc 582b866
Update src/routes/Breadcrumb.svelte
hhvrc 8380a11
Update src/routes/(app)/profile/+page.svelte
hhvrc 788a430
fix pr comments
hhvrc c7f5316
Merge branch 'develop' into feature/breadcrumb-cleanup
hhvrc 633a3e5
more format
hhvrc af208f7
Fix more stuff
hhvrc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,25 +1,39 @@ | ||
| import type { Pathname } from '$app/types'; | ||
| import { onMount } from 'svelte'; | ||
| import { onDestroy } from 'svelte'; | ||
|
|
||
| export interface BreadCrumbEntry { | ||
| text: string; | ||
| export interface BreadcrumbEntry { | ||
| label: string; | ||
| href: Pathname | null; | ||
| } | ||
|
|
||
| let _state = $state<BreadCrumbEntry[]>([]); | ||
| interface BreadcrumbSlot { | ||
| id: symbol; | ||
| entries: BreadcrumbEntry[]; | ||
| } | ||
|
|
||
| const _slots = $state<BreadcrumbSlot[]>([]); | ||
|
|
||
| export const breadcrumbs = { | ||
| get state() { | ||
| return _state; | ||
| get state(): BreadcrumbEntry[] { | ||
| return _slots.flatMap((s) => s.entries); | ||
| }, | ||
| push: (text: string, href: Pathname | null = null) => { | ||
| onMount(() => { | ||
| const entry = { text, href }; | ||
| _state = [..._state, entry]; | ||
| return () => { | ||
| _state = _state.filter((e) => e.text !== entry.text || e.href !== entry.href); | ||
| }; | ||
| }); | ||
| }, | ||
| clear: () => (_state = []), | ||
| }; | ||
|
|
||
| export function registerBreadcrumbs( | ||
| entriesFn: () => Array<{ label: string; href?: Pathname | null }> | ||
| ): void { | ||
| const id = Symbol(); | ||
| _slots.push({ id, entries: [] }); | ||
|
|
||
| $effect(() => { | ||
| const slot = _slots.find((s) => s.id === id); | ||
| if (slot) { | ||
| slot.entries = entriesFn().map((e) => ({ label: e.label, href: e.href ?? null })); | ||
| } | ||
| }); | ||
|
|
||
| onDestroy(() => { | ||
| const idx = _slots.findIndex((s) => s.id === id); | ||
| if (idx !== -1) _slots.splice(idx, 1); | ||
| }); | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,10 @@ | ||
| <script lang="ts"> | ||
| import { registerBreadcrumbs } from '$lib/state/breadcrumbs-state.svelte'; | ||
|
|
||
| registerBreadcrumbs(() => [{ label: 'Profile' }]); | ||
| </script> | ||
|
|
||
| <main> | ||
| <h1>Profile</h1> | ||
| <p>Your profile page is coming soon.</p> | ||
| </main> | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.