2022-02-08 04:04:45 +00:00
|
|
|
<template>
|
|
|
|
<form-field>
|
2022-02-12 22:04:32 +00:00
|
|
|
<label v-if="label" :class="{error: isError}">{{label}}</label>
|
|
|
|
<input :value="modelValue" ref="field" @input="handleInput" :type="inputType" :class="{error: isError}" />
|
2022-02-08 04:04:45 +00:00
|
|
|
</form-field>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import FormField from "./FormField.vue";
|
|
|
|
export default {
|
|
|
|
props: {
|
2022-02-12 22:04:32 +00:00
|
|
|
required: Boolean,
|
2022-02-08 04:04:45 +00:00
|
|
|
label: String,
|
|
|
|
modelValue: String,
|
|
|
|
password: Boolean,
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
inputType() {
|
|
|
|
return this.password ? "password" : "text";
|
|
|
|
},
|
2022-02-12 22:04:32 +00:00
|
|
|
isError() {
|
|
|
|
return this.required && !this.modelValue
|
|
|
|
}
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
FormField
|
2022-02-08 04:04:45 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
handleInput() {
|
|
|
|
this.$emit("update:modelValue", this.$refs.field.value);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
input {
|
2022-02-12 06:23:07 +00:00
|
|
|
transition: all 0.2s;
|
2022-02-08 04:04:45 +00:00
|
|
|
color: #fff;
|
2022-02-12 06:23:07 +00:00
|
|
|
background-color: transparent;
|
|
|
|
font-weight: bold;
|
2022-02-08 04:04:45 +00:00
|
|
|
outline: none;
|
2022-02-12 06:23:07 +00:00
|
|
|
border: none;
|
|
|
|
border-bottom: 1px solid #555;
|
|
|
|
overflow: hidden;
|
2022-02-08 04:04:45 +00:00
|
|
|
flex: 1;
|
|
|
|
padding: 8px 15px;
|
|
|
|
}
|
2022-02-12 06:23:07 +00:00
|
|
|
input:focus {
|
|
|
|
transition: all 0.2s;
|
|
|
|
border-bottom: 1px solid #336699;
|
2022-02-12 22:04:32 +00:00
|
|
|
}
|
|
|
|
input.error {
|
|
|
|
border-bottom: 1px solid #900;
|
|
|
|
}
|
|
|
|
input.error:focus {
|
|
|
|
border-bottom: 1px solid #c00;
|
|
|
|
}
|
|
|
|
label.error {
|
|
|
|
color: #eee;
|
2022-02-12 06:23:07 +00:00
|
|
|
}
|
2022-02-08 04:04:45 +00:00
|
|
|
</style>
|