123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <template>
- <div
- :class="[
- 'nana-simple-input',
- focusState ? 'focus' : '',
- ]"
- >
- <div class="prefix">
- <slot name="prefix"/>
- </div>
- <input
- :placeholder="placeholder"
- v-bind="$attrs"
- class="nana-input-text"
- :value="modelValue"
- @input="(e: Event) => emit('update:modelValue', (e.target as HTMLInputElement).value)"
- @focus="handleFocus"
- @blur="handleBlur"
- />
- <div class="suffix">
- <slot name="suffix"/>
- </div>
- </div>
- </template>
- <script setup lang="ts">
- import { ref } from 'vue';
- defineProps({
- modelValue: {
- type: String,
- default: '',
- },
- placeholder: {
- type: String,
- default: '',
- },
- })
- const focusState = ref(false)
- const emit = defineEmits([ 'update:modelValue', 'focus', 'blur' ])
- function handleFocus() {
- focusState.value = true;
- emit('focus');
- }
- function handleBlur() {
- focusState.value = false;
- emit('blur');
- }
- </script>
- <style lang="scss">
- @use "@/assets/scss/colors.scss" as *;
- .nana-simple-input {
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: space-between;
- padding: 10px 15px;
- background-color: $box-color;
- border: 1px solid $border-default-color;
- &.focus {
- border-color: $border-active-color;
- }
- input {
- font-size: 1rem;
- color: $text-color;
- border: none;
- outline: none;
- background-color: transparent;
- }
- .prefix {
- margin-right: 6px;
- img {
- width: 24px;
- height: 24px;
- vertical-align: middle;
- }
- }
- .suffix {
- margin-left: 10px;
- margin-right: 10px;
- }
-
- &.dark {
- background-color: $box-dark-trans-color;
- border: 1px solid $border-dark-color;
- .nana-input-text {
- color: $text-color-light;
- &::placeholder {
- color: $text-second-color-light;
- }
- }
- }
- }
- .nana-input-text {
- color: $text-color;
- font-size: 26px;
- }
- </style>
|