@taiga-ui/kit
Version:
Taiga UI Angular main components kit
41 lines (37 loc) • 1.39 kB
JavaScript
import * as i0 from '@angular/core';
import { Pipe } from '@angular/core';
class TuiAutoColorPipe {
transform(text) {
return tuiAutoColor(text);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: TuiAutoColorPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.21", ngImport: i0, type: TuiAutoColorPipe, isStandalone: true, name: "tuiAutoColor" }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: TuiAutoColorPipe, decorators: [{
type: Pipe,
args: [{ name: 'tuiAutoColor' }]
}] });
/**
* Converts a string to an HSL color
* @param value string to convert
* @return HSL color string
*/
function tuiAutoColor(value) {
if (value === '') {
return '';
}
let hash = 0;
for (let i = 0; i < value.length; i++) {
hash = value.charCodeAt(i) + ((hash << 5) - hash);
hash &= hash;
}
const hue = hash % 360;
const saturation = 60 + (hash % 5);
const lightness = 80 + (hash % 5);
return `hsl(${hue},${saturation}%,${lightness}%)`;
}
/**
* Generated bundle index. Do not edit.
*/
export { TuiAutoColorPipe, tuiAutoColor };
//# sourceMappingURL=taiga-ui-kit-pipes-auto-color.mjs.map