debian-mirror-gitlab/app/assets/javascripts/ide/components/resizable_panel.vue

86 lines
1.7 KiB
Vue
Raw Normal View History

2018-05-09 12:01:36 +05:30
<script>
import { mapActions, mapState } from 'vuex';
import PanelResizer from '~/vue_shared/components/panel_resizer.vue';
export default {
components: {
PanelResizer,
},
props: {
collapsible: {
type: Boolean,
required: true,
},
initialWidth: {
type: Number,
required: true,
},
minSize: {
type: Number,
required: false,
default: 340,
},
side: {
type: String,
required: true,
},
},
data() {
return {
width: this.initialWidth,
};
},
computed: {
...mapState({
collapsed(state) {
return state[`${this.side}PanelCollapsed`];
},
}),
panelStyle() {
if (!this.collapsed) {
return {
width: `${this.width}px`,
};
}
return {};
},
},
methods: {
...mapActions(['setPanelCollapsedStatus', 'setResizingStatus']),
toggleFullbarCollapsed() {
if (this.collapsed && this.collapsible) {
this.setPanelCollapsedStatus({
side: this.side,
collapsed: !this.collapsed,
});
}
},
},
maxSize: window.innerWidth / 2,
};
</script>
<template>
<div
:class="{
'is-collapsed': collapsed && collapsible,
}"
:style="panelStyle"
2018-11-08 19:23:39 +05:30
class="multi-file-commit-panel"
2018-05-09 12:01:36 +05:30
@click="toggleFullbarCollapsed"
>
<slot></slot>
<panel-resizer
:size.sync="width"
:enabled="!collapsed"
:start-size="initialWidth"
:min-size="minSize"
:max-size="$options.maxSize"
2018-11-08 19:23:39 +05:30
:side="side === 'right' ? 'left' : 'right'"
2019-02-13 22:33:31 +05:30
@resize-start="setResizingStatus(true);"
@resize-end="setResizingStatus(false);"
2018-05-09 12:01:36 +05:30
/>
</div>
</template>