Skip to content

Commit

Permalink
feat(FileUpload): support disabled mode
Browse files Browse the repository at this point in the history
ISSUES CLOSED: #1810
  • Loading branch information
benjamincharity committed Dec 5, 2019
1 parent d53067f commit f85857b
Show file tree
Hide file tree
Showing 10 changed files with 225 additions and 214 deletions.
5 changes: 4 additions & 1 deletion demo/app/components/file-upload/file-upload.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ <h3 tsVerticalSpacing>Demo Controls</h3>
<ts-toggle [(ngModel)]="multiple">Allow multiple selections</ts-toggle>
<br>
<ts-toggle [(ngModel)]="hideButton">Hide button</ts-toggle>
<br>
<ts-toggle [(ngModel)]="disabled">Disabled</ts-toggle>
</div>
<div fxLayout="row" fxLayoutGap="24px">
<div>
<ts-input label="Max Size (kb)" type="number" [(ngModel)]="maxKb"></ts-input>
</div>
<div>
<div fxFlex="noshrink">
<ts-select
label="Allowed MIME types"
[allowMultiple]="true"
Expand All @@ -30,6 +32,7 @@ <h3 tsVerticalSpacing>Demo Controls</h3>

<ts-card tsVerticalSpacing>
<ts-file-upload
[isDisabled]="disabled"
[hideButton]="hideButton"
[maximumKilobytesPerFile]="maxKb"
[multiple]="multiple"
Expand Down
2 changes: 1 addition & 1 deletion demo/app/components/file-upload/file-upload.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export class FileUploadComponent {
maxKb: number | undefined;
mimeTypeOptions = ['image/png', 'image/jpg', 'image/jpeg', 'text/csv', 'video/mp4', 'video/x-flv', 'video/webm', 'video/quicktime', 'video/mpeg'];
ratioConstraints = ['1:2', '1.9:1', '5:1'];

disabled = false;

selected(e) {
console.log('DEMO: selected: ', e);
Expand Down
2 changes: 2 additions & 0 deletions demo/app/components/file-upload/file-upload.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { FlexLayoutModule } from '@angular/flex-layout';
import { FormsModule } from '@angular/forms';
import { TsCardModule } from '@terminus/ui/card';
import { TsFileUploadModule } from '@terminus/ui/file-upload';
Expand All @@ -17,6 +18,7 @@ import { FileUploadComponent } from './file-upload.component';
imports: [
CommonModule,
FileUploadRoutingModule,
FlexLayoutModule,
FormsModule,
TsCardModule,
TsFileUploadModule,
Expand Down
4 changes: 3 additions & 1 deletion terminus-ui/file-upload/src/file-upload.component.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<div
class="c-file-upload qa-file-upload"
[class.c-file-upload--disabled]="isDisabled"
[class.c-file-upload--drag]="dragInProgress"
[class.c-file-upload--file]="file"
[class.c-file-upload--error]="file && !file.isValid"
[id]="id"
tabindex="1"
fxLayout="column"
>
Expand Down Expand Up @@ -85,7 +87,7 @@
class="c-file-upload__prompt qa-file-upload-prompt"
[class.c-file-upload__prompt--hidden]="hideButton"
[theme]="theme"
[isDisabled]="dragInProgress"
[isDisabled]="dragInProgress || isDisabled"
(clicked)="promptForFiles()"
>
{{ buttonMessage }}
Expand Down
14 changes: 12 additions & 2 deletions terminus-ui/file-upload/src/file-upload.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ $drag-bg: lighten(color(primary, xlight), 50%);

// Top level styles belong here
.c-file-upload {
cursor: cursor(pointer);
&:not(.c-file-upload--disabled) {
cursor: cursor(pointer);
}
}

// If followed directly by another instance, add vertical spacing
Expand All @@ -39,7 +41,9 @@ $drag-bg: lighten(color(primary, xlight), 50%);

&:hover,
&:focus {
border-color: color(primary, xlight);
&:not(.c-file-upload--disabled) {
border-color: color(primary, xlight);
}
}

// Class added when dragging over
Expand All @@ -63,6 +67,12 @@ $drag-bg: lighten(color(primary, xlight), 50%);
border-color: color(warn);
}

&.c-file-upload--disabled {
.c-file-upload__empty {
color: color(utility, light);
}
}

// <div> container for the selected file
.c-file-upload__file {
@include typography(hint);
Expand Down
Loading

0 comments on commit f85857b

Please sign in to comment.