Sha256: ce8627a13c37eac5509e7dd9a574921fbb93eb0236a0153b9dc4982e5e9107dc

Contents?: true

Size: 1.38 KB

Versions: 17

Compression:

Stored size: 1.38 KB

Contents

<template>
  <div>
    <label :for="name" class="flex items-center cursor-pointer">
      <div class="font-semibold text-gray-800">
        {{ label }}
      </div>
      <div class="ml-auto relative">
        <input :id="name" type="checkbox" class="hidden" v-model="localValue" />
        <div class="toggle__line w-10 h-6 bg-gray-200 rounded-full"></div>
        <div
          class="toggle__dot absolute w-5 h-5 bg-white rounded-full inset-y-0 left-0 transition duration-200 ease-in-out"
        ></div>
      </div>
    </label>
    <div class="text-gray-600 text-sm" v-if="hasPlaceholder">
      {{ placeholder }}
    </div>
  </div>
</template>

<script>
export default {
  name: 'CheckboxInput',
  props: {
    label: { type: String, default: 'Label' },
    name: { type: String, default: 'text' },
    value: { type: Boolean, default: false },
    placeholder: { type: String, default: null },
  },
  computed: {
    localValue: {
      get() {
        return this.value
      },
      set(value) {
        this.$emit('input', value)
      },
    },
    hasPlaceholder() {
      return !this.isBlank(this.placeholder)
    },
  },
}
</script>

<style scoped>
.toggle__dot {
  top: theme('spacing.1/2');
  left: theme('spacing.1/2');
}

input:checked ~ .toggle__dot {
  transform: translateX(calc(100% - theme('spacing.1')));
}

input:checked ~ .toggle__line {
  @apply bg-editor-primary;
}
</style>

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
maglevcms-1.4.0 app/frontend/editor/components/kit/checkbox-input.vue
maglevcms-1.3.0 app/frontend/editor/components/kit/checkbox-input.vue
maglevcms-1.2.2 app/frontend/editor/components/kit/checkbox-input.vue
maglevcms-1.2.1 app/frontend/editor/components/kit/checkbox-input.vue
maglevcms-1.2.0 app/frontend/editor/components/kit/checkbox-input.vue
maglevcms-1.1.7 app/frontend/editor/components/kit/checkbox-input.vue
maglevcms-1.1.6 app/frontend/editor/components/kit/checkbox-input.vue
maglevcms-1.1.5 app/frontend/editor/components/kit/checkbox-input.vue
maglevcms-1.1.4 app/frontend/editor/components/kit/checkbox-input.vue
maglevcms-1.1.3 app/frontend/editor/components/kit/checkbox-input.vue
maglevcms-1.1.2 app/frontend/editor/components/kit/checkbox-input.vue
maglevcms-1.1.1 app/frontend/editor/components/kit/checkbox-input.vue
maglevcms-1.1.0 app/frontend/editor/components/kit/checkbox-input.vue
maglevcms-1.0.0 app/javascript/editor/components/kit/checkbox-input.vue
maglevcms-1.0.0.rc3 app/javascript/editor/components/kit/checkbox-input.vue
maglevcms-1.0.0.rc2 app/javascript/editor/components/kit/checkbox-input.vue
maglevcms-1.0.0.rc1 app/javascript/editor/components/kit/checkbox-input.vue