Skip to content
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

fix: 🐛 update sidebar styling #23

Merged
merged 3 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/components/sidebar/AppSidebar.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<script setup lang="ts">
import { Icon } from "@iconify/vue";
import type { MenuOption } from "naive-ui";
import type { MenuInst, MenuOption } from "naive-ui";
import { NLayoutSider, NMenu, NSpace } from "naive-ui";
import { computed, h } from "vue";
// import {ref} from "vue/dist/vue";
import { RouterLink, useRoute, useRouter } from "vue-router";

import { useSidebarStore } from "@/stores/sidebar";
Expand Down Expand Up @@ -380,6 +381,20 @@ const defaultExpandedKeys = computed(() => {
}
return [];
});

const selectedKeyRef = ref("1");
const menuInstRef = ref<MenuInst | null>(null);

const selectAndExpand = (key: string) => {
selectedKeyRef.value = key;
menuInstRef.value?.showOption(key);
};

router.beforeEach((to, from) => {
if (typeof to.name !== "string") return;
const name: string = to.meta && to.meta.menuItem ? (to.meta.menuItem as string) : to.name;
selectAndExpand(name);
});
</script>

<template>
Expand All @@ -397,6 +412,8 @@ const defaultExpandedKeys = computed(() => {
<n-space vertical justify="space-between" class="h-full">
<div class="flex flex-col justify-start divide-y">
<n-menu
ref="menuInstRef"
v-model:value="selectedKeyRef"
:collapsed-width="64"
:collapsed-icon-size="22"
:default-expanded-keys="defaultExpandedKeys"
Expand All @@ -407,6 +424,8 @@ const defaultExpandedKeys = computed(() => {
</div>

<n-menu
ref="menuInstRef"
v-model:value="selectedKeyRef"
:collapsed-width="64"
:collapsed-icon-size="22"
:collapsed="sidebarCollapsed"
Expand Down
18 changes: 17 additions & 1 deletion src/components/sidebar/DatasetSidebar.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { Icon } from "@iconify/vue";
import type { MenuOption } from "naive-ui";
import type { MenuInst, MenuOption } from "naive-ui";
import { NLayoutSider, NMenu, NSpace } from "naive-ui";
import { computed, h, ref } from "vue";
import { useRoute, useRouter } from "vue-router";
Expand Down Expand Up @@ -197,6 +197,20 @@ const showSidebar = computed(() => {

return false;
});

const selectedKeyRef = ref("1");
const menuInstRef = ref<MenuInst | null>(null);

const selectAndExpand = (key: string) => {
selectedKeyRef.value = key;
menuInstRef.value?.showOption(key);
};

router.beforeEach((to, from) => {
if (typeof to.name !== "string") return;
const name: string = to.meta && to.meta.menuItem ? (to.meta.menuItem as string) : to.name;
selectAndExpand(name);
});
</script>

<template>
Expand All @@ -213,6 +227,8 @@ const showSidebar = computed(() => {
>
<n-space vertical justify="space-between" class="h-full">
<n-menu
ref="menuInstRef"
v-model:value="selectedKeyRef"
:collapsed-width="64"
:collapsed-icon-size="22"
:default-expanded-keys="['dataset:metadata']"
Expand Down
11 changes: 11 additions & 0 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ const router = createRouter({
name: "studies:new-study",
path: "new",
component: NewStudy,
meta: { menuItem: "studies:all-studies" },
},
],
},
Expand Down Expand Up @@ -140,6 +141,7 @@ const router = createRouter({
name: "study:add-participant",
path: "add",
component: AddParticipant,
meta: { menuItem: "study:participants" },
},
],
},
Expand Down Expand Up @@ -170,6 +172,7 @@ const router = createRouter({
name: "dataset:new",
path: "new",
component: NewDataset,
meta: { menuItem: "study:all-datasets" },
},
],
},
Expand Down Expand Up @@ -283,6 +286,7 @@ const router = createRouter({
name: "dataset:publish:versions:new",
path: "new",
component: NewVersion,
meta: { menuItem: "dataset:publish:versions" },
},
{
path: ":versionId",
Expand All @@ -291,31 +295,37 @@ const router = createRouter({
name: "dataset:publish:version:participants",
path: "participants",
component: PublishSelectParticipants,
meta: { menuItem: "dataset:publish:versions" },
},
{
name: "dataset:publish:version:study-metadata",
path: "study-metadata",
component: PublishStudyMetadata,
meta: { menuItem: "dataset:publish:versions" },
},
{
name: "dataset:publish:version:dataset-metadata",
path: "dataset-metadata",
component: PublishDatasetMetadata,
meta: { menuItem: "dataset:publish:versions" },
},
{
name: "dataset:publish:version:changelog",
path: "changelog",
component: PublishChangelog,
meta: { menuItem: "dataset:publish:versions" },
},
{
name: "dataset:publish:version:readme",
path: "additional-readme",
component: PublishReadme,
meta: { menuItem: "dataset:publish:versions" },
},
{
name: "dataset:publish:version:summary",
path: "summary",
component: PublishSummary,
meta: { menuItem: "dataset:publish:versions" },
},
],
},
Expand Down Expand Up @@ -433,6 +443,7 @@ const router = createRouter({
name: "all-settings",
path: "/settings",
component: AllSettings,
meta: { menuItem: "settings" },
},
{
name: "help",
Expand Down
Loading