<template>
  <form-field>
    <label v-if="label">{{label}}</label>
    <input :value="modelValue" ref="field" @input="handleInput" :type="inputType" />
  </form-field>
</template>

<script>
import FormField from "./FormField.vue";
export default {
  props: {
    label: String,
    modelValue: String,
    password: Boolean,
  },
  computed: {
    inputType() {
      return this.password ? "password" : "text";
    },
  },
  components: { FormField },
  methods: {
    handleInput() {
      this.$emit("update:modelValue", this.$refs.field.value);
    },
  },
};
</script>

<style scoped>
input {
  transition: all 0.2s;
  color: #fff;
  background-color: transparent;
  font-weight: bold;
  outline: none;
  border: none;
  border-bottom: 1px solid #555;
  overflow: hidden;
  flex: 1;
  padding: 8px 15px;
}
input:focus {
  transition: all 0.2s;
  border-bottom: 1px solid #336699;
}
</style>
