-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
feat: allow collapsible sidebar items #663
Conversation
Thanks a lot! As always, I'll adjust a bit on styles since I actually have the design for this toggle feature 😅 But before doing that, I would like to discuss a bit on config option! First, let's make Next, I would like to have defaults to open/closed option. So So how about we add 2 options? export interface SidebarGroup {
text: string
items: SidebarItem[]
// If `false`, toggle button is hidden.
// Default: true
collapsible?: boolean
// If `false`, collapsible group is collapsed by default
// Default: true
open?: boolean
} What do you think? |
Its
Fine. Also, lets keep |
Oh sorry for that. I was looking at VuePress v1 doc 😓 Let's go with
Gotcha. Sounds perfect 👍 |
Changed the interface to this: export interface SidebarGroup {
text: string
items: SidebarItem[]
// If `true`, toggle button is shown.
// Default: false
collapsible?: boolean
// If `true`, collapsible group is collapsed by default.
// Default: false
collapsed?: boolean
} There is a certain issue with current implementation. When a group is collapsed by default, how do we get the items height for smooth transition? Currently, I am setting |
Nice! I like
I was thinking to not have smooth animation and just pop open/close 😅 I think it's not possible (at least in an easy way). So I would say for now go with no animation... until we find out some cool technique. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've swapped the icon and adjusted the styles.
I went with no style for now. I think we can animate it by using FLIP technique, but it's a bit of work and we can always add it later 👍
@kiaking You removed |
Woops, will fix right away 👍 |
This should fix that: const collapsed = ref(props.collapsible && props.collapsed)
function toggle() {
if (!props.collapsible) return
collapsed.value = !collapsed.value
} Also, one will be able to always click the title as you've set .VPSidebarGroup.collapsible .title {
cursor: pointer;
} |
Ah... good point. Hmmm, yeah let's only add |
Fixed! 🎉 Thank you so much for your review! 🙏 |
Good catch! Thanks 😳 I'll push the fix now 👍 |
When a user enters a specific page, the corresponding SidebarGroup should open automatically (with other SidebarGroups collapsed), and even scroll to the exact sidebar location. Otherwise, a user would definitely get lost in the sidebar, when there're a lot of pages. Wondering if you could add this feature? @kiaking |
fixes #640