Width fix for password inputs
This commit is contained in:
@@ -1,10 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="group" :class="{ completed: value }">
|
<div class="group" :class="{ completed: value }">
|
||||||
<svg class="group__input-icon"><use v-bind="{'xlink:href':'#icon' + icon}"></use></svg>
|
<svg class="group__input-icon">
|
||||||
<input class="group__input" :type="tempType || type" @input="handleInput" v-model="inputValue"
|
<use v-bind="{ 'xlink:href': '#icon' + icon }"></use>
|
||||||
:placeholder="placeholder" @keyup.enter="submit" />
|
</svg>
|
||||||
|
<input
|
||||||
|
class="group__input"
|
||||||
|
:type="tempType || type"
|
||||||
|
@input="handleInput"
|
||||||
|
v-model="inputValue"
|
||||||
|
:placeholder="placeholder"
|
||||||
|
@keyup.enter="submit"
|
||||||
|
/>
|
||||||
|
|
||||||
<i v-if="value && type === 'password'" @click="toggleShowPassword" class="group__input-show noselect">show</i>
|
<i
|
||||||
|
v-if="value && type === 'password'"
|
||||||
|
@click="toggleShowPassword"
|
||||||
|
class="group__input-show noselect"
|
||||||
|
>{{ tempType == "password" ? "show" : "hide" }}</i
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -13,46 +26,49 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
placeholder: { type: String },
|
placeholder: { type: String },
|
||||||
icon: { type: String },
|
icon: { type: String },
|
||||||
type: { type: String, default: 'text' },
|
type: { type: String, default: "text" },
|
||||||
value: { type: String, default: undefined }
|
value: { type: String, default: undefined }
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
inputValue: this.value || undefined,
|
inputValue: this.value || undefined,
|
||||||
tempType: undefined
|
tempType: undefined
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
submit(event) {
|
submit(event) {
|
||||||
this.$emit('enter')
|
this.$emit("enter");
|
||||||
},
|
},
|
||||||
handleInput(event) {
|
handleInput(event) {
|
||||||
if (this.value !== undefined) {
|
if (this.value !== undefined) {
|
||||||
this.$emit('update:value', this.inputValue)
|
this.$emit("update:value", this.inputValue);
|
||||||
} else {
|
} else {
|
||||||
this.$emit('change', this.inputValue, event)
|
this.$emit("change", this.inputValue, event);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
toggleShowPassword() {
|
toggleShowPassword() {
|
||||||
if (this.tempType === 'text') {
|
if (this.tempType === "text") {
|
||||||
this.tempType = 'password'
|
this.tempType = "password";
|
||||||
} else {
|
} else {
|
||||||
this.tempType = 'text'
|
this.tempType = "text";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@import "./src/scss/variables";
|
@import "./src/scss/variables";
|
||||||
@import "./src/scss/media-queries";
|
@import "./src/scss/media-queries";
|
||||||
|
|
||||||
.group{
|
.group {
|
||||||
display: flex;
|
display: flex;
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
position: relative;
|
||||||
|
max-width: 35rem;
|
||||||
|
|
||||||
&:hover, &:focus {
|
&:hover,
|
||||||
|
&:focus {
|
||||||
.group__input {
|
.group__input {
|
||||||
border-color: $text-color;
|
border-color: $text-color;
|
||||||
|
|
||||||
@@ -74,7 +90,6 @@ export default {
|
|||||||
|
|
||||||
&__input {
|
&__input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 35rem;
|
|
||||||
padding: 10px 10px 10px 45px;
|
padding: 10px 10px 10px 45px;
|
||||||
outline: none;
|
outline: none;
|
||||||
background-color: $background-color-secondary;
|
background-color: $background-color-secondary;
|
||||||
@@ -85,20 +100,24 @@ export default {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
margin-left: -2.2rem !important;
|
margin-left: -2.2rem !important;
|
||||||
z-index: 3;
|
z-index: 3;
|
||||||
transition: color .5s ease, background-color .5s ease, border .5s ease;
|
transition: color 0.5s ease, background-color 0.5s ease, border 0.5s ease;
|
||||||
|
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
|
|
||||||
&-show {
|
&-show {
|
||||||
position: relative;
|
position: absolute;
|
||||||
left: -50px;
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
right: 20px;
|
||||||
z-index: 11;
|
z-index: 11;
|
||||||
margin: auto 0;
|
margin: auto 0;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color: $text-color-50;
|
color: $text-color-50;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
user-select: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user