Skip to content

Latest commit

 

History

History
60 lines (47 loc) · 1.73 KB

README.md

File metadata and controls

60 lines (47 loc) · 1.73 KB

OpenCIAg | ciag-colorful

Build Status Maintainability Test Coverage npm version

Install

npm install @ciag/colorful

Usage example with Angular

Add the service

import { NgModule } from '@angular/core';
import { ColorService } from '@ciag/colorful';
import { PalleteBasedColorGenerator } from '@ciag/colorful/generator';
import { PalleteFactory, NEBULAR_CORPORATE } from '@ciag/colorful/pallete';

const palleteFactory = new PalleteFactory();
const pallete = palleteFactory.makeFromArray(NEBULAR_CORPORATE);

@NgModule({
    providers: [{
        provide: ColorService,
        useValue: new ColorService(new PalleteBasedColorGenerator(pallete,0.3))
    ]}
})
export class AppModule{}

Use the service

import { Component } from '@angular/core';
import { ColorService } from '@ciag/colorful';

@Component({
    selector: 'colorful-component',
    templateUri: './colorful-component.html',
})
export class ColorfulComponent {

    constructor(
        private colorService: ColorService,
    ) {
        this.colorService.makeColor();
        //make a new color
        this.colorService.makeColor();

        this.colorSerice.makeColor('unique');
        //make the same color
        this.colorSerice.makeColor('unique');
    }

}