File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import type { Pathname } from '$app/types' ;
2+ import { onMount } from 'svelte' ;
3+
4+ export interface BreadCrumbEntry {
5+ text : string ;
6+ href : Pathname | null ;
7+ }
8+
9+ let state = $state < BreadCrumbEntry [ ] > ( [ ] ) ;
10+
11+ export const breadcrumbs = {
12+ get State ( ) {
13+ return state ;
14+ } ,
15+ push : ( text : string , href : Pathname | null = null ) => {
16+ onMount ( ( ) => {
17+ const entry = { text, href } ;
18+ state = [ ...state , entry ] ;
19+ return ( ) => {
20+ state = state . filter ( ( e ) => e . text !== entry . text || e . href !== entry . href ) ;
21+ } ;
22+ } ) ;
23+ } ,
24+ clear : ( ) => state = [ ] ,
25+ } ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11<script lang =" ts" >
22 import Container from ' $lib/components/Container.svelte' ;
3+ import { breadcrumbs } from ' $lib/state/Breadcrumbs.svelte' ;
4+ breadcrumbs .push (' Home' , ' /home' );
35 </script >
46
57<Container >Home</Container >
Original file line number Diff line number Diff line change 1313 import { type Hub , columns } from ' ./columns' ;
1414 import DataTableActions from ' ./data-table-actions.svelte' ;
1515 import HubCreateDialog from ' ./dialog-hub-create.svelte' ;
16+ import { breadcrumbs } from ' $lib/state/Breadcrumbs.svelte' ;
1617
1718 const isMobile = new IsMobile ();
1819
4647
4748 let showAddHubModal = $state <boolean >(false );
4849
50+ breadcrumbs .push (' Hubs' , ' /hubs' );
4951 onMount (refreshOwnHubs );
5052 </script >
5153
Original file line number Diff line number Diff line change 1+ <script lang =" ts" >
2+ import * as Breadcrumb from " $lib/components/ui/breadcrumb" ;
3+ import { breadcrumbs } from " $lib/state/Breadcrumbs.svelte" ;
4+ </script >
5+
6+ {#if breadcrumbs .State .length > 0 }
7+ <Breadcrumb .Root >
8+ <Breadcrumb .List >
9+ {#each breadcrumbs .State as crumb , index }
10+ <Breadcrumb .Item >
11+ {#if index < breadcrumbs .State .length - 1 }
12+ <Breadcrumb .Link href ={crumb .href } class =" text-gray-600 dark:text-gray-300" >
13+ {crumb .text }
14+ </Breadcrumb .Link >
15+ <Breadcrumb .Separator class =" text-gray-600 dark:text-gray-300" />
16+ {:else }
17+ <Breadcrumb .Page class =" text-gray-900 dark:text-gray-100" >
18+ {crumb .text }
19+ </Breadcrumb .Page >
20+ {/if }
21+ </Breadcrumb .Item >
22+ {/each }
23+ </Breadcrumb .List >
24+ </Breadcrumb .Root >
25+ {/if }
Original file line number Diff line number Diff line change 55 import LightSwitch from ' $lib/components/LightSwitch.svelte' ;
66 import DiscordIcon from ' $lib/components/svg/DiscordIcon.svelte' ;
77 import GithubIcon from ' $lib/components/svg/GithubIcon.svelte' ;
8- import * as Breadcrumb from ' $lib/components/ui/breadcrumb' ;
98 import { Button } from ' $lib/components/ui/button' ;
109 import * as DropdownMenu from ' $lib/components/ui/dropdown-menu' ;
1110 import { useSidebar } from ' $lib/components/ui/sidebar' ;
12- import { BreadCrumbStore } from ' $lib/stores/BreadCrumbStore' ;
1311 import { UserStore } from ' $lib/stores/UserStore' ;
1412 import { cn } from ' $lib/utils' ;
13+ import Breadcrumb from ' ./Breadcrumb.svelte' ;
1514 import type { Pathname } from ' $app/types' ;
1615
1716 let sidebar = useSidebar ();
3231 <Button variant ="ghost" class ="size-8" title ="Open Sidebar" onclick ={() => sidebar .toggle ()}>
3332 <PanelLeft size ={24 } class =" m-0 text-gray-600 dark:text-gray-300" />
3433 </Button >
35- {#if $BreadCrumbStore .length > 0 }
36- <Breadcrumb .Root >
37- <Breadcrumb .List >
38- {#each $BreadCrumbStore as crumb , index }
39- <Breadcrumb .Item >
40- {#if index < $BreadCrumbStore .length - 1 }
41- <Breadcrumb .Link href ={crumb .href } class =" text-gray-600 dark:text-gray-300" >
42- {crumb .text }
43- </Breadcrumb .Link >
44- <Breadcrumb .Separator class =" text-gray-600 dark:text-gray-300" />
45- {:else }
46- <Breadcrumb .Page class =" text-gray-900 dark:text-gray-100" >
47- {crumb .text }
48- </Breadcrumb .Page >
49- {/if }
50- </Breadcrumb .Item >
51- {/each }
52- </Breadcrumb .List >
53- </Breadcrumb .Root >
54- {/if }
34+ <Breadcrumb />
5535 <div
5636 class ={cn (
5737 ' flex flex-1 flex-row items-center justify-between space-x-2 py-2' ,
You can’t perform that action at this time.
0 commit comments