kanastra-palette
v0.0.3
Published
Generate color palettes with dynamic base step
Downloads
362
Readme
Kanastra Palette
Kanastra Palette is a TypeScript library for generating color palettes with dynamic base tone determination. Inspired by Palettey, it offers a robust solution for creating balanced color schemes in modern web applications.
Features
- Generates complete color palettes from a single color
- Automatically determines the base tone based on color luminosity
- Creates balanced lighter and darker shades
- Compatible with design frameworks like Tailwind CSS
- Written in TypeScript for enhanced type safety and developer experience
- Includes unit tests for reliability
Installation
npm install kanastra-palette
Usage
import { createPaletteFromColor } from 'kanastra-palette';
// Generate a palette from a color
const primaryPalette = createPaletteFromColor('primary', '#7953e0');
console.log(primaryPalette);
API
createPaletteFromColor(name: string, hex: string, options?: PaletteOptions): Record<string, Record<number, string>>
Generates a complete color palette from a single color.
name
: Name of the palette (e.g., 'primary', 'secondary')hex
: Base color in hexadecimal formatoptions
: Additional options (reserved for future expansions)
Returns an object with the color palette, containing shades from 50 to 900.
Example Output
{
"primary": {
"50": "#fafafa",
"100": "#f5f5f5",
"200": "#e5e5e5",
"300": "#d4d4d4",
"400": "#a3a3a3",
"500": "#737373",
"600": "#525252",
"700": "#3f3f3f",
"800": "#262626",
"900": "#171717"
}
}
Development
To set up the project for development:
- Clone the repository
- Install dependencies:
npm install
- Run tests:
npm test
- Build the project:
npm run build
Please make sure to update tests as appropriate and adhere to the existing coding style.
License
This project is licensed under the MIT License - see the LICENSE file for details.