Skip to content
Snippets Groups Projects
slider.component.ts 1.24 KiB
Newer Older
  • Learn to ignore specific revisions
  • mechtelm's avatar
    mechtelm committed
    import { Component, EventEmitter, Output } from '@angular/core';
    import { ElementComponent } from '../element-component.directive';
    import { SliderElement } from '../models/slider-element';
    
    mechtelm's avatar
    mechtelm committed
    import { FormElementComponent } from '../form-element-component.directive';
    
    mechtelm's avatar
    mechtelm committed
    
    @Component({
      selector: 'app-slider',
      template: `
        <div [style.display]="'flex'"
             [style.background-color]="elementModel.backgroundColor"
             [style.width.%]="100"
             [style.height.%]="100">
    
    mechtelm's avatar
    mechtelm committed
          <div *ngIf="elementModel.showValues">{{elementModel.minValue | number:'.0'}}</div>
    
    mechtelm's avatar
    mechtelm committed
          <mat-slider
    
    mechtelm's avatar
    mechtelm committed
                  [formControl]="elementFormControl"
    
    mechtelm's avatar
    mechtelm committed
                  [style.width.%]="100"
                  [style.height.%]="100"
                  [max]="elementModel.maxValue"
                  [min]="elementModel.minValue">
          </mat-slider>
    
    mechtelm's avatar
    mechtelm committed
          <div *ngIf="elementModel.showValues">{{elementModel.maxValue | number:'.0'}}</div>
    
    mechtelm's avatar
    mechtelm committed
        </div>
      `,
      styles: [
        '.dynamic-image{width: 100%; height: fit-content}',
    
    mechtelm's avatar
    mechtelm committed
        '.static-image{ width: 100%; height: 100%; object-fit: contain}',
        ':host ::ng-deep .mat-slider-thumb{border-radius: 0; width: 10px; height: 40px; bottom: -15px}'
    
    mechtelm's avatar
    mechtelm committed
      ]
    })
    
    mechtelm's avatar
    mechtelm committed
    export class SliderComponent extends FormElementComponent {
    
    mechtelm's avatar
    mechtelm committed
      elementModel!: SliderElement;
    }