WIP Переделаны селект и инпуты

This commit is contained in:
Daria Golova
2022-12-28 18:54:58 +03:00
parent 83e1588e1f
commit 9fc796c9d7
5 changed files with 116 additions and 122 deletions

View File

@@ -1,27 +1,29 @@
<template lang="pug">
.base-select.flex.justify-between.items-center.py-9px.px-4.gap-4.cursor-pointer.relative(
@click="open = !open",
:class="{'open': open, 'border-none': borderNone}",
)
.placeholder.text-base.flex.items-center(
:class="{'value-color': value.label || placeholderOpacity}"
) {{ value.label || placeholder }}
.flex.items-center
.select-form-separator.cursor-pointer.mr-4(v-if="separator")
span.icon-down-arrow.open-icon.flex.text-xsm(:class="{'open': open }")
base-options(
v-if="open",
.flex.flex-col.gap-y-2
.label.font-semibold.text-xxs.opacity-40(v-if="label") {{ label }}
.base-select.flex.justify-between.items-center.py-9px.px-4.gap-4.cursor-pointer.relative(
@click="open = !open",
:class="{'open': open, 'border-none': borderNone}",
)
.items-container.mt-1(
@click="closeOptions",
v-click-outside="leaveSelect"
.placeholder.text-base.flex.items-center(
:class="{'value-color': value.label || placeholderOpacity}"
) {{ value.label || placeholder }}
.flex.items-center
.select-form-separator.cursor-pointer.mr-4(v-if="separator")
span.icon-down-arrow.open-icon.flex.text-xsm(:class="{'open': open }")
base-options(
v-if="open",
)
.item.py-2.px-4.cursor-pointer(
v-for="item in items",
:key="item?.id",
:class="{'center': center}",
@click="clickItem(item?.id, item?.label)"
) {{ item?.label }}
.items-container.mt-1(
@click="closeOptions",
v-click-outside="leaveSelect"
)
.item.py-2.px-4.cursor-pointer(
v-for="item in items",
:key="item?.id",
:class="{'center': center}",
@click="clickItem(item?.id, item?.label)"
) {{ item?.label }}
</template>
<script>
@@ -40,6 +42,7 @@ export default {
separator: Boolean,
placeholderOpacity: Boolean,
center: Boolean,
label: String,
},
emits: ["update:modelValue"],
data() {

View File

@@ -1,20 +1,16 @@
<template lang="pug">
.input-wrapper.flex.gap-x-2.px-4.box-border.py-10px(
:class="{'border-none': borderNone, 'date-input': dateInput}",
:style="{ minWidth: widthInput + 'px' }"
)
input.input.w-full.outline-0.not-italic(
:class="{date:type === 'date'}",
:value="value",
:type="type",
@input="$emit('update:value', $event.target.value)",
:placeholder="placeholder",
:maxLength="maxLength",
:max="maxDate",
:disabled="disabled"
.flex.flex-col.gap-y-2
.label.font-semibold.text-xxs.opacity-40(v-if="label") {{ label }}
.input-wrapper.flex.gap-x-2.px-4.box-border.py-10px(
:class="{'border-none': borderNone}"
)
.slot(v-if="withIcon", :class="iconPosition")
slot.cursor-pointer
input.input.w-full.outline-0.not-italic(
v-model="value",
:placeholder="placeholder",
:disabled="disabled"
)
.slot(v-if="withIcon", :class="iconPosition")
slot.cursor-pointer
</template>
<script>
@@ -22,11 +18,7 @@
export default {
name: "BaseInput",
props: {
type: {
default: "text",
},
maxLength: Number,
value: String,
modelValue: String,
withIcon: {
default: false,
},
@@ -34,11 +26,20 @@ export default {
default: "right",
},
placeholder: String,
widthInput: Number,
borderNone: Boolean,
disabled: Boolean,
maxDate: String,
dateInput: Boolean,
label: String,
},
emits: ["update:modelValue"],
computed: {
value: {
get() {
return this.modelValue;
},
set(value) {
this.$emit("update:modelValue", value);
},
},
},
};
</script>
@@ -55,12 +56,10 @@ export default {
background-color: var(--default-white)
color: var(--font-black-color)
height: 40px
.date
background: url("../../assets/icons/calendar-input.svg") no-repeat 100% 50%
&::-webkit-calendar-picker-indicator
opacity: 0
.border-none
border: none
.input
background-color: inherit
.label
color: var(--font-black-color)
</style>

View File

@@ -1,5 +1,5 @@
<template lang="pug">
.flex.flex-col
.flex.flex-col.gap-y-2
.label(v-if="!!label") {{label}}
.field
input(
@@ -37,7 +37,7 @@ export default {
<style lang="sass" scoped>
.field
height: 100%
height: 40px
display: flex
align-items: center
border: 1.5px solid var(--border-light-grey-color)
@@ -55,6 +55,7 @@ export default {
.label
font-weight: 600
font-size: 14px
line-height: 135%
font-size: 12px
line-height: 14px
opacity: 0.4
</style>

View File

@@ -1,25 +1,21 @@
<template lang="pug">
.input-wrapper.flex.gap-x-2.px-4.box-border(
class="py-2.5"
:style="{ minWidth: widthInput + 'px' }"
)
input.input.w-full.outline-0.not-italic.cursor-text(
:value="value"
type="time"
@input="$emit('update:value', $event.target.value)"
:placeholder="placeholder"
:maxlength="maxLength"
)
.slot(v-if="withIcon" :class="iconPosition")
slot.cursor-pointer
.flex.flex-col.gap-y-2
.label.font-semibold.text-xxs.opacity-40(v-if="label") {{ label }}
.input-wrapper.flex.gap-x-2.px-4.box-border.py-2.h-10
input.input.w-full.outline-0.not-italic.cursor-text(
v-model="value"
type="time"
:placeholder="placeholder"
)
.slot(v-if="withIcon" :class="iconPosition")
slot.cursor-pointer
</template>
<script>
export default {
name: "BaseInputTime",
props: {
maxLength: Number,
value: String,
modelValue: String,
withIcon: {
default: false,
},
@@ -27,7 +23,18 @@ export default {
default: "right",
},
placeholder: String,
widthInput: Number,
label: String,
},
emits: ["update:modelValue"],
computed: {
value: {
get() {
return this.modelValue;
},
set(value) {
this.$emit("update:modelValue", value);
},
},
},
};
</script>
@@ -41,6 +48,7 @@ export default {
border-radius: 4px
background-color: var(--default-white)
color: var(--font-black-color)
border: 1.5px solid var(--border-light-grey-color)
input::-webkit-calendar-picker-indicator
cursor: pointer
</style>