File

projects/i-components/src/lib/pipes/dimensions.pipe.ts

Description

Pipe to apply dimensions to a component part according to height or width changes.

Metadata

Name dimensionsPipe
Pure true

Methods

transform
transform(value: any, ...args: any[])
Parameters :
Name Type Optional
value any No
args any[] No
Returns : any
import { Pipe, PipeTransform } from '@angular/core';

/**
 * Pipe to apply dimensions to a component part according
 * to height or width changes.
 */
@Pipe({
  name: 'dimensionsPipe',
  pure: true, //can be omitted as default value
})
export class DimensionsPipe implements PipeTransform {
  // eslint-disable-next-line @typescript-eslint/ban-types
  transform(value: any, ...args: any[]): any {
    const defaultValue = args[0] === 'undefined' ? undefined : '100%';
    return value > 0 ? `${value}px` : defaultValue;
  }
}

result-matching ""

    No results matching ""