<template>
  <div class="switch-label">
    <div class="label">{{label}}</div>
    <y-switch
      v-model:value="currentValue"
      @on-change="onChange"
      :size="size"
    ></y-switch>
  </div>
</template>

<script>
import YSwitch from '../Switch/switch'
export default {
  components: {
    YSwitch
  },
  props: {
    label: {
      type: String,
      default: ''
    },
    value: {
      type: Boolean,
      default: false
    },
    size: {
      type: String,
      default: '50'
    }
  },
  data () {
    return {
      currentValue: this.value
    }
  },
  watch: {
    value (val) {
      this.currentValue = val
    }
  },
  methods: {
    onChange (val) {
      this.currentValue = val
      this.$emit('update:value',val)
    }
  }
}
</script>

<style lang="scss">
@import "./switch-label.scss";
</style>