2018-11-27 10:51:33 +00:00
|
|
|
// Copyright (C) 2018 Storj Labs, Inc.
|
|
|
|
// 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">
|
|
|
|
<div v-if="!isOptional" class="label-container">
|
2018-11-14 14:00:01 +00:00
|
|
|
<img v-if="error" src="../../../static/images/register/ErrorInfo.svg"/>
|
2018-11-05 15:26:18 +00:00
|
|
|
<h3 v-if="!error">{{label}}</h3>
|
2018-11-27 13:14:10 +00:00
|
|
|
<h3 v-if="!error" class="label-container__add-label">{{additionalLabel}}</h3>
|
2018-11-19 15:32:50 +00:00
|
|
|
<h3 class="label-container__error" v-if="error">{{error}}</h3>
|
2018-11-05 15:26:18 +00:00
|
|
|
</div>
|
2018-11-19 15:32:50 +00:00
|
|
|
<div v-if="isOptional" class="optional-label-container">
|
2018-11-05 15:26:18 +00:00
|
|
|
<h3>{{label}}</h3>
|
|
|
|
<h4>Optional</h4>
|
|
|
|
</div>
|
2018-11-27 13:14:10 +00:00
|
|
|
<textarea
|
|
|
|
v-if="isMultiline"
|
|
|
|
:id="this.$props.label"
|
|
|
|
:placeholder="this.$props.placeholder"
|
|
|
|
v-model="value"
|
|
|
|
:style="style"
|
|
|
|
:rows="5"
|
|
|
|
:cols="40"
|
|
|
|
wrap="hard"
|
|
|
|
@input="onInput" >
|
|
|
|
</textarea>
|
2018-11-05 15:26:18 +00:00
|
|
|
<input
|
|
|
|
v-if="!isMultiline"
|
|
|
|
@input="onInput"
|
|
|
|
:id="this.$props.label"
|
|
|
|
:placeholder="this.$props.placeholder"
|
|
|
|
v-model="value"
|
|
|
|
v-bind:type="[isPassword ? passwordType : textType]"
|
2018-11-23 15:48:11 +00:00
|
|
|
:style="style" />
|
2018-11-05 15:26:18 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { Component, Prop, Vue } from 'vue-property-decorator';
|
|
|
|
|
|
|
|
// Custom input component with labeled header
|
|
|
|
@Component(
|
|
|
|
{
|
|
|
|
data: () => {
|
|
|
|
return {
|
|
|
|
value: "",
|
|
|
|
textType: "text",
|
|
|
|
passwordType: "password"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2018-11-14 14:57:21 +00:00
|
|
|
//emits data to parent component
|
2018-11-05 15:26:18 +00:00
|
|
|
onInput () {
|
|
|
|
this.$emit('setData', this.$data.value)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
label: {
|
|
|
|
type: String,
|
2018-11-14 14:00:01 +00:00
|
|
|
default: ""
|
|
|
|
},
|
|
|
|
additionalLabel: {
|
|
|
|
type: String,
|
|
|
|
default: ""
|
2018-11-05 15:26:18 +00:00
|
|
|
},
|
|
|
|
error: {
|
|
|
|
type: String
|
|
|
|
},
|
|
|
|
placeholder: {
|
|
|
|
type: String,
|
|
|
|
default: "default"
|
|
|
|
},
|
|
|
|
isOptional: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
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 }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
)
|
|
|
|
export default class HeaderedInput extends Vue { }
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
2018-11-19 15:32:50 +00:00
|
|
|
.input-container {
|
2018-11-05 15:26:18 +00:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
align-items: flex-start;
|
|
|
|
margin-top: 10px;
|
2018-11-23 15:48:11 +00:00
|
|
|
width: 48%;
|
2018-11-05 15:26:18 +00:00
|
|
|
}
|
2018-11-19 15:32:50 +00:00
|
|
|
.label-container {
|
2018-11-05 15:26:18 +00:00
|
|
|
display: flex;
|
|
|
|
justify-content: flex-start;
|
|
|
|
flex-direction: row;
|
2018-11-19 15:32:50 +00:00
|
|
|
|
|
|
|
&__add-label {
|
|
|
|
margin-left: 5px;
|
|
|
|
font-family: 'montserrat_regular';
|
|
|
|
font-size: 16px;
|
|
|
|
line-height: 21px;
|
|
|
|
color: rgba(56, 75, 101, 0.4);
|
|
|
|
}
|
|
|
|
|
|
|
|
&__error {
|
|
|
|
color: #FF5560;
|
|
|
|
margin-left: 10px;
|
|
|
|
}
|
2018-11-05 15:26:18 +00:00
|
|
|
}
|
2018-11-19 15:32:50 +00:00
|
|
|
.optional-label-container {
|
2018-11-05 15:26:18 +00:00
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
justify-content: space-between;
|
|
|
|
align-items: center;
|
|
|
|
width: 100%;
|
|
|
|
h4 {
|
|
|
|
font-family: 'montserrat_regular';
|
|
|
|
font-size: 16px;
|
|
|
|
line-height: 21px;
|
|
|
|
color: #AFB7C1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
input,
|
|
|
|
textarea {
|
|
|
|
font-family: 'montserrat_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;
|
|
|
|
}
|
|
|
|
textarea {
|
|
|
|
padding-top: 20px;
|
|
|
|
}
|
|
|
|
h3 {
|
|
|
|
font-family: 'montserrat_regular';
|
|
|
|
font-size: 16px;
|
|
|
|
line-height: 21px;
|
|
|
|
color: #354049;
|
|
|
|
}
|
|
|
|
</style>
|