0.3.1 • Published 3 years ago

@openpalette/core v0.3.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@openpalette/core

A library for interacting with OpenPalette data.

npm install --save @openpalette/core

OR

yarn add @openpalette/core

API


getPalettes

Returns an array of all palettes.

Type: function getPalettes(): OpenPalette[]

Example

import { getPalettes } from '@openpalette/core';

console.log(getPalettes()); // => [{ id: 0, colors: ['#ee7722', ...]}, ...]

getPaletteById

Returns a specific palette.

Throws an error if the palette ID is invalid.

Type: function getPaletteById(paletteId: number): OpenPalette

Example

import { getPaletteById } from '@openpalette/core';

console.log(getPaletteById(0)); // => { id: 0, colors: ['#ee7722', ...]}

isValidPaletteId

Validate a palette ID.

Returns true for integers within the range 0, 9999 inclusive.

Type: function isValidPaletteId(paletteId: number): boolean

Example

import { isValidPaletteId } from '@openpalette/core';

console.log(isValidPaletteId(0)); // => true
console.log(isValidPaletteId(0.5)); // => false
console.log(isValidPaletteId(-1)); // => false

getColors

Returns the array of colors for the specified OpenPalette.

Type: function getColors(paletteId: number): OpenPaletteColors

Example

import { getColors } from '@openpalette/core';

console.log(getColors(0)); // => ['#ee7722', '#dd44cc', '#ee8833', '#cc99bb', '#775511']
0.3.0

3 years ago

0.3.1

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago