Last active
November 23, 2018 17:09
-
-
Save plugn/07eb0c0ea7072f0c157fac3a715e4301 to your computer and use it in GitHub Desktop.
Sexy Input for Semantic-UI
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 class="ui icon input"> | |
<input | |
:placeholder="placeholder" | |
:value="value" | |
@input="onInput" | |
@blur="onBlur" | |
ref="input" | |
/><i | |
class="icon" :class="value ? 'close link' : icon" | |
@click="onClear" | |
></i> | |
</div> | |
</template> | |
<script> | |
export default { | |
name: 'InputPlus', | |
props: { | |
icon: { | |
type: String, | |
default: 'search' | |
}, | |
value: [String, Number], | |
placeholder: { | |
type: String, | |
default: 'Search...' | |
}, | |
}, | |
events: { | |
input: { | |
custom: true, | |
}, | |
blur: { | |
custom: true, | |
}, | |
}, | |
methods: { | |
onClear(e) { | |
this.$emit('input', ''); | |
}, | |
onInput(e) { | |
this.$emit('input', e.target.value); | |
}, | |
onBlur(e) { | |
this.$emit('blur', e); | |
}, | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment