2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-11-27 10:51:33 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2018-11-14 14:57:21 +00:00
|
|
|
<template>
|
|
|
|
<div class="input-wrap">
|
2019-01-02 13:20:51 +00:00
|
|
|
<div class="label-container">
|
2019-10-23 13:26:39 +01:00
|
|
|
<ErrorIcon v-if="error"/>
|
2020-05-29 16:36:59 +01:00
|
|
|
<p class="label-container__label" v-if="isLabelShown" :style="style.labelStyle">{{label}}</p>
|
|
|
|
<p class="label-container__error" v-if="error" :style="style.errorStyle">{{error}}</p>
|
2019-07-09 16:04:51 +01:00
|
|
|
</div>
|
2018-12-18 14:43:23 +00:00
|
|
|
<input
|
2019-09-26 14:36:12 +01:00
|
|
|
class="headerless-input"
|
2019-09-20 11:13:22 +01:00
|
|
|
:class="{'inputError' : error, 'password': isPassword}"
|
2018-12-18 14:43:23 +00:00
|
|
|
@input="onInput"
|
2019-07-19 14:32:01 +01:00
|
|
|
@change="onInput"
|
2018-12-18 14:43:23 +00:00
|
|
|
v-model="value"
|
2019-07-19 14:32:01 +01:00
|
|
|
:placeholder="placeholder"
|
|
|
|
:type="type"
|
2019-10-02 10:42:12 +01:00
|
|
|
:style="style.inputStyle"
|
2019-11-29 12:52:21 +00:00
|
|
|
@focus="showPasswordStrength"
|
|
|
|
@blur="hidePasswordStrength"
|
2019-10-02 10:42:12 +01:00
|
|
|
/>
|
2018-11-14 14:57:21 +00:00
|
|
|
<!--2 conditions of eye image (crossed or not) -->
|
2019-10-23 13:26:39 +01:00
|
|
|
<PasswordHiddenIcon
|
|
|
|
class="input-wrap__image"
|
|
|
|
v-if="isPasswordHiddenState"
|
|
|
|
@click="changeVision"
|
|
|
|
/>
|
|
|
|
<PasswordShownIcon
|
|
|
|
class="input-wrap__image"
|
|
|
|
v-if="isPasswordShownState"
|
|
|
|
@click="changeVision"
|
|
|
|
/>
|
2018-11-14 14:57:21 +00:00
|
|
|
<!-- end of image-->
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2019-09-13 15:58:18 +01:00
|
|
|
import { Component, Prop, Vue } from 'vue-property-decorator';
|
2018-11-14 14:57:21 +00:00
|
|
|
|
2019-10-23 13:26:39 +01:00
|
|
|
import PasswordHiddenIcon from '@/../static/images/common/passwordHidden.svg';
|
|
|
|
import PasswordShownIcon from '@/../static/images/common/passwordShown.svg';
|
|
|
|
import ErrorIcon from '@/../static/images/register/ErrorInfo.svg';
|
|
|
|
|
2019-09-13 15:58:18 +01:00
|
|
|
// Custom input component for login page
|
2019-10-23 13:26:39 +01:00
|
|
|
@Component({
|
|
|
|
components: {
|
|
|
|
ErrorIcon,
|
|
|
|
PasswordHiddenIcon,
|
|
|
|
PasswordShownIcon,
|
|
|
|
},
|
|
|
|
})
|
2019-09-13 15:58:18 +01:00
|
|
|
export default class HeaderlessInput extends Vue {
|
|
|
|
private readonly textType: string = 'text';
|
|
|
|
private readonly passwordType: string = 'password';
|
2019-07-19 14:32:01 +01:00
|
|
|
|
2019-09-13 15:58:18 +01:00
|
|
|
private type: string = this.textType;
|
|
|
|
private isPasswordShown: boolean = false;
|
2019-07-18 14:39:39 +01:00
|
|
|
|
2019-09-13 15:58:18 +01:00
|
|
|
protected value: string = '';
|
2019-07-19 14:32:01 +01:00
|
|
|
|
2019-09-13 15:58:18 +01:00
|
|
|
@Prop({default: ''})
|
|
|
|
protected readonly label: string;
|
|
|
|
@Prop({default: 'default'})
|
|
|
|
protected readonly placeholder: string;
|
|
|
|
@Prop({default: false})
|
|
|
|
protected readonly isPassword: boolean;
|
|
|
|
@Prop({default: '48px'})
|
|
|
|
protected readonly height: string;
|
|
|
|
@Prop({default: '100%'})
|
|
|
|
protected readonly width: string;
|
|
|
|
@Prop({default: ''})
|
|
|
|
protected readonly error: string;
|
|
|
|
@Prop({default: Number.MAX_SAFE_INTEGER})
|
|
|
|
protected readonly maxSymbols: number;
|
2019-07-19 14:32:01 +01:00
|
|
|
|
2019-09-13 15:58:18 +01:00
|
|
|
@Prop({default: false})
|
|
|
|
private readonly isWhite: boolean;
|
2019-07-18 14:39:39 +01:00
|
|
|
|
2019-09-13 15:58:18 +01:00
|
|
|
public constructor() {
|
|
|
|
super();
|
2019-07-18 14:39:39 +01:00
|
|
|
|
2019-09-13 15:58:18 +01:00
|
|
|
this.type = this.isPassword ? this.passwordType : this.textType;
|
|
|
|
}
|
2019-07-18 14:39:39 +01:00
|
|
|
|
2020-02-14 15:35:10 +00:00
|
|
|
/**
|
|
|
|
* Used to set default value from parent component.
|
|
|
|
* @param value
|
|
|
|
*/
|
2019-09-13 15:58:18 +01:00
|
|
|
public setValue(value: string): void {
|
|
|
|
this.value = value;
|
|
|
|
}
|
2019-07-19 14:32:01 +01:00
|
|
|
|
2019-11-29 12:52:21 +00:00
|
|
|
public showPasswordStrength(): void {
|
|
|
|
this.$emit('showPasswordStrength');
|
|
|
|
}
|
|
|
|
|
|
|
|
public hidePasswordStrength(): void {
|
|
|
|
this.$emit('hidePasswordStrength');
|
|
|
|
}
|
|
|
|
|
2020-02-14 15:35:10 +00:00
|
|
|
/**
|
|
|
|
* triggers on input.
|
|
|
|
*/
|
2019-09-13 15:58:18 +01:00
|
|
|
public onInput({ target }): void {
|
|
|
|
if (target.value.length > this.maxSymbols) {
|
|
|
|
this.value = target.value.slice(0, this.maxSymbols);
|
|
|
|
} else {
|
|
|
|
this.value = target.value;
|
2019-07-19 14:32:01 +01:00
|
|
|
}
|
|
|
|
|
2019-09-13 15:58:18 +01:00
|
|
|
this.$emit('setData', this.value);
|
|
|
|
}
|
2019-07-19 14:32:01 +01:00
|
|
|
|
2020-02-14 15:35:10 +00:00
|
|
|
/**
|
|
|
|
* Triggers input type between text and password to show/hide symbols.
|
|
|
|
*/
|
2019-09-20 11:13:22 +01:00
|
|
|
public changeVision(): void {
|
2019-09-13 15:58:18 +01:00
|
|
|
this.isPasswordShown = !this.isPasswordShown;
|
2020-02-14 15:35:10 +00:00
|
|
|
this.type = this.isPasswordShown ? this.textType : this.passwordType;
|
2019-07-18 14:39:39 +01:00
|
|
|
}
|
2019-09-13 15:58:18 +01:00
|
|
|
|
2019-10-02 10:42:12 +01:00
|
|
|
public get isLabelShown(): boolean {
|
|
|
|
return !!(!this.error && this.label);
|
|
|
|
}
|
|
|
|
|
|
|
|
public get isPasswordHiddenState(): boolean {
|
|
|
|
return this.isPassword && !this.isPasswordShown;
|
|
|
|
}
|
|
|
|
|
|
|
|
public get isPasswordShownState(): boolean {
|
|
|
|
return this.isPassword && this.isPasswordShown;
|
|
|
|
}
|
|
|
|
|
2020-02-14 15:35:10 +00:00
|
|
|
/**
|
|
|
|
* Returns style objects depends on props.
|
|
|
|
*/
|
2019-09-13 15:58:18 +01:00
|
|
|
protected get style(): object {
|
|
|
|
return {
|
|
|
|
inputStyle: {
|
|
|
|
width: this.width,
|
|
|
|
height: this.height,
|
|
|
|
},
|
|
|
|
labelStyle: {
|
|
|
|
color: this.isWhite ? 'white' : '#354049',
|
|
|
|
},
|
|
|
|
errorStyle: {
|
|
|
|
color: this.isWhite ? 'white' : '#FF5560',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2018-11-14 14:57:21 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
2019-09-26 14:36:12 +01:00
|
|
|
.input-wrap {
|
|
|
|
position: relative;
|
|
|
|
width: 100%;
|
2019-10-28 15:59:19 +00:00
|
|
|
font-family: 'font_regular', sans-serif;
|
2019-10-02 10:42:12 +01:00
|
|
|
|
2019-09-26 14:36:12 +01:00
|
|
|
&__image {
|
|
|
|
position: absolute;
|
|
|
|
right: 25px;
|
|
|
|
bottom: 5px;
|
|
|
|
transform: translateY(-50%);
|
|
|
|
z-index: 20;
|
|
|
|
cursor: pointer;
|
2019-10-02 10:42:12 +01:00
|
|
|
|
2019-09-26 14:36:12 +01:00
|
|
|
&:hover .input-wrap__image__path {
|
2019-10-28 15:59:19 +00:00
|
|
|
fill: #2683ff !important;
|
2019-09-26 14:36:12 +01:00
|
|
|
}
|
|
|
|
}
|
2019-01-02 13:20:51 +00:00
|
|
|
}
|
2019-09-26 14:36:12 +01:00
|
|
|
|
2019-07-10 10:55:40 +01:00
|
|
|
.label-container {
|
|
|
|
display: flex;
|
|
|
|
justify-content: flex-start;
|
|
|
|
align-items: flex-end;
|
|
|
|
padding-bottom: 8px;
|
|
|
|
flex-direction: row;
|
2019-09-26 14:36:12 +01:00
|
|
|
|
|
|
|
&__label {
|
|
|
|
font-size: 16px;
|
|
|
|
line-height: 21px;
|
|
|
|
color: #354049;
|
2019-07-10 10:55:40 +01:00
|
|
|
margin-bottom: 0;
|
|
|
|
}
|
2019-09-26 14:36:12 +01:00
|
|
|
|
2019-07-10 10:55:40 +01:00
|
|
|
&__add-label {
|
|
|
|
margin-left: 5px;
|
|
|
|
font-size: 16px;
|
|
|
|
line-height: 21px;
|
|
|
|
color: rgba(56, 75, 101, 0.4);
|
|
|
|
}
|
2019-09-26 14:36:12 +01:00
|
|
|
|
2019-07-10 10:55:40 +01:00
|
|
|
&__error {
|
2019-09-26 14:36:12 +01:00
|
|
|
font-size: 16px;
|
|
|
|
margin: 18px 0 0 10px;
|
2019-07-10 10:55:40 +01:00
|
|
|
}
|
|
|
|
}
|
2019-09-26 14:36:12 +01:00
|
|
|
|
|
|
|
.headerless-input {
|
|
|
|
font-size: 16px;
|
|
|
|
line-height: 21px;
|
|
|
|
resize: none;
|
|
|
|
height: 46px;
|
|
|
|
padding: 0 30px 0 0;
|
|
|
|
width: calc(100% - 30px) !important;
|
|
|
|
text-indent: 20px;
|
|
|
|
border: 1px solid rgba(56, 75, 101, 0.4);
|
|
|
|
border-radius: 6px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.headerless-input::placeholder {
|
2019-10-28 15:59:19 +00:00
|
|
|
color: #384b65;
|
2019-09-26 14:36:12 +01:00
|
|
|
opacity: 0.4;
|
|
|
|
}
|
|
|
|
|
|
|
|
.inputError::placeholder {
|
2019-10-28 15:59:19 +00:00
|
|
|
color: #eb5757;
|
2019-09-26 14:36:12 +01:00
|
|
|
opacity: 0.4;
|
|
|
|
}
|
|
|
|
|
2019-07-10 10:55:40 +01:00
|
|
|
.error {
|
2019-10-28 15:59:19 +00:00
|
|
|
color: #ff5560;
|
2019-01-02 13:20:51 +00:00
|
|
|
margin-left: 10px;
|
|
|
|
}
|
2019-09-20 11:13:22 +01:00
|
|
|
|
|
|
|
.password {
|
|
|
|
width: calc(100% - 75px) !important;
|
|
|
|
padding-right: 75px;
|
|
|
|
}
|
2018-11-14 14:57:21 +00:00
|
|
|
</style>
|