projects/i-components/src/lib/pipes/dimensions.pipe.ts
Pipe to apply dimensions to a component part according to height or width changes.
Name | dimensionsPipe |
Pure | true |
transform | |||||||||
transform(value: any, ...args: any[])
|
|||||||||
Parameters :
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;
}
}