Skip to content

Commit 79b6fc1

Browse files
committed
feat: Minimize sidebar only if CSidebarMinimizer is inside CSidebar
1 parent b0c902c commit 79b6fc1

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/components/Sidebar/CSidebar.vue

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ export default {
1111
name: 'CSidebar',
1212
props: {
1313
fixed: Boolean,
14+
breakpoint: {
15+
type: [String, Boolean],
16+
default: 'lg',
17+
validator: val => [false, '', 'sm', 'md', 'lg', 'xl'].includes(val)
18+
},
1419
minimize: Boolean,
1520
show: {
1621
type: Boolean,
1722
default: true
1823
},
1924
mobileShow: Boolean,
2025
noHideOnMobileClick: Boolean,
21-
breakpoint: {
22-
type: [String, Boolean],
23-
default: 'lg',
24-
validator: val => [false, 'sm', 'md', 'lg', 'xl'].includes(val)
25-
},
2626
aside: Boolean,
2727
light: Boolean
2828
},
@@ -45,9 +45,12 @@ export default {
4545
mounted () {
4646
this.erd.listenTo(document.body, (el) => this.bodyWidth = el.clientWidth)
4747
48-
this.$root.$on(`c-${this.mode}-toggle-minimize`, () => {
49-
this.switchState('minimized')
48+
this.$root.$on(`c-sidebar-minimize`, (evt) => {
49+
if (this.$el.contains(evt.target)) {
50+
this.switchState('minimized')
51+
}
5052
})
53+
5154
this.$root.$on(`c-${this.mode}-toggle`, () => {
5255
if (this.isOnMobile) {
5356
this.switchState('mobileOpen')
@@ -100,9 +103,9 @@ export default {
100103
`c-sidebar-${this.light ? 'light' : 'dark'}`,
101104
{
102105
'c-sidebar-show': this.isOnMobile && this.mobileOpen,
103-
[`c-sidebar-${this.breakpoint}-show`]: this.open,
106+
[`c-sidebar-${this.breakpoint}-show`]: this.open && this.breakpoint,
104107
'c-sidebar-fixed': this.fixed,
105-
'c-sidebar-minimized': this.minimized,
108+
'c-sidebar-minimized': this.minimized && !this.isOnMobile,
106109
'c-sidebar-right': this.aside
107110
}
108111
]

src/components/Sidebar/CSidebarMinimizer.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<button
33
class="c-sidebar-minimizer"
44
type="button"
5-
@click="$root.$emit('c-sidebar-toggle-minimize')"
5+
@click="$root.$emit('c-sidebar-minimize', $event)"
66
>
77
</button>
88
</template>

0 commit comments

Comments
 (0)