Skip to content

Commit

Permalink
feat(color-picker): implement position for used colors
Browse files Browse the repository at this point in the history
Closes #90
  • Loading branch information
tiaguinho committed Jul 22, 2020
1 parent 916ab45 commit d199e04
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
19 changes: 16 additions & 3 deletions src/lib/color-picker/color-picker.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,25 @@
[height]="colorPickerSelectorHeight" (changeSelectedColor)="updateTmpSelectedColor($event)">
</mcc-color-picker-selector>

<mcc-color-picker-collection *ngIf="!hideUsedColors" [label]="usedColorLabel" [size]="usedSizeColors" [transparent]="!hideTransparent"
[hideEmpty]="hideEmpty" [colors]="usedColors$ | async" (changeColor)="updateTmpSelectedColor($event)">
</mcc-color-picker-collection>
<!-- show used colors on top -->
<ng-container *ngIf="!hideUsedColors && usedColorsPosition == 'top'">
<mcc-color-picker-collection [label]="usedColorLabel" [size]="usedSizeColors"
[transparent]="!hideTransparent" [hideEmpty]="hideEmpty"
[colors]="usedColors$ | async" (changeColor)="updateTmpSelectedColor($event)">
</mcc-color-picker-collection>
</ng-container>

<!-- render user collections -->
<ng-content></ng-content>

<!-- show used colors on bottom -->
<ng-container *ngIf="!hideUsedColors && usedColorsPosition == 'bottom'">
<mcc-color-picker-collection [label]="usedColorLabel" [size]="usedSizeColors"
[transparent]="!hideTransparent" [hideEmpty]="hideEmpty" [colors]="usedColors$
| async" (changeColor)="updateTmpSelectedColor($event)">
</mcc-color-picker-collection>
</ng-container>

<div *ngIf="!hideButtons" class="mcc-color-picker-actions">

<button mat-button role="button" aria-label="Cancel" (click)="cancelSelection()">
Expand Down
15 changes: 14 additions & 1 deletion src/lib/color-picker/color-picker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from '@angular/core';
import { BehaviorSubject, Observable, Subscription } from 'rxjs';
import { map } from 'rxjs/operators';
import { EMPTY_COLOR, ENABLE_ALPHA_SELECTOR, coerceHexaColor } from './color-picker';
import { EMPTY_COLOR, ENABLE_ALPHA_SELECTOR, MccColorPickerUsedColorPosition, coerceHexaColor } from './color-picker';
import { MccColorPickerCollectionComponent } from './color-picker-collection.component';
import { MccColorPickerService } from './color-picker.service';

Expand Down Expand Up @@ -79,6 +79,19 @@ export class MccColorPickerComponent implements AfterContentInit, OnInit, OnDest
}
private _reverseUsedColor: boolean = false;


/**
* Set position of used colors collection
*/
@Input()
get usedColorsPosition(): MccColorPickerUsedColorPosition {
return this._usedColorsPosition;
}
set usedColorsPosition(position: MccColorPickerUsedColorPosition) {
this._usedColorsPosition = position;
}
private _usedColorsPosition: MccColorPickerUsedColorPosition = 'top';

/**
* Hide the hexadecimal color forms.
*/
Expand Down

0 comments on commit d199e04

Please sign in to comment.