From 4ad0d8d3c216e5333f199a29ea37c2c51c8e4c9b Mon Sep 17 00:00:00 2001 From: Thang Minh Vu Date: Sat, 11 May 2019 17:44:26 +0900 Subject: [PATCH] feat: toggle sidebar children (#223) * Create SidebarItem component * Add collapsable attribute * Add arrow icon * Update document * Hide collapsable by default * Automatically open collapsed item by path * Handle open state in parent * Update index.js * Update SidebarItem.vue --- src/components/Sidebar.vue | 162 +++++--------------- src/components/SidebarItem.vue | 195 +++++++++++++++++++++++++ website/docs/guide/customization.md | 1 + website/docs/options.md | 1 + website/docs/zh/guide/customization.md | 1 + website/index.js | 3 + 6 files changed, 239 insertions(+), 124 deletions(-) create mode 100644 src/components/SidebarItem.vue diff --git a/src/components/Sidebar.vue b/src/components/Sidebar.vue index 6304153c..4affe906 100644 --- a/src/components/Sidebar.vue +++ b/src/components/Sidebar.vue @@ -1,7 +1,6 @@ + + diff --git a/website/docs/guide/customization.md b/website/docs/guide/customization.md index 82db7a4f..75d92459 100644 --- a/website/docs/guide/customization.md +++ b/website/docs/guide/customization.md @@ -50,6 +50,7 @@ new Docute({ // A sidebar item, with child links { title: 'Guide', // Optional + collapsable: true, // Optional children: [ { title: 'Getting Started', diff --git a/website/docs/options.md b/website/docs/options.md index 50afac0f..7cb5a4b6 100644 --- a/website/docs/options.md +++ b/website/docs/options.md @@ -49,6 +49,7 @@ An array of navigation items to display at sidebar. ```ts interface SidebarItem { title?: string + collapsable?: boolean children: Array } diff --git a/website/docs/zh/guide/customization.md b/website/docs/zh/guide/customization.md index dc283758..dc671c3b 100644 --- a/website/docs/zh/guide/customization.md +++ b/website/docs/zh/guide/customization.md @@ -47,6 +47,7 @@ new Docute({ sidebar: [ { title: 'Guide', // 可选的 + collapsable: true, // 可选的 children: [ { title: 'Getting Started', diff --git a/website/index.js b/website/index.js index 6ee0ce14..93f84c0d 100644 --- a/website/index.js +++ b/website/index.js @@ -135,6 +135,7 @@ new Docute({ }, { title: 'Advanced', + collapsable: true, children: [ { title: 'Use With Bundlers', @@ -148,6 +149,7 @@ new Docute({ }, { title: 'References', + collapsable: true, children: [ { title: 'Options', @@ -165,6 +167,7 @@ new Docute({ }, { title: 'Misc', + collapsable: true, children: [ { title: 'Credits',