Skip to content

Commit

Permalink
fix(input): make all icons in input containers the correct size (#3489)
Browse files Browse the repository at this point in the history
* fix(input): make all icons in input containers the correct size

* docs(input): add icon prefix/suffix example
  • Loading branch information
marshall007 authored and tinayuangao committed Mar 10, 2017
1 parent 23ee633 commit 359c9bb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 25 deletions.
7 changes: 0 additions & 7 deletions src/demo-app/baseline/baseline-demo.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@
width: 100%;
}

.demo-icons {
font-size: 100%;
height: inherit;
vertical-align: top;
width: inherit;
}

.demo-card {
margin: 16px;
}
17 changes: 14 additions & 3 deletions src/demo-app/input/input-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@
<td>
<md-input-container class="demo-full-width">
<input mdInput #postalCode maxLength="5" placeholder="Postal Code" value="94043">
<md-hint align="end">{{postalCode.value.length}} / 5</md-hint>
<md-hint align="end">
<md-icon>mode_edit</md-icon>
{{postalCode.value.length}} / 5
</md-hint>
</md-input-container>
</td>
</tr></table>
Expand All @@ -51,11 +54,19 @@
<md-card class="demo-card demo-basic">
<md-toolbar color="primary">Prefix + Suffix</md-toolbar>
<md-card-content>
<h4>Text</h4>
<md-input-container align="end">
<input mdInput placeholder="amount">
<span mdPrefix>$&nbsp;</span>
<span mdSuffix>.00</span>
</md-input-container>

<h4>Icons</h4>
<md-input-container>
<input mdInput placeholder="amount">
<md-icon mdPrefix>attach_money</md-icon>
<md-icon mdSuffix>mode_edit</md-icon>
</md-input-container>
</md-card-content>
</md-card>

Expand Down Expand Up @@ -152,10 +163,10 @@ <h4>Textarea</h4>
<md-input-container>
<input mdInput>
<md-placeholder>
I <md-icon class="demo-icons">favorite</md-icon> <b>bold</b> placeholder
I <md-icon>favorite</md-icon> <b>bold</b> placeholder
</md-placeholder>
<md-hint>
I also <md-icon class="demo-icons">home</md-icon> <i>italic</i> hint labels
I also <md-icon>home</md-icon> <i>italic</i> hint labels
</md-hint>
</md-input-container>
</p>
Expand Down
7 changes: 0 additions & 7 deletions src/demo-app/input/input-demo.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@
width: 100%;
}

.demo-icons {
font-size: 100%;
height: inherit;
vertical-align: top;
width: inherit;
}

.demo-card {
margin: 16px;
}
Expand Down
16 changes: 8 additions & 8 deletions src/lib/input/input-container.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ $mat-input-underline-disabled-background-image:
[dir='rtl'] & {
text-align: right;
}

// Allow icons in a prefix/suffix/hint/etc to adapt to the correct size.
& .mat-icon {
width: auto;
height: auto;
font-size: 100%;
vertical-align: top;
}
}

// Global wrapper. We need to apply margin to the element for spacing, but
Expand Down Expand Up @@ -238,12 +246,4 @@ $mat-input-underline-disabled-background-image:
// Prevents the prefix and suffix from stretching together with the container.
width: 0.1px;
white-space: nowrap;

// Allow icons in a prefix/suffix to adapt to the correct size.
& .mat-icon {
width: auto;
height: auto;
font-size: 100%;
vertical-align: top;
}
}

0 comments on commit 359c9bb

Please sign in to comment.