Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#817][3.0] TextField 아이콘 설정 추가 #818

Merged
merged 1 commit into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/views/textField/api/textField.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ height: 35px;
/* type = textarea */
height: 100px;
```
- '#icon-prefix', '#icon-suffix' 을 지정해서 <텍스트필드> 내 아이콘 표시 가능
```
<ev-text-field>
<template #icon-prefix>
<ev-icon icon="ev-icon-search"></ev-icon>
</template>
</ev-text-field>
```


### Props
Expand Down
86 changes: 86 additions & 0 deletions docs/views/textField/example/Icon.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<template>
<div class="case">
<p class="case-title">Prefix</p>
<ev-text-field
v-model="modelValue1"
placeholder="Please enter the content"
type="text"
>
<template #icon-prefix>
<ev-icon icon="ev-icon-search"></ev-icon>
</template>
</ev-text-field>
<div class="description">
<span class="badge yellow">
type="text"
</span>
<span class="badge">
Text Field Value
</span>
{{ modelValue1 }}
</div>
</div>
<div class="case">
<p class="case-title">Suffix</p>
<ev-text-field
v-model="modelValue2"
placeholder="Please enter the content"
type="text"
>
<template #icon-suffix>
<ev-icon icon="ev-icon-calendar"></ev-icon>
</template>
</ev-text-field>
<div class="description">
<span class="badge yellow">
type="text"
</span>
<span class="badge">
Text Field Value
</span>
{{ modelValue2 }}
</div>
</div>
<div class="case">
<p class="case-title">Prefix & Suffix</p>
<ev-text-field
v-model="modelValue3"
placeholder="Please enter the content"
type="text"
>
<template #icon-prefix>
<ev-icon icon="ev-icon-search"></ev-icon>
</template>
<template #icon-suffix>
<ev-icon icon="ev-icon-calendar"></ev-icon>
</template>
</ev-text-field>
<div class="description">
<span class="badge yellow">
type="text"
</span>
<span class="badge">
Text Field Value
</span>
{{ modelValue3 }}
</div>
</div>
</template>

<script>
import { ref } from 'vue';

export default {
setup() {
const modelValue1 = ref();
const modelValue2 = ref();
const modelValue3 = ref();

return {
modelValue1,
modelValue2,
modelValue3,
};
},
};
</script>
7 changes: 7 additions & 0 deletions docs/views/textField/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import Search from './example/Search';
import SearchRaw from '!!raw-loader!./example/Search';
import Textarea from './example/Textarea';
import TextareaRaw from '!!raw-loader!./example/Textarea';
import Icon from './example/Icon';
import IconRaw from '!!raw-loader!./example/Icon';

export default {
mdText,
Expand All @@ -27,6 +29,11 @@ export default {
component: Search,
parsedData: parseComponent(SearchRaw),
},
Icon: {
description: 'TextField 내에 Prefix, Suffix 아이콘 설정이 가능한 input 컴포넌트입니다.',
component: Icon,
parsedData: parseComponent(IconRaw),
},
Textarea: {
description: '여러 줄의 문장을 입력할 수 있는 input 컴포넌트입니다.',
component: Textarea,
Expand Down
39 changes: 39 additions & 0 deletions src/components/textField/TextField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
'show-password': showPassword,
'show-maxlength': showMaxLength,
[`type-${type}`]: !!type,
'ev-text-field-prefix': $slots['icon-prefix'],
'ev-text-field-suffix': $slots['icon-suffix'],
'ev-text-field-prefix-suffix': $slots['icon-prefix'] && $slots['icon-suffix'],
}"
>
<div
Expand Down Expand Up @@ -67,6 +70,18 @@
>
<i class="ev-icon-search"/>
</span>
<span
v-if="$slots['icon-suffix']"
class="ev-text-field-icon icon-suffix"
>
<slot name="icon-suffix"/>
</span>
<span
v-if="$slots['icon-prefix']"
class="ev-text-field-icon icon-prefix"
>
<slot name="icon-prefix"/>
</span>
</template>
</div>
<div
Expand Down Expand Up @@ -331,4 +346,28 @@ $icon-width: 14px !default;
}
}
}
@include state('ev-text-field-suffix') {
.ev-input {
padding: 0 #{$input-default-padding + $icon-width} 0 $input-default-padding;
}
.icon-suffix {
font-size: 15px;
cursor: default;
}
}
@include state('ev-text-field-prefix') {
.ev-input {
padding: 0 $input-default-padding 0 #{$input-default-padding + $icon-width};
}
.icon-prefix {
left: 7px;
font-size: 15px;
cursor: default;
}
}
@include state('ev-text-field-prefix-suffix') {
.ev-input {
padding: 0 #{$input-default-padding + $icon-width};
}
}
</style>