Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 5c889b7

Browse files
author
Robert Messerle
committed
docs(input): adds icon example to input demo page
1 parent 425a76a commit 5c889b7

10 files changed

+69
-0
lines changed
Loading
Loading
Loading
Loading
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<div ng-app="inputIconDemo" ng-controller="DemoCtrl" layout="column">
2+
3+
<br/>
4+
<md-content class="md-padding">
5+
<md-input-container md-no-float>
6+
<md-icon md-svg-src="/demo-partials/input/demoIcons/icons/ic_person_24px.svg"></md-icon>
7+
<input ng-model="user.name" type="text" placeholder="Name">
8+
</md-input-container>
9+
<md-input-container md-no-float>
10+
<md-icon md-svg-src="/demo-partials/input/demoIcons/icons/ic_phone_24px.svg"></md-icon>
11+
<input ng-model="user.phone" type="text" placeholder="Phone Number">
12+
</md-input-container>
13+
<md-input-container md-no-float>
14+
<md-icon md-svg-src="/demo-partials/input/demoIcons/icons/ic_email_24px.svg"></md-icon>
15+
<input ng-model="user.email" type="email" placeholder="Email">
16+
</md-input-container>
17+
<md-input-container md-no-float>
18+
<md-icon md-svg-src="/demo-partials/input/demoIcons/icons/ic_place_24px.svg"></md-icon>
19+
<input ng-model="user.address" type="text" placeholder="Address">
20+
</md-input-container>
21+
</md-content>
22+
23+
</div>
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
angular
2+
.module('inputIconDemo', ['ngMaterial', 'ngMessages'])
3+
.controller('DemoCtrl', function($scope) {
4+
$scope.user = {
5+
name: 'John Doe',
6+
7+
phone: '',
8+
address: ''
9+
};
10+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.inputIconDemo {
2+
min-height:48px;
3+
}

src/components/input/input-theme.scss

+7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ md-input-container.md-THEME_NAME-theme {
66
text-shadow: '{{foreground-shadow}}';
77
}
88

9+
> md-icon {
10+
fill: '{{foreground-1}}';
11+
}
12+
913
label,
1014
.md-placeholder {
1115
text-shadow: '{{foreground-shadow}}';
@@ -26,6 +30,9 @@ md-input-container.md-THEME_NAME-theme {
2630
label {
2731
color: '{{primary-500}}';
2832
}
33+
md-icon {
34+
fill: '{{primary-500}}';
35+
}
2936
&.md-accent {
3037
.md-input {
3138
border-color: '{{accent-500}}';

src/components/input/input.js

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ angular.module('material.components.input', [
2929
* parent is provided.
3030
*
3131
* @param md-is-error {expression=} When the given expression evaluates to true, the input container will go into error state. Defaults to erroring if the input has been touched and is invalid.
32+
* @param md-no-float {boolean=} When present, placeholders will not be converted to floating labels
3233
*
3334
* @usage
3435
* <hljs lang="html">
@@ -319,6 +320,7 @@ function placeholderDirective() {
319320

320321
function postLink(scope, element, attr, inputContainer) {
321322
if (!inputContainer) return;
323+
if (angular.isDefined(inputContainer.element.attr('md-no-float'))) return;
322324

323325
var placeholderText = attr.placeholder;
324326
element.removeAttr('placeholder');

src/components/input/input.scss

+8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ md-input-container {
2424
padding: $input-container-padding;
2525
padding-bottom: $input-container-padding + $input-error-height;
2626

27+
> md-icon {
28+
position: absolute;
29+
top: 5px;
30+
left: 2px;
31+
+ input {
32+
margin-left: 28px * 2;
33+
}
34+
}
2735

2836
textarea,
2937
input[type="text"],

0 commit comments

Comments
 (0)