2020-01-29 13:37:25 -06:00
|
|
|
<template>
|
|
|
|
<div class="eiipwacr" :class="{ focused, disabled, filled, inline }">
|
|
|
|
<div class="icon" ref="icon"><slot name="icon"></slot></div>
|
|
|
|
<div class="input" @click="focus">
|
|
|
|
<span class="label" ref="label"><slot name="label"></slot></span>
|
|
|
|
<div class="prefix" ref="prefix"><slot name="prefix"></slot></div>
|
|
|
|
<select ref="input"
|
|
|
|
v-model="v"
|
|
|
|
:required="required"
|
|
|
|
:disabled="disabled"
|
|
|
|
@focus="focused = true"
|
|
|
|
@blur="focused = false"
|
|
|
|
>
|
|
|
|
<slot></slot>
|
|
|
|
</select>
|
2020-08-22 21:05:04 -05:00
|
|
|
<div class="suffix">
|
|
|
|
<slot name="suffix">
|
2020-10-17 06:12:00 -05:00
|
|
|
<Fa :icon="faChevronDown"/>
|
2020-08-22 21:05:04 -05:00
|
|
|
</slot>
|
|
|
|
</div>
|
2020-01-29 13:37:25 -06:00
|
|
|
</div>
|
|
|
|
<div class="text"><slot name="text"></slot></div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 06:12:00 -05:00
|
|
|
import { defineComponent } from 'vue';
|
2020-08-22 21:05:04 -05:00
|
|
|
import { faChevronDown } from '@fortawesome/free-solid-svg-icons';
|
2020-01-29 13:37:25 -06:00
|
|
|
|
2020-10-17 06:12:00 -05:00
|
|
|
export default defineComponent({
|
2020-01-29 13:37:25 -06:00
|
|
|
props: {
|
|
|
|
value: {
|
|
|
|
required: false
|
|
|
|
},
|
|
|
|
required: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false
|
|
|
|
},
|
|
|
|
disabled: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false
|
|
|
|
},
|
|
|
|
inline: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2020-08-22 21:05:04 -05:00
|
|
|
focused: false,
|
|
|
|
faChevronDown,
|
2020-01-29 13:37:25 -06:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
v: {
|
|
|
|
get() {
|
|
|
|
return this.value;
|
|
|
|
},
|
|
|
|
set(v) {
|
2020-10-17 06:12:00 -05:00
|
|
|
this.$emit('update:value', v);
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
},
|
|
|
|
filled(): boolean {
|
2020-02-19 11:40:53 -06:00
|
|
|
return true;
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
if (this.$refs.prefix) {
|
|
|
|
this.$refs.label.style.left = (this.$refs.prefix.offsetLeft + this.$refs.prefix.offsetWidth) + 'px';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
focus() {
|
|
|
|
this.$refs.input.focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.eiipwacr {
|
|
|
|
position: relative;
|
|
|
|
margin: 32px 0;
|
|
|
|
|
2020-02-13 10:24:05 -06:00
|
|
|
&:not(.inline):first-child {
|
|
|
|
margin-top: 8px;
|
|
|
|
}
|
|
|
|
|
2020-02-16 15:39:41 -06:00
|
|
|
&:not(.inline):last-child {
|
|
|
|
margin-bottom: 8px;
|
|
|
|
}
|
|
|
|
|
2020-01-29 13:37:25 -06:00
|
|
|
> .icon {
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 24px;
|
|
|
|
text-align: center;
|
|
|
|
line-height: 32px;
|
|
|
|
|
|
|
|
&:not(:empty) + .input {
|
|
|
|
margin-left: 28px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .input {
|
|
|
|
display: flex;
|
2020-02-19 11:40:53 -06:00
|
|
|
position: relative;
|
2020-01-29 13:37:25 -06:00
|
|
|
|
|
|
|
&:before {
|
|
|
|
content: '';
|
|
|
|
display: block;
|
|
|
|
position: absolute;
|
|
|
|
bottom: 0;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
height: 1px;
|
|
|
|
background: var(--inputBorder);
|
|
|
|
}
|
|
|
|
|
|
|
|
&:after {
|
|
|
|
content: '';
|
|
|
|
display: block;
|
|
|
|
position: absolute;
|
|
|
|
bottom: 0;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
height: 2px;
|
|
|
|
background: var(--accent);
|
|
|
|
opacity: 0;
|
|
|
|
transform: scaleX(0.12);
|
|
|
|
transition: border 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
|
|
will-change: border opacity transform;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .label {
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
pointer-events: none;
|
|
|
|
transition: 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
|
|
|
|
transition-duration: 0.3s;
|
2020-07-10 20:13:11 -05:00
|
|
|
font-size: 1em;
|
2020-01-29 13:37:25 -06:00
|
|
|
line-height: 32px;
|
|
|
|
pointer-events: none;
|
|
|
|
//will-change transform
|
|
|
|
transform-origin: top left;
|
|
|
|
transform: scale(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
> select {
|
|
|
|
display: block;
|
|
|
|
flex: 1;
|
|
|
|
width: 100%;
|
|
|
|
padding: 0;
|
|
|
|
font: inherit;
|
|
|
|
font-weight: normal;
|
2020-07-10 20:13:11 -05:00
|
|
|
font-size: 1em;
|
2020-01-29 13:37:25 -06:00
|
|
|
height: 32px;
|
2020-02-21 15:40:48 -06:00
|
|
|
background: none;
|
2020-01-29 13:37:25 -06:00
|
|
|
border: none;
|
|
|
|
border-radius: 0;
|
|
|
|
outline: none;
|
|
|
|
box-shadow: none;
|
2020-08-22 21:05:04 -05:00
|
|
|
appearance: none;
|
|
|
|
-webkit-appearance: none;
|
2020-01-29 13:37:25 -06:00
|
|
|
color: var(--fg);
|
2020-03-06 07:54:23 -06:00
|
|
|
|
|
|
|
option,
|
|
|
|
optgroup {
|
2020-10-17 06:12:00 -05:00
|
|
|
color: var(--fg);
|
2020-03-06 07:54:23 -06:00
|
|
|
background: var(--bg);
|
|
|
|
}
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
> .prefix,
|
|
|
|
> .suffix {
|
|
|
|
display: block;
|
|
|
|
align-self: center;
|
|
|
|
justify-self: center;
|
2020-07-10 20:13:11 -05:00
|
|
|
font-size: 1em;
|
2020-01-29 13:37:25 -06:00
|
|
|
line-height: 32px;
|
2020-08-22 21:05:04 -05:00
|
|
|
color: var(--inputLabel);
|
2020-01-29 13:37:25 -06:00
|
|
|
pointer-events: none;
|
|
|
|
|
|
|
|
&:empty {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
> * {
|
|
|
|
display: block;
|
|
|
|
min-width: 16px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .prefix {
|
|
|
|
padding-right: 4px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .suffix {
|
|
|
|
padding-left: 4px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .text {
|
|
|
|
margin: 6px 0;
|
2020-08-08 23:46:19 -05:00
|
|
|
font-size: 0.8em;
|
2020-01-29 13:37:25 -06:00
|
|
|
|
|
|
|
&:empty {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
* {
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&.focused {
|
|
|
|
> .input {
|
|
|
|
&:after {
|
|
|
|
opacity: 1;
|
|
|
|
transform: scaleX(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
> .label {
|
|
|
|
color: var(--accent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&.focused,
|
|
|
|
&.filled {
|
|
|
|
> .input {
|
|
|
|
> .label {
|
|
|
|
top: -17px;
|
|
|
|
left: 0 !important;
|
|
|
|
transform: scale(0.75);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|