-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: better command line for tasks and start task (#671)
* Expanding textarea v1 * fixes * Single line * style tweaks * Start task too * wrap tweaks
- Loading branch information
1 parent
76db4af
commit fd9d8bd
Showing
11 changed files
with
124 additions
and
3 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
app/components/base/form/expanding-textarea/expanding-textarea.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { Component, ElementRef, HostBinding, Input, ViewChild, forwardRef } from "@angular/core"; | ||
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from "@angular/forms"; | ||
|
||
import "./expanding-textarea.scss"; | ||
|
||
@Component({ | ||
selector: "bl-expanding-textarea", | ||
templateUrl: "expanding-textarea.html", | ||
providers: [ | ||
// tslint:disable-next-line:no-forward-ref | ||
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => ExpandingTextareaComponent), multi: true }, | ||
], | ||
}) | ||
export class ExpandingTextareaComponent implements ControlValueAccessor { | ||
@Input() public placeholder: string; | ||
@Input() public value: string; | ||
@Input() public hint: string; | ||
|
||
@HostBinding("class.expanded") public expanded: boolean = false; | ||
@ViewChild("textarea") public textarea: ElementRef; | ||
|
||
private _propagateChange: any; | ||
private _propagateTouched: any; | ||
private _lastExpandedHeight = "100px"; | ||
|
||
public expand() { | ||
this.expanded = true; | ||
this.textarea.nativeElement.style.height = this._lastExpandedHeight; | ||
if (this._propagateTouched) { | ||
this._propagateTouched(true); | ||
} | ||
} | ||
|
||
public collapse() { | ||
this._lastExpandedHeight = this.textarea.nativeElement.style.height; | ||
this.textarea.nativeElement.style.height = null; | ||
this.expanded = false; | ||
} | ||
|
||
public valueChange(newValue: string) { | ||
this.value = newValue; | ||
if (this._propagateChange) { | ||
this._propagateChange(newValue); | ||
} | ||
} | ||
|
||
public writeValue(value: string): void { | ||
this.value = value; | ||
} | ||
public registerOnChange(fn: any): void { | ||
this._propagateChange = fn; | ||
} | ||
|
||
public registerOnTouched(fn: any): void { | ||
this._propagateTouched = fn; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
app/components/base/form/expanding-textarea/expanding-textarea.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div class="textarea-container"> | ||
<md-input-container> | ||
<textarea #textarea mdInput [placeholder]="placeholder" (focus)="expand()" (blur)="collapse()" [ngModel]="value" (ngModelChange)="valueChange($event)"></textarea> | ||
<md-hint *ngIf="hint" align="end">{{hint}}</md-hint> | ||
</md-input-container> | ||
</div> |
31 changes: 31 additions & 0 deletions
31
app/components/base/form/expanding-textarea/expanding-textarea.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
@import "app/styles/variables"; | ||
|
||
bl-expanding-textarea { | ||
$container-height: 48px; | ||
$collapsed-height: 20px; | ||
$expanded-height: 100px; | ||
|
||
> .textarea-container { | ||
height: $container-height; | ||
|
||
|
||
textarea { | ||
position: relative; | ||
width: 100%; | ||
height: $collapsed-height; | ||
resize: none; | ||
} | ||
} | ||
|
||
&.expanded { | ||
.mat-input-infix { | ||
background-color: #f5f5f5; | ||
z-index: 1000; | ||
} | ||
|
||
textarea { | ||
background-color: #f5f5f5; | ||
resize: vertical; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./expanding-textarea.component"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./single-line-textarea.directive"; |
17 changes: 17 additions & 0 deletions
17
app/components/base/form/single-line-textarea/single-line-textarea.directive.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Directive, HostListener } from "@angular/core"; | ||
|
||
import "./single-line-textarea.scss"; | ||
|
||
@Directive({ | ||
selector: "[blSingleLineTextarea]", | ||
}) | ||
export class SingleLineTextareaDirective { | ||
@HostListener("keydown", ["$event"]) | ||
public preventEnter(event: KeyboardEvent) { | ||
if (event.keyCode === 13) { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
event.stopImmediatePropagation(); | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
app/components/base/form/single-line-textarea/single-line-textarea.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[blSingleLineTextarea] { | ||
min-height: 18px; | ||
word-break: break-all; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters