Skip to content
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

feature(file-input): introducing file-input component. (closes #326) and (closes #286) #339

Merged
merged 35 commits into from
Feb 22, 2017
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
3d09a48
feature(file): introducing file-input component
Feb 14, 2017
f67eb92
chore(file-input): add initial unit tests
Feb 14, 2017
aa08409
feat(file-upload): leverage file-input component
Feb 14, 2017
75ee36e
feature(file): add a way to replace labels in file-upload
Feb 14, 2017
d40236e
feature(file-upload): proxy (select) event from td-file-input
Feb 14, 2017
55c5db3
fix(file-upload): improve unit tests and added mark check for OnPush
Feb 14, 2017
dab294c
fix(file-input): added mark check for OnPush
Feb 14, 2017
368b49f
docs(file-upload): updated demo in file upload docs
Feb 14, 2017
10f261d
docs(file-upload): update README.md and load it in docs
Feb 14, 2017
b35e410
docs(file-upload): improved demos and docs for file-upload
Feb 14, 2017
8e8c7e5
fix(): interpolation in file-upload demo
Feb 14, 2017
726cbdf
fix(): remove need for ?
Feb 14, 2017
75bdd21
docs(file-input): added README.md
Feb 14, 2017
91ea8a5
docs(file-input): scaffolding for demo and docs
Feb 14, 2017
e42b562
docs(file-input): add demo and docs for file input
Feb 14, 2017
e921815
docs(): added clear() method in API of file input
Feb 14, 2017
0df1ba1
Merge branch 'develop' into feature/file-browse
emoralesb05 Feb 15, 2017
220e67f
feature(file-input): add ngModel support
Feb 15, 2017
3f232d2
docs(file-input): update docs with ngModel
Feb 15, 2017
be49edc
fix(file-upload): update unit tests with model support
Feb 15, 2017
86b5072
fix(): final fix in README.md
Feb 15, 2017
ccc0282
update(file-input): markup tweaks
Feb 15, 2017
a97bccf
update(docs): cleanup file-upload docs
Feb 15, 2017
1012ed7
update(docs): tweak file upload icons & text
Feb 15, 2017
b95eb16
Merge branch 'develop' into feature/file-browse
emoralesb05 Feb 15, 2017
e0d3e60
feat(file-input): remove primary color by default
Feb 15, 2017
3b381ec
Merge branch 'feature/file-browse' of https://github.com/Teradata/cov…
Feb 15, 2017
22b8d72
feat(file-input): expose underlying input element
Feb 15, 2017
a8dc2ce
feat(file-input): add OnPush detection strategy
Feb 15, 2017
bec9dc1
docs(file-input): polished demo with a better example
Feb 15, 2017
190f33a
docs(file-input): fix for OnPush usage in docs
Feb 15, 2017
8ff5011
Merge branch 'develop' into feature/file-browse
emoralesb05 Feb 22, 2017
7e64c77
Merge branch 'develop' into feature/file-browse
emoralesb05 Feb 22, 2017
7288e61
corrected the event name
richavyas Feb 22, 2017
80bc222
Merge branch 'feature/file-browse' of https://github.com/Teradata/cov…
richavyas Feb 22, 2017
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
11 changes: 8 additions & 3 deletions src/app/components/components/components.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,15 @@ export class ComponentsComponent implements AfterViewInit {
route: 'expansion-panel',
title: 'Expansion Panels',
}, {
description: 'Upload input button',
icon: 'file_upload',
description: 'Text input for files',
icon: 'space_bar',
route: 'file-input',
title: 'File Input',
}, {
description: 'All-in-one upload button',
icon: 'attach_file',
route: 'file-upload',
title: 'File Upload',
title: 'File Upload Button',
}, {
description: 'Small blocks for multiple items',
icon: 'label_outline',
Expand Down
2 changes: 2 additions & 0 deletions src/app/components/components/components.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ComponentsOverviewComponent } from './overview/overview.component';
import { HighlightDemoComponent } from './highlight/highlight.component';
import { StepsDemoComponent } from './steps/steps.component';
import { ExpansionPanelDemoComponent } from './expansion-panel/expansion-panel.component';
import { FileInputDemoComponent } from './file-input/file-input.component';
import { FileUploadDemoComponent } from './file-upload/file-upload.component';
import { LoadingDemoComponent } from './loading/loading.component';
import { MarkdownDemoComponent } from './markdown/markdown.component';
Expand Down Expand Up @@ -46,6 +47,7 @@ import { DocumentationToolsModule } from '../../documentation-tools';
HighlightDemoComponent,
StepsDemoComponent,
ExpansionPanelDemoComponent,
FileInputDemoComponent,
FileUploadDemoComponent,
LoadingDemoComponent,
MarkdownDemoComponent,
Expand Down
4 changes: 4 additions & 0 deletions src/app/components/components/components.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ComponentsOverviewComponent } from './overview/overview.component';
import { HighlightDemoComponent } from './highlight/highlight.component';
import { StepsDemoComponent } from './steps/steps.component';
import { ExpansionPanelDemoComponent } from './expansion-panel/expansion-panel.component';
import { FileInputDemoComponent } from './file-input/file-input.component';
import { FileUploadDemoComponent } from './file-upload/file-upload.component';
import { LoadingDemoComponent } from './loading/loading.component';
import { MarkdownDemoComponent } from './markdown/markdown.component';
Expand Down Expand Up @@ -41,6 +42,9 @@ const routes: Routes = [{
}, {
component: ExpansionPanelDemoComponent,
path: 'expansion-panel',
}, {
component: FileInputDemoComponent,
path: 'file-input',
}, {
component: FileUploadDemoComponent,
path: 'file-upload',
Expand Down
104 changes: 104 additions & 0 deletions src/app/components/components/file-input/file-input.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<md-card>
<md-card-title>File Input</md-card-title>
<md-card-subtitle>single or multiple selection/drop</md-card-subtitle>
<md-divider></md-divider>
<md-tab-group md-stretch-tabs>
<md-tab>
<template md-tab-label>Demo</template>
<md-card-content>
<div layout="row">
<md-input-container tdFileDrop
[disabled]="disabled"
(fileDrop)="files = $event"
(click)="fileInput.inputElement.click()"
(keyup.enter)="fileInput.inputElement.click()"
(keyup.delete)="fileInput.clear()"
(keyup.backspace)="fileInput.clear()"
flex>
<input md-input
placeholder="select or drop files"
[value]="files?.length ? (files?.length + ' files') : files?.name"
[disabled]="disabled"
readonly/>
</md-input-container>
<button md-icon-button *ngIf="files" (click)="fileInput.clear()" (keyup.enter)="fileInput.clear()">
<md-icon>cancel</md-icon>
</button>
<td-file-input class="push-left-sm push-right-sm" #fileInput [(ngModel)]="files" multiple [disabled]="disabled">
<md-icon>folder</md-icon>
Browse...
</td-file-input>
<span>
<button md-raised-button color="accent" [disabled]="!files">Submit</button>
</span>
</div>
</md-card-content>
<md-divider></md-divider>
<md-card-actions>
<button md-button color="primary" (click)="toggleDisabled()">Toggle Disable</button>
</md-card-actions>
</md-tab>
<md-tab>
<template md-tab-label>Code</template>
<md-card-content>
<p>HTML:</p>
<td-highlight lang="html">
<![CDATA[
<div layout="row">
<md-input-container tdFileDrop
[disabled]="disabled"
(fileDrop)="files = $event"
(click)="fileInput.inputElement.click()"
(keyup.enter)="fileInput.inputElement.click()"
(keyup.delete)="fileInput.clear()"
(keyup.backspace)="fileInput.clear()"
flex>
<input md-input
placeholder="select or drop files"
[value]="files?.length ? (files?.length + ' files') : files?.name"
[disabled]="disabled"
readonly/>
</md-input-container>
<button md-icon-button *ngIf="files" (click)="fileInput.clear()" (keyup.enter)="fileInput.clear()">
<md-icon>cancel</md-icon>
</button>
<td-file-input class="push-left-sm push-right-sm" #fileInput [(ngModel)]="files" multiple [disabled]="disabled">
<md-icon>folder</md-icon>
Browse...
</td-file-input>
<span>
<button md-raised-button color="accent" [disabled]="!files">Submit</button>
</span>
</div>
]]>
</td-highlight>
<p>CSS:</p>
<td-highlight lang="typescript">
<![CDATA[
.drop-zone {
font-weight: 600;
/deep/ * {
pointer-events: none; //added to fix bug that re-throws dragleave/dragenter by child elements
}
}
]]>
</td-highlight>
<p>Typescript:</p>
<td-highlight lang="typescript">
<![CDATA[
export class Demo {
files: File | FileList;
disabled: boolean = false;

toggleDisabled(): void {
this.disabled = !this.disabled;
}
}
]]>
</td-highlight>
</md-card-content>
</md-tab>
</md-tab-group>
</md-card>

<td-readme-loader resourceUrl="platform/core/file/file-input/README.md"></td-readme-loader>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.drop-zone {
font-weight: 600;
/deep/ * {
pointer-events: none; //added to fix bug that re-throws dragleave/dragenter by child elements
}
}
26 changes: 26 additions & 0 deletions src/app/components/components/file-input/file-input.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Component, HostBinding, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core';

import { slideInDownAnimation } from '../../../app.animations';

@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
selector: 'file-input-demo',
styleUrls: ['./file-input.component.scss'],
templateUrl: './file-input.component.html',
animations: [slideInDownAnimation],
})
export class FileInputDemoComponent {

@HostBinding('@routeAnimation') routeAnimation: boolean = true;
@HostBinding('class.td-route-animation') classAnimation: boolean = true;

disabled: boolean = false;

constructor(private _changeDetectorRef: ChangeDetectorRef) {}

toggleDisabled(): void {
this.disabled = !this.disabled;
this._changeDetectorRef.detectChanges();
this._changeDetectorRef.markForCheck();
}
}
Loading