|
1 | 1 | <h1>Demo</h1> |
2 | 2 |
|
3 | | -<div> |
| 3 | +<div class="content"> |
4 | 4 |
|
5 | 5 | <ngx-input-counter [(ngModel)]="qty"></ngx-input-counter> |
6 | 6 |
|
7 | 7 | Value: {{qty}} |
8 | 8 |
|
9 | 9 | <h2>Custom style</h2> |
10 | 10 |
|
11 | | -<ngx-input-counter class="custom" [(ngModel)]="custom" [max]="5" [min]="0"></ngx-input-counter> |
| 11 | +<ngx-input-counter class="custom" [(ngModel)]="custom" [max]="5" [min]="0"> |
| 12 | + <ng-container ngProjectAs="[minus]"> |
| 13 | + <ng-template let-step="step" let-min="min" let-value="value"> |
| 14 | + <svg *ngIf="custom !== min + step" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6"> |
| 15 | + <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 12h-15" /> |
| 16 | + </svg> |
| 17 | + <svg *ngIf="custom == min + step" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6"> |
| 18 | + <path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" /> |
| 19 | + </svg> |
| 20 | + </ng-template> |
| 21 | + </ng-container> |
| 22 | +</ngx-input-counter> |
12 | 23 |
|
13 | 24 | Value: {{custom}} |
14 | 25 |
|
| 26 | +<h2>Custom style 2</h2> |
| 27 | + |
| 28 | +<!-- <small>Using SVG icons</small> --> |
| 29 | + |
| 30 | +<div style="display: flex;"> |
| 31 | + |
| 32 | +<ngx-input-counter class="custom-plus" style="margin: auto;" [(ngModel)]="custom" [max]="5" [min]="0" *ngIf="custom>0"> |
| 33 | + <ng-template plus> |
| 34 | + <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"> |
| 35 | + <path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" /> |
| 36 | + </svg> |
| 37 | + </ng-template> |
| 38 | + <ng-template minus let-step="step" let-min="min" let-value="value"> |
| 39 | + <svg *ngIf="custom !== min + step" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"> |
| 40 | + <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 12h-15" /> |
| 41 | + </svg> |
| 42 | + <svg *ngIf="custom == min + step" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="#EF2F35"> |
| 43 | + <path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" /> |
| 44 | + </svg> |
| 45 | + </ng-template> |
| 46 | +</ngx-input-counter> |
| 47 | +</div> |
| 48 | + |
| 49 | +<h2>Custom Template prop</h2> |
| 50 | +<div> |
| 51 | + <ng-template #plusTemplate> |
| 52 | + <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" style="width: 24px;height: 24px;"> |
| 53 | + <path stroke-linecap="round" stroke-linejoin="round" d="M21 7.5V18M15 7.5V18M3 16.811V8.69c0-.864.933-1.406 1.683-.977l7.108 4.061a1.125 1.125 0 010 1.954l-7.108 4.061A1.125 1.125 0 013 16.811z" /> |
| 54 | + </svg> |
| 55 | + </ng-template> |
| 56 | + <ngx-input-counter |
| 57 | + style="margin: auto;" |
| 58 | + [(ngModel)]="custom" |
| 59 | + (change)="onChange($event)" |
| 60 | + [max]="5" |
| 61 | + [min]="0" |
| 62 | + [minusTemplate]="plusTemplate"> |
| 63 | + </ngx-input-counter> |
| 64 | +</div> |
| 65 | + |
15 | 66 | <h2>Form</h2> |
16 | 67 |
|
17 | 68 | <div [formGroup]="myForm"> |
|
0 commit comments