Skip to content

create md-input-container to eventually replace md-input #2052

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

Merged
merged 35 commits into from
Dec 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
dd76026
created md-input-wrapper and removed useless inputs
mmalerba Nov 29, 2016
ea45082
added demo
mmalerba Nov 29, 2016
e88f608
remove ControlValueAccessor and start migrating input
mmalerba Nov 29, 2016
4cd9381
finished converting most input attrs
mmalerba Nov 29, 2016
f1adbdf
typescript fixed, css needs work
mmalerba Nov 29, 2016
3fd291b
removed duplicate directives.
mmalerba Nov 29, 2016
9b31865
fix scss
mmalerba Nov 30, 2016
e01f6e1
set up demo area
mmalerba Nov 30, 2016
0c9b537
Fix disabled state
mmalerba Nov 30, 2016
52d20fb
fixed some small bugs and converted more of demo
mmalerba Nov 30, 2016
ac0c1c6
demo card #1 converted
mmalerba Nov 30, 2016
36c72e3
finished converting demo
mmalerba Nov 30, 2016
26181e0
subscribe to ngModel changes
mmalerba Nov 30, 2016
ed1db39
updated other demos to use new input
mmalerba Nov 30, 2016
4640a22
undo accidental changes to other inputs
mmalerba Nov 30, 2016
66f0922
working through tests
mmalerba Nov 30, 2016
2bcbcb1
fixed all tests
mmalerba Dec 1, 2016
46f5cb2
fixed lint issues
mmalerba Dec 1, 2016
009b9a1
fix firefox type=date issue
mmalerba Dec 1, 2016
937186c
try removing ie11 checks, see if we need them
mmalerba Dec 1, 2016
2c21d52
added md-input back to baseline demo
mmalerba Dec 2, 2016
8bf8d02
started md-input directive
mmalerba Dec 3, 2016
25e85e8
more refactoring
mmalerba Dec 4, 2016
700577a
fixed demos, tests still broken
mmalerba Dec 5, 2016
4646be6
remove useless imports
mmalerba Dec 5, 2016
202b020
fix tests
mmalerba Dec 5, 2016
754e701
fix tests for ff & ie
mmalerba Dec 6, 2016
aa64775
move input feature detection into service
mmalerba Dec 6, 2016
dbb6731
addressed some comments
mmalerba Dec 6, 2016
956e8a5
s/input-wrapper/input-container
mmalerba Dec 7, 2016
d2534d5
s/NgModel/NgControl
mmalerba Dec 7, 2016
9010085
remove FeatureDetector
mmalerba Dec 7, 2016
e352175
s/MdPlatformModule/PlatformModule
mmalerba Dec 7, 2016
68ef6eb
Remove some problematic privates and add mat- versions of everything
mmalerba Dec 8, 2016
a6325a6
fix import
mmalerba Dec 9, 2016
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
12 changes: 10 additions & 2 deletions src/demo-app/baseline/baseline-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
| Text 3 |
<md-radio-button value="option_3">Radio 3</md-radio-button>
| Text 4 |
<md-input>Label</md-input>
<md-input placeholder="Input"></md-input>
| Text 5 |
<md-input-container>
<input md-input placeholder="Input">
</md-input-container>
| Text After
</md-card-content>
</md-card>
Expand All @@ -28,7 +32,11 @@ <h1>
| Text 3 |
<md-radio-button value="option_3">Radio 3</md-radio-button>
| Text 4 |
<md-input>Label</md-input>
<md-input placeholder="Input"></md-input>
| Text 5 |
<md-input-container>
<input md-input placeholder="Input">
</md-input-container>
| Text After
</h1>
</md-card-content>
Expand Down
2 changes: 2 additions & 0 deletions src/demo-app/demo-app-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {TabsDemo, SunnyTabContent, RainyTabContent, FoggyTabContent} from './tab
import {ProjectionDemo, ProjectionTestComponent} from './projection/projection-demo';
import {PlatformDemo} from './platform/platform-demo';
import {AutocompleteDemo} from './autocomplete/autocomplete-demo';
import {InputContainerDemo} from './input/input-container-demo';

@NgModule({
imports: [
Expand All @@ -62,6 +63,7 @@ import {AutocompleteDemo} from './autocomplete/autocomplete-demo';
Home,
IconDemo,
InputDemo,
InputContainerDemo,
JazzDialog,
ListDemo,
LiveAnnouncerDemo,
Expand Down
1 change: 1 addition & 0 deletions src/demo-app/demo-app/demo-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class DemoApp {
{name: 'Grid List', route: 'grid-list'},
{name: 'Icon', route: 'icon'},
{name: 'Input', route: 'input'},
{name: 'Input Container', route: 'input-container'},
{name: 'List', route: 'list'},
{name: 'Menu', route: 'menu'},
{name: 'Live Announcer', route: 'live-announcer'},
Expand Down
2 changes: 2 additions & 0 deletions src/demo-app/demo-app/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {ProjectionDemo} from '../projection/projection-demo';
import {TABS_DEMO_ROUTES} from '../tabs/routes';
import {PlatformDemo} from '../platform/platform-demo';
import {AutocompleteDemo} from '../autocomplete/autocomplete-demo';
import {InputContainerDemo} from '../input/input-container-demo';

export const DEMO_APP_ROUTES: Routes = [
{path: '', component: Home},
Expand All @@ -51,6 +52,7 @@ export const DEMO_APP_ROUTES: Routes = [
{path: 'overlay', component: OverlayDemo},
{path: 'checkbox', component: CheckboxDemo},
{path: 'input', component: InputDemo},
{path: 'input-container', component: InputContainerDemo},
{path: 'toolbar', component: ToolbarDemo},
{path: 'icon', component: IconDemo},
{path: 'list', component: ListDemo},
Expand Down
265 changes: 265 additions & 0 deletions src/demo-app/input/input-container-demo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,265 @@
<md-card class="demo-card demo-basic">
<md-toolbar color="primary">Basic</md-toolbar>
<md-card-content>
<form>
<md-input-container class="demo-full-width">
<input md-input placeholder="Company (disabled)" disabled value="Google">
</md-input-container>

<table style="width: 100%" cellspacing="0"><tr>
<td>
<md-input-container style="width: 100%">
<input md-input placeholder="First name">
</md-input-container>
</td>
<td>
<md-input-container style="width: 100%">
<input md-input placeholder="Long Last Name That Will Be Truncated">
</md-input-container>
</td>
</tr></table>
<p>
<md-input-container class="demo-full-width">
<textarea md-input placeholder="Address">1600 Amphitheatre Pkway</textarea>
</md-input-container>
<md-input-container class="demo-full-width">
<textarea md-input placeholder="Address 2"></textarea>
</md-input-container>
</p>
<table style="width: 100%" cellspacing="0"><tr>
<td>
<md-input-container class="demo-full-width">
<input md-input placeholder="City" value="Mountain View">
</md-input-container>
</td>
<td>
<md-input-container class="demo-full-width">
<input md-input placeholder="State" maxLength="2" value="CA">
</md-input-container>
</td>
<td>
<md-input-container class="demo-full-width">
<input md-input #postalCode maxLength="5" placeholder="Postal Code" value="94043">
<md-hint align="end">{{postalCode.value.length}} / 5</md-hint>
</md-input-container>
</td>
</tr></table>
</form>
</md-card-content>
</md-card>

<md-card class="demo-card demo-basic">
<md-toolbar color="primary">Prefix + Suffix</md-toolbar>
<md-card-content>
<md-input-container align="end">
<input md-input placeholder="amount">
<span md-prefix>$&nbsp;</span>
<span md-suffix>.00</span>
</md-input-container>
</md-card-content>
</md-card>

<md-card class="demo-card demo-basic">
<md-toolbar color="primary">Divider Colors</md-toolbar>
<md-card-content>
<h4>Input</h4>
<md-input-container dividerColor="primary" >
<input md-input placeholder="Default Color" value="example">
</md-input-container>
<md-input-container dividerColor="accent">
<input md-input placeholder="Accent Color" value="example">
</md-input-container>
<md-input-container dividerColor="warn">
<input md-input placeholder="Warn Color" value="example">
</md-input-container>

<h4>Textarea</h4>
<md-input-container dividerColor="primary">
<textarea md-input placeholder="Default Color">example</textarea>
</md-input-container>
<md-input-container dividerColor="accent">
<textarea md-input placeholder="Accent Color">example</textarea>
</md-input-container>
<md-input-container dividerColor="warn">
<textarea md-input placeholder="Warn Color">example</textarea>
</md-input-container>
</md-card-content>
</md-card>

<md-card class="demo-card demo-basic">
<md-toolbar color="primary">Hints</md-toolbar>
<md-card-content>
<h4>Input</h4>
<p>
<md-input-container class="demo-full-width">
<input md-input
#characterCountInputHintExample
placeholder="Character count (100 max)"
maxLength="100"
value="Hello world. How are you?">
<md-hint align="end">{{characterCountInputHintExample.value.length}} / 100</md-hint>
</md-input-container>
</p>

<h4>Textarea</h4>
<p>
<md-input-container class="demo-full-width">
<textarea md-input
#characterCountTextareaHintExample
placeholder="Character count (100 max)"
maxLength="100">Hello world. How are you?</textarea>
<md-hint align="end">{{characterCountTextareaHintExample.value.length}} / 100</md-hint>
</md-input-container>
</p>
</md-card-content>
</md-card>

<md-card class="demo-card demo-basic">
<md-toolbar color="primary">
Hello&nbsp;
<md-input-container dividerColor="accent">
<input md-input [(ngModel)]="name" type="text" placeholder="First name">
</md-input-container>,
how are you?
</md-toolbar>
<md-card-content>
<p>
<md-input-container>
<input md-input disabled placeholder="Disabled field" value="Value">
</md-input-container>
<md-input-container>
<input md-input required placeholder="Required field">
</md-input-container>
</p>
<p>
<md-input-container style="width: 100%">
<input md-input placeholder="100% width placeholder">
</md-input-container>
</p>
<p>
<md-input-container style="width: 100%">
<input md-input #input placeholder="Character count (100 max)" maxLength="100">
<md-hint align="end">{{input.value.length}} / 100</md-hint>
</md-input-container>
</p>
<p>
<md-input-container hintLabel="Hint label" style="width: 100%">
<input md-input placeholder="Show Hint Label">
</md-input-container>
</p>

<p>
<md-input-container>
<input md-input>
<md-placeholder>
I <md-icon class="demo-icons">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
</md-hint>
</md-input-container>
</p>
<p>
<md-input-container hintLabel="Hint label" style="width: 100%">
<input md-input #hintLabelWithCharCount placeholder="Show Hint Label With Character Count">
<md-hint align="end">{{hintLabelWithCharCount.value.length}}</md-hint>
</md-input-container>
</p>
<p>
<md-checkbox [(ngModel)]="dividerColor">Check to change the divider color:</md-checkbox>
<md-input-container [dividerColor]="dividerColor ? 'primary' : 'accent'">
<input md-input [placeholder]="dividerColor ? 'Primary color' : 'Accent color'">
</md-input-container>
</p>
<p>
<md-checkbox [(ngModel)]="requiredField"> Check to make required:</md-checkbox>
<md-input-container>
<input md-input
[required]="requiredField"
[placeholder]="requiredField ? 'Required field' : 'Not required field'">
</md-input-container>
</p>
<p>
<md-checkbox [(ngModel)]="floatingLabel"> Check to make floating label:</md-checkbox>
<md-input-container [floatingPlaceholder]="floatingLabel">
<input md-input [placeholder]="floatingLabel ? 'Floating label' : 'Not floating label'">
</md-input-container>
</p>

<p>
<md-input-container>
<input md-input placeholder="Prefixed" value="example">
<div md-prefix>Example:&nbsp;</div>
</md-input-container>
<md-input-container align="end">
<input md-input placeholder="Suffixed" value="123">
<span md-suffix>.00 €</span>
</md-input-container>
<br/>
Both:
<md-input-container align="end">
<input md-input #email placeholder="Email Address" value="angular-core">
<span md-prefix>
<md-icon [class.primary]="email.focused" class="demo-icons demo-transform">email</md-icon>
&nbsp;
</span>
<span md-suffix class="demo-transform" [class.primary]="email.focused">
&nbsp;@gmail.com
</span>
</md-input-container>
</p>

<p>
Empty: <md-input-container><input md-input></md-input-container>
<label>Label: <md-input-container><input md-input></md-input-container></label>
</p>
</md-card-content>
</md-card>

<md-card class="demo-card demo-basic">
<md-toolbar color="primary">Number Inputs</md-toolbar>
<md-card-content>
<table width="100%">
<thead>
<td>Table</td>
<td colspan="3">
<button (click)="addABunch(5)">Add 5</button>
<button (click)="addABunch(10)">Add 10</button>
<button (click)="addABunch(100)">Add 100</button>
<button (click)="addABunch(1000)">Add 1000</button>
</td>
</thead>
<tr *ngFor="let item of items; let i = index">
<td>{{i+1}}</td>
<td>
<md-input-container>
<input md-input
type="number"
placeholder="value"
aria-label="hello"
[(ngModel)]="items[i].value">
</md-input-container>
</td>
<td>
<input type="number" [(ngModel)]="items[i].value">
</td>
<td>{{item.value}}</td>
</tr>
</table>
</md-card-content>
</md-card>


<md-card class="demo-card demo-basic">
<md-toolbar color="primary">Textarea Autosize</md-toolbar>
<md-card-content>
<textarea md-autosize class="demo-textarea"></textarea>
<div>
<md-input-container>
<textarea md-input
md-autosize
placeholder="Autosized textarea"></textarea>
</md-input-container>
</div>
</md-card-content>
</md-card>
31 changes: 31 additions & 0 deletions src/demo-app/input/input-container-demo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {Component} from '@angular/core';


let max = 5;

@Component({
moduleId: module.id,
selector: 'input-container-demo',
templateUrl: 'input-container-demo.html',
styleUrls: ['input-demo.css'],
})
export class InputContainerDemo {
dividerColor: boolean;
requiredField: boolean;
floatingLabel: boolean;
name: string;
items: any[] = [
{ value: 10 },
{ value: 20 },
{ value: 30 },
{ value: 40 },
{ value: 50 },
];
rows = 8;

addABunch(n: number) {
for (let x = 0; x < n; x++) {
this.items.push({ value: ++max });
}
}
}
12 changes: 12 additions & 0 deletions src/demo-app/platform/platform-demo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<p>Is Android: {{ platform.ANDROID }}</p>
<p>Is iOS: {{ platform.IOS }}</p>
<p>Is Firefox: {{ platform.FIREFOX }}</p>
<p>Is Blink: {{ platform.BLINK }}</p>
<p>Is Webkit: {{ platform.WEBKIT }}</p>
<p>Is Trident: {{ platform.TRIDENT }}</p>
<p>Is Edge: {{ platform.EDGE }}</p>

<p>
Supported input types:
<span *ngFor="let type of supportedInputTypes">{{ type }}, </span>
</p>
Loading