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-05 15:26:18 +00:00
|
|
|
<template>
|
2018-11-19 15:32:50 +00:00
|
|
|
<div class="input-container">
|
2019-07-09 16:04:51 +01:00
|
|
|
<div v-if="!isOptional" class="label-container">
|
|
|
|
<img v-if="error" src="../../../static/images/register/ErrorInfo.svg"/>
|
|
|
|
<h3 v-if="!error">{{label}}</h3>
|
|
|
|
<h3 v-if="!error" class="label-container__add-label">{{additionalLabel}}</h3>
|
|
|
|
<h3 class="label-container__error" v-if="error">{{error}}</h3>
|
|
|
|
</div>
|
|
|
|
<div v-if="isOptional" class="optional-label-container">
|
|
|
|
<h3>{{label}}</h3>
|
|
|
|
<h4>Optional</h4>
|
|
|
|
</div>
|
|
|
|
<textarea
|
2018-11-30 15:49:14 +00:00
|
|
|
v-if="isMultiline"
|
|
|
|
:id="this.$props.label"
|
|
|
|
:placeholder="this.$props.placeholder"
|
|
|
|
:style="style"
|
|
|
|
:rows="5"
|
|
|
|
:cols="40"
|
|
|
|
wrap="hard"
|
2019-07-09 16:04:51 +01:00
|
|
|
v-model.lazy="value"
|
|
|
|
@change="onInput"
|
2018-11-30 15:49:14 +00:00
|
|
|
@input="onInput">
|
2019-07-09 16:04:51 +01:00
|
|
|
</textarea>
|
|
|
|
<input
|
2018-11-30 15:49:14 +00:00
|
|
|
v-if="!isMultiline"
|
|
|
|
:id="this.$props.label"
|
|
|
|
:placeholder="this.$props.placeholder"
|
|
|
|
v-bind:type="[isPassword ? 'password': 'text']"
|
|
|
|
v-model.lazy="value"
|
|
|
|
@change="onInput"
|
|
|
|
@input="onInput"
|
|
|
|
:style="style"/>
|
2019-07-09 16:04:51 +01:00
|
|
|
</div>
|
2018-11-05 15:26:18 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2019-07-08 14:45:25 +01:00
|
|
|
import { Component, Vue } from 'vue-property-decorator';
|
2018-11-05 15:26:18 +00:00
|
|
|
|
2019-07-08 14:45:25 +01:00
|
|
|
// Custom input component with labeled header
|
|
|
|
@Component({
|
2018-12-18 14:43:23 +00:00
|
|
|
data: function () {
|
|
|
|
return {
|
|
|
|
value: this.$props.initValue ? this.$props.initValue : '',
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
// Emits data to parent component
|
|
|
|
onInput() {
|
|
|
|
this.$emit('setData', this.$data.value);
|
|
|
|
},
|
|
|
|
setValue(value: string) {
|
|
|
|
this.$data.value = value;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
initValue: {
|
|
|
|
type: String,
|
|
|
|
},
|
|
|
|
label: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
additionalLabel: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
error: {
|
|
|
|
type: String
|
2018-11-30 15:49:14 +00:00
|
|
|
},
|
2018-12-18 14:43:23 +00:00
|
|
|
placeholder: {
|
|
|
|
type: String,
|
|
|
|
default: 'default'
|
2018-11-30 15:49:14 +00:00
|
|
|
},
|
2018-12-18 14:43:23 +00:00
|
|
|
isOptional: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
2018-11-30 15:49:14 +00:00
|
|
|
},
|
2018-12-18 14:43:23 +00:00
|
|
|
isMultiline: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
isPassword: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
height: {
|
|
|
|
type: String,
|
|
|
|
default: '48px'
|
|
|
|
},
|
|
|
|
width: {
|
|
|
|
type: String,
|
|
|
|
default: '100%'
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
style: function () {
|
|
|
|
return {width: this.$props.width, height: this.$props.height};
|
2018-11-30 15:49:14 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-08 14:45:25 +01:00
|
|
|
})
|
2019-01-03 15:05:22 +00:00
|
|
|
|
2019-07-08 14:45:25 +01:00
|
|
|
export default class HeaderedInput extends Vue {}
|
2018-11-05 15:26:18 +00:00
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
2019-07-10 10:55:40 +01:00
|
|
|
.input-container {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
align-items: flex-start;
|
|
|
|
margin-top: 10px;
|
|
|
|
width: 48%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.label-container {
|
|
|
|
display: flex;
|
|
|
|
justify-content: flex-start;
|
|
|
|
flex-direction: row;
|
|
|
|
|
|
|
|
&__add-label {
|
|
|
|
margin-left: 5px;
|
|
|
|
font-family: 'font_regular';
|
|
|
|
font-size: 16px;
|
|
|
|
line-height: 21px;
|
|
|
|
color: rgba(56, 75, 101, 0.4);
|
|
|
|
}
|
|
|
|
|
|
|
|
&__error {
|
|
|
|
color: #FF5560;
|
|
|
|
margin-left: 10px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.optional-label-container {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
justify-content: space-between;
|
|
|
|
align-items: center;
|
|
|
|
width: 100%;
|
|
|
|
|
|
|
|
h4 {
|
|
|
|
font-family: 'font_regular';
|
|
|
|
font-size: 16px;
|
|
|
|
line-height: 21px;
|
|
|
|
color: #AFB7C1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
input,
|
|
|
|
textarea {
|
|
|
|
font-family: 'font_regular';
|
|
|
|
font-size: 16px;
|
|
|
|
line-height: 21px;
|
|
|
|
resize: none;
|
|
|
|
height: 48px;
|
|
|
|
width: 100%;
|
|
|
|
text-indent: 20px;
|
|
|
|
border-color: rgba(56, 75, 101, 0.4);
|
|
|
|
border-radius: 6px;
|
|
|
|
outline: none;
|
|
|
|
box-shadow: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
textarea {
|
|
|
|
padding-top: 20px;
|
|
|
|
}
|
|
|
|
|
|
|
|
h3 {
|
|
|
|
font-family: 'font_regular';
|
|
|
|
font-size: 16px;
|
|
|
|
line-height: 21px;
|
|
|
|
color: #354049;
|
|
|
|
}
|
2018-11-05 15:26:18 +00:00
|
|
|
</style>
|