Skip to content

Commit 13549dc

Browse files
committed
feat(MdField): make icons work together with fields
1 parent f1bb1c6 commit 13549dc

File tree

6 files changed

+79
-10
lines changed

6 files changed

+79
-10
lines changed

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

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<example src="./examples/TextFields.vue" />
22
<example src="./examples/ErrorsMessages.vue" />
33
<example src="./examples/Counters.vue" />
4+
<example src="./examples/Icons.vue" />
45

56
<template>
67
<page-container centered :title="$t('pages.input.title')">
@@ -25,6 +26,12 @@
2526

2627
<code-example title="Counter" :component="examples['counters']" />
2728
</div>
29+
30+
<div class="page-container-section">
31+
<h2>Icons and Clear button</h2>
32+
33+
<code-example title="Outside, inline and clear" :component="examples['icons']" />
34+
</div>
2835
</page-container>
2936
</template>
3037

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

+8-3
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,22 @@
22
<div>
33
<md-field>
44
<label>Required Field</label>
5-
<md-input required maxlength="30" />
5+
<md-input maxlength="30" />
6+
</md-field>
7+
8+
<md-field :md-counter="false">
9+
<label>Maxlength with disabled counter</label>
10+
<md-input maxlength="10" />
611
</md-field>
712

813
<md-field>
914
<label>Autogrow</label>
10-
<md-textarea md-autogrow required maxlength="200" />
15+
<md-textarea md-autogrow maxlength="200" />
1116
</md-field>
1217

1318
<md-field>
1419
<label>Textarea</label>
15-
<md-textarea required maxlength="80" />
20+
<md-textarea maxlength="80" />
1621
</md-field>
1722
</div>
1823
</template>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<template>
2+
<div>
3+
<md-field>
4+
<md-icon>event</md-icon>
5+
<label>Date</label>
6+
<md-input />
7+
</md-field>
8+
9+
<md-field>
10+
<label>Voice</label>
11+
<md-input />
12+
<md-icon>keyboard_voice</md-icon>
13+
</md-field>
14+
15+
<md-field>
16+
<label>Description</label>
17+
<md-textarea />
18+
<md-icon>description</md-icon>
19+
</md-field>
20+
21+
<md-field>
22+
<md-icon class="md-accent">warning</md-icon>
23+
<label>Transfer Money</label>
24+
<md-input />
25+
<md-icon>attach_money</md-icon>
26+
</md-field>
27+
</div>
28+
</template>
29+
30+
<style lang="scss" scoped>
31+
.md-field:last-child {
32+
margin-bottom: 40px;
33+
}
34+
</style>
35+
36+
<script>
37+
export default {
38+
name: 'Icons'
39+
}
40+
</script>

src/components/MdField/MdField.vue

+15-4
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
margin: 4px 0 24px;
8282
padding-top: 16px;
8383
display: flex;
84-
flex-direction: column;
8584
position: relative;
8685
8786
&:before,
@@ -179,18 +178,23 @@
179178
right: 0;
180179
}
181180
182-
.md-icon:not(.md-icon-delete) {
181+
> .md-icon {
183182
margin: 4px auto;
183+
position: relative;
184+
z-index: 3;
184185
color: rgba(#000, .54);
185186
transition: $md-transition-stand;
186187
188+
&:last-of-type:not(:first-child):after {
189+
display: none;
190+
}
191+
187192
&:after {
188193
width: 36px;
189194
height: 2px;
190195
position: absolute;
191196
left: 0;
192-
bottom: 0;
193-
z-index: 2;
197+
bottom: -4px;
194198
content: "";
195199
}
196200
@@ -253,6 +257,13 @@
253257
padding: 0 16px;
254258
}
255259
260+
.md-icon {
261+
position: absolute;
262+
top: 6px;
263+
right: 6px;
264+
z-index: 3;
265+
}
266+
256267
.md-count {
257268
right: 6px;
258269
bottom: 2px;

src/components/MdField/theme.scss

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
background-color: rgba(#000, .42);
66
}
77

8-
98
.md-helper-text,
109
.md-count,
1110
label {
@@ -89,6 +88,13 @@
8988
}
9089
}
9190

91+
92+
> .md-icon {
93+
&:after {
94+
@include md-theme-property(background-color, background);
95+
}
96+
}
97+
9298
&.md-invalid {
9399
&:after {
94100
@include md-theme-property-by-hue(background-color, red, A400, field, error);

src/components/MdIcon/theme.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}
1010

1111
&.md-accent {
12-
@include md-theme-property(fill, primary, background);
12+
@include md-theme-property(fill, accent, background);
1313
}
1414
}
1515
}
@@ -22,7 +22,7 @@
2222
}
2323

2424
&.md-accent {
25-
@include md-theme-property(color, primary, background);
25+
@include md-theme-property(color, accent, background);
2626
}
2727
}
2828
}

0 commit comments

Comments
 (0)