Skip to content

Commit a30d84c

Browse files
Samuell1marcosmoura
authored andcommitted
feat(MdField): add prefixes and suffixes (#1592)
* feat(MdField): add prefixes, suffixes * docs(MdField): prefixes, suffixes example * docs(MdField): example name * feat(MdField): remove padding
1 parent 5d3dfcf commit a30d84c

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed

docs/app/pages/Components/Input/Input.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<example src="./examples/InlineActions.vue" />
66
<example src="./examples/FieldVariations.vue" />
77
<example src="./examples/AppBarNested.vue" />
8+
<example src="./examples/Fixes.vue" />
89

910
<template>
1011
<page-container centered :title="$t('pages.input.title')">
@@ -62,7 +63,16 @@
6263

6364
<p>Fields can have a clearable feature to make easy for users to clear the value. And to be easier to type passwords we can show a toggle button to reveal the password. This is really useful for mobile applications:</p>
6465
<code-example title="Clear and password" :component="examples['inline-actions']" />
66+
</div>
67+
68+
<div class="page-container-section">
69+
<h2>Prefixes & suffixes</h2>
6570

71+
<p>Prefixes and suffixes can be used to clarify units or to add input in advance. Prefixes are left justified in the text field; suffixes are right justified. Text fields can have both prefixes and suffixes.</p>
72+
<code-example title="Prefixes & suffixes" :component="examples['fixes']" />
73+
</div>
74+
75+
<div class="page-container-section">
6676
<api-item title="API - md-field">
6777
<p>The following options can be applied to any field:</p>
6878

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<template>
2+
<div>
3+
<md-field>
4+
<label>Prefix</label>
5+
<span class="md-prefix">$</span>
6+
<md-input v-model="initial"></md-input>
7+
</md-field>
8+
9+
<md-field>
10+
<label>Suffix</label>
11+
<md-input v-model="empty"></md-input>
12+
<span class="md-suffix">@gmail.com</span>
13+
</md-field>
14+
</div>
15+
</template>
16+
17+
<script>
18+
export default {
19+
name: 'Fixes',
20+
data: () => ({
21+
initial: 0,
22+
empty: ''
23+
})
24+
}
25+
</script>
26+
27+
<style lang="scss" scoped>
28+
.md-field:last-child {
29+
margin-bottom: 40px;
30+
}
31+
</style>

src/components/MdField/MdField.vue

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,27 @@
196196
transition-duration: .3s;
197197
line-height: 1;
198198
}
199+
.md-suffix {
200+
font-size: 16px;
201+
line-height: 32px;
202+
align-self: center;
203+
justify-self: center;
204+
}
205+
206+
.md-prefix {
207+
display: none;
208+
padding-right: 4px;
209+
font-size: 16px;
210+
line-height: 32px;
211+
align-self: center;
212+
justify-self: center;
213+
}
214+
215+
&.md-focused, &.md-has-value {
216+
.md-prefix {
217+
display: block;
218+
}
219+
}
199220
200221
.md-input,
201222
.md-textarea {

src/components/MdField/theme.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
color: rgba(#000, .54);
3030
}
3131

32+
.md-suffix, .md-prefix {
33+
color: rgba(#000, .54);
34+
}
35+
3236
.md-input,
3337
.md-textarea {
3438
&::-webkit-input-placeholder {
@@ -58,6 +62,10 @@
5862
color: rgba(#fff, .7);
5963
}
6064

65+
.md-suffix, .md-prefix {
66+
color: rgba(#fff, .7);
67+
}
68+
6169
.md-input,
6270
.md-textarea {
6371
&::-webkit-input-placeholder {

0 commit comments

Comments
 (0)