Skip to content

Commit a0a94c1

Browse files
committed
highlight drawer item based on route
2 parents 9eab392 + d7244f0 commit a0a94c1

File tree

3 files changed

+104
-52
lines changed

3 files changed

+104
-52
lines changed

package-lock.json

Lines changed: 68 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@
3737
"@progress/kendo-vue-form": "^3.4.0",
3838
"@progress/kendo-vue-indicators": "^3.4.0",
3939
"@progress/kendo-vue-inputs": "^3.4.0",
40+
"@progress/kendo-vue-intl": "^3.4.3",
4041
"@progress/kendo-vue-layout": "^3.4.0",
4142
"@progress/kendo-vue-notification": "^3.4.0",
4243
"@progress/kendo-vue-popup": "^3.4.0",
44+
"@progress/kendo-vue-progressbars": "^3.4.3",
4345
"@rollup/plugin-graphql": "^1.1.0",
4446
"@rushstack/eslint-patch": "^1.1.0",
4547
"@types/jsdom": "^16.2.14",

src/components/TheDrawer.vue

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,58 @@
11
<script setup lang="ts">
22
import { Drawer, DrawerContent } from "@progress/kendo-vue-layout";
33
import { useLocalStorage } from "@vueuse/core";
4-
import { useRouter } from "vue-router";
4+
import { useRouter, useRoute } from "vue-router";
55
66
import { computed, ref } from "vue";
77
88
const router = useRouter();
9+
const route = useRoute();
910
const selectedId = ref(0);
1011
1112
const expanded = useLocalStorage("vue-forge-drawer-expanded", true);
1213
const expandedIcon = computed(() =>
1314
expanded.value ? "k-i-arrow-chevron-left" : "k-i-arrow-chevron-right"
1415
);
15-
const items = computed(() => [
16-
{
17-
text: "Boards",
18-
icon: "k-i-set-column-position",
19-
selected: true,
20-
data: {
21-
path: "/",
16+
const items = computed(() =>
17+
[
18+
{
19+
text: "Boards",
20+
icon: "k-i-set-column-position",
21+
data: {
22+
path: "/boards",
23+
},
2224
},
23-
},
24-
{
25-
text: "Templates",
26-
icon: "k-i-border-left",
27-
data: {
28-
path: "/templates",
25+
{
26+
text: "Templates",
27+
icon: "k-i-border-left",
28+
data: {
29+
path: "/templates",
30+
},
2931
},
30-
},
31-
{
32-
text: "Settings",
33-
icon: "k-i-gear",
34-
data: {
35-
path: "/settings",
32+
{
33+
text: "Settings",
34+
icon: "k-i-gear",
35+
data: {
36+
path: "/settings",
37+
},
3638
},
37-
},
38-
{
39-
text: "Collapse",
40-
icon: expandedIcon.value,
41-
data: {
42-
action: () => (expanded.value = !expanded.value),
39+
{
40+
text: "Collapse",
41+
icon: expandedIcon.value,
42+
data: {
43+
action: () => (expanded.value = !expanded.value),
44+
},
4345
},
44-
},
45-
]);
46+
].map((item, index) => ({
47+
...item,
48+
selected: route.path === item.data.path,
49+
}))
50+
);
4651
4752
function onSelect({ itemIndex }: { itemIndex: number }) {
4853
const item = items.value[itemIndex];
4954
if (!item) return;
55+
selectedId.value = itemIndex;
5056
if (item.data.path) router.push(item.data.path);
5157
if (typeof item.data.action === "function") item.data.action();
5258
}

0 commit comments

Comments
 (0)