summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_shared/components/settings/settings_block.vue
blob: 92ae4575c52c58dc72cd04623542346cf95d827f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<script>
import { GlButton } from '@gitlab/ui';
import { __ } from '~/locale';

export default {
  components: { GlButton },
  props: {
    slideAnimated: {
      type: Boolean,
      default: true,
      required: false,
    },
    defaultExpanded: {
      type: Boolean,
      default: false,
      required: false,
    },
  },
  data() {
    return {
      sectionExpanded: false,
    };
  },
  computed: {
    expanded() {
      return this.defaultExpanded || this.sectionExpanded;
    },
    toggleText() {
      return this.expanded ? __('Collapse') : __('Expand');
    },
  },
};
</script>

<template>
  <section class="settings" :class="{ 'no-animate': !slideAnimated, expanded }">
    <div class="settings-header">
      <h4><slot name="title"></slot></h4>
      <gl-button @click="sectionExpanded = !sectionExpanded">
        {{ toggleText }}
      </gl-button>
      <p>
        <slot name="description"></slot>
      </p>
    </div>
    <div class="settings-content">
      <slot></slot>
    </div>
  </section>
</template>