Skip to content

Instantly share code, notes, and snippets.

@Darkmift
Last active March 5, 2021 16:30
Show Gist options
  • Save Darkmift/3617b552963c95fa3789806637f9583f to your computer and use it in GitHub Desktop.
Save Darkmift/3617b552963c95fa3789806637f9583f to your computer and use it in GitHub Desktop.
export default {
name: 'color-picker',
template: /*html*/ `
<div class="row" style="margin-bottom:0;">
<div
class="input-field col s12"
@click="openColorPicker">
<i class="material-icons prefix">color</i>
<input
type="text"
disabled
v-model="color" />
<span class="highlight"></span>
<span class="bar"></span>
<label>{{title}}</label>
<input
ref="colorInput"
type="color"
style="visibility:hidden;"
v-model="color"
@input="$emit('colorSelected',color)" />
</div>
</div>
`,
props: ['title', 'default'],
data() {
return { color: this.default || '#fff' };
},
methods: {
openColorPicker() {
this.$refs.colorInput.focus();
this.$refs.colorInput.click();
},
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment