Skip to content

Commit cdc4ae1

Browse files
committed
feat: add breadcrumb
1 parent fec1a65 commit cdc4ae1

File tree

5 files changed

+29
-4
lines changed

5 files changed

+29
-4
lines changed

.changes/breadcrumb.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"algohub": patch:feat
3+
---
4+
5+
Support for breadcrumbs in the AlgoHub toolbar.

src/components/UniversalToolBar.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { useToast } from 'primevue';
55
import { computed, ref } from 'vue';
66
import { useRouter } from 'vue-router';
77
8+
const props = defineProps<{ path?: { icon: string, label: string, command: () => void }[] }>()
9+
810
const router = useRouter();
911
const toast = useToast();
1012
@@ -83,7 +85,15 @@ const toggleCreateMenu = (event: any) => {
8385
<div class="bg-gray-100 dark:bg-zinc-900 flex flex-row items-center justify-between w-full p-3 flex-wrap">
8486
<div class="inline-flex justify-center items-center">
8587
<img :src="themeStore.dark ? '/acm-light.png' : '/acm.png'" width="40"></img>
86-
<h1 class="text-lg font-bold">Dashboard</h1>
88+
<Breadcrumb :model="props.path">
89+
<template #item="{ item }">
90+
<a :class="item.url ? 'cursor-pointer' : ''" :href="item.url">
91+
<span :class="item.icon"></span>
92+
<span>{{ item.label }}</span>
93+
</a>
94+
</template>
95+
<template #separator> / </template>
96+
</Breadcrumb>
8797
</div>
8898
<div class="inline-flex justify-center items-center gap-3">
8999
<Button @click="toggleCreateMenu" aria-haspopup="true" aria-controls="overlay_menu" plain outlined>

src/views/dashboard.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import * as api from '@/scripts/api';
55
import { useRouter } from 'vue-router';
66
import { useToast } from 'primevue';
77
8+
const path = [{ label: 'Dashboard' }];
9+
810
const router = useRouter();
911
const toast = useToast();
1012
@@ -33,7 +35,7 @@ onMounted(async () => {
3335

3436
<template>
3537
<div class="min-h-screen h-screen flex flex-col">
36-
<UniversalToolBar></UniversalToolBar>
38+
<UniversalToolBar :path></UniversalToolBar>
3739
<div class="flex flex-col md:flex-row h-full w-full">
3840
<aside class="w-full md:w-1/3 lg:w-1/4 flex">
3941
<div

src/views/problem/[id].vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ const onSubmitCode = async (code: string, language: string) => {
5151
toast.add({ severity: 'success', summary: 'Success', detail: 'Your code has been submitted successfully.' });
5252
}
5353
54+
const path = ref([
55+
{ label: 'fu050409' },
56+
{ label: 'problem' },
57+
{ label: id },
58+
]);
59+
5460
const loading = ref(true);
5561
onMounted(async () => {
5662
const res = await api.fetchProblem(id, {
@@ -67,7 +73,7 @@ onMounted(async () => {
6773

6874
<template>
6975
<div class="h-full w-full flex flex-col">
70-
<UniversalToolBar></UniversalToolBar>
76+
<UniversalToolBar :path></UniversalToolBar>
7177
<Splitter :gutterSize="2" class="flex-1 max-h-screen">
7278
<SplitterPanel>
7379
<Panel v-if="!loading" :header="problem?.title" class="w-full h-full overflow-auto">

src/views/problem/create.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { useRouter } from 'vue-router';
66
import { useAccountStore } from '@/scripts/store';
77
import { Thing } from '@/scripts/types';
88
9+
const path = [{ label: 'New problem' }];
10+
911
const router = useRouter();
1012
const toast = useToast();
1113
const $primevue = usePrimeVue();
@@ -220,7 +222,7 @@ const formatSize = (bytes: number) => {
220222

221223
<template>
222224
<div class="min-h-screen h-full flex flex-col">
223-
<UniversalToolBar></UniversalToolBar>
225+
<UniversalToolBar :path></UniversalToolBar>
224226
<div class="max-w-full md:max-w-[768px] mx-auto">
225227
<Panel class="mt-10">
226228
<div class="flex flex-col gap-8">

0 commit comments

Comments
 (0)