Last active
July 8, 2019 10:25
-
-
Save SteinRobert/2d705069a2d21be2c8cf03e284a0a4b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template> | |
| <div @click="$emit('update:active', !active)"> | |
| <label :for="id">{{ label }}</label> | |
| <input type="checkbox" :name="name" :id="id" :checked="active"> | |
| </div> | |
| </template> | |
| <script> | |
| export default { | |
| name: 'Toggle', | |
| props: { | |
| name: { | |
| type: String, | |
| default: '' | |
| }, | |
| id: { | |
| type: String, | |
| default: () => { | |
| // Taken from https://gist.github.com/gordonbrander/2230317 | |
| return 'toggle-' + Math.random().toString(36).substr(2, 9); | |
| } | |
| }, | |
| label: { | |
| type: String, | |
| default: '' | |
| }, | |
| active: { | |
| type: Boolean, | |
| default: false | |
| } | |
| } | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment