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

68 lines
1.3 KiB
Vue
Raw Normal View History

2018-05-09 12:01:36 +05:30
<script>
2020-05-24 23:13:21 +05:30
import { mapActions } from 'vuex';
2018-05-09 12:01:36 +05:30
import PanelResizer from '~/vue_shared/components/panel_resizer.vue';
2020-06-23 00:09:42 +05:30
import { SIDEBAR_MIN_WIDTH } from '../constants';
2018-05-09 12:01:36 +05:30
export default {
components: {
PanelResizer,
},
props: {
initialWidth: {
type: Number,
required: true,
},
minSize: {
type: Number,
required: false,
2020-06-23 00:09:42 +05:30
default: SIDEBAR_MIN_WIDTH,
2018-05-09 12:01:36 +05:30
},
side: {
type: String,
required: true,
},
2020-06-23 00:09:42 +05:30
resizable: {
type: Boolean,
required: false,
default: true,
},
2018-05-09 12:01:36 +05:30
},
data() {
return {
width: this.initialWidth,
};
},
computed: {
panelStyle() {
2020-06-23 00:09:42 +05:30
if (this.resizable) {
2018-05-09 12:01:36 +05:30
return {
width: `${this.width}px`,
};
}
return {};
},
},
methods: {
2020-05-24 23:13:21 +05:30
...mapActions(['setResizingStatus']),
2018-05-09 12:01:36 +05:30
},
maxSize: window.innerWidth / 2,
};
</script>
<template>
2020-06-23 00:09:42 +05:30
<div class="gl-relative" :style="panelStyle">
2018-05-09 12:01:36 +05:30
<slot></slot>
<panel-resizer
2020-06-23 00:09:42 +05:30
v-show="resizable"
2018-05-09 12:01:36 +05:30
:size.sync="width"
:start-size="initialWidth"
:min-size="minSize"
:max-size="$options.maxSize"
2018-11-08 19:23:39 +05:30
:side="side === 'right' ? 'left' : 'right'"
2019-03-02 22:35:43 +05:30
@resize-start="setResizingStatus(true)"
@resize-end="setResizingStatus(false)"
2018-05-09 12:01:36 +05:30
/>
</div>
</template>