Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

magic-color

Package Overview
Dependencies
Maintainers
0
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

magic-color - npm Package Compare versions

Comparing version 1.3.0 to 2.0.0

150

dist/index.d.ts

@@ -1,3 +0,5 @@

import { ColorType, Colors, Opacity, RgbColor, HslColor, HsbColor, LabColor } from '@magic-color/core';
import { ColorType, Colors, Opacity, Magicolor, guessType, SupportTypes } from '@magic-color/core';
export * from '@magic-color/core';
import { random, theme, deltaE, getColorName } from '@magic-color/theme';
export { ThemeMetas, ThemeOptions } from '@magic-color/theme';

@@ -77,49 +79,2 @@ /**

interface ColorObject<T extends ColorType> {
type: T;
values: Colors[T];
alpha: Opacity;
}
declare class Magicolor<T extends ColorType> implements ColorObject<T> {
type: T;
values: Colors[T];
alpha: Opacity;
cloned: boolean;
private _stack;
constructor(value: Colors[T] | Record<string, number>, type?: T, alpha?: Opacity);
constructor(v1: number, v2: number, v3: number, type?: T, alpha?: Opacity);
private toString;
get name(): string;
toRgb(): Magicolor<'rgb'>;
toHex(): Magicolor<'hex'>;
toHsl(): Magicolor<'hsl'>;
toHsb(): Magicolor<'hsb'>;
toLab(): Magicolor<'lab'>;
to(type: ColorType): Magicolor<"hex"> | Magicolor<"rgb"> | Magicolor<"hsl"> | Magicolor<"hsb"> | Magicolor<"lab">;
hex(): string;
rgb(round?: boolean): RgbColor;
hsl(round?: boolean): HslColor;
hsb(round?: boolean): HsbColor;
lab(round?: boolean): LabColor;
value<K extends ColorType = T>(type?: K, round?: boolean): Colors[K];
css(): string;
css(typeOrWithAlpha: ColorType): string;
css(typeOrWithAlpha: ColorType, withAlpha: boolean): string;
css(typeOrWithAlpha: ColorType, withAlpha: boolean, round: boolean): string;
css(typeOrWithAlpha: boolean): string;
css(typeOrWithAlpha: boolean, round: boolean): string;
private _push;
get history(): Magicolor<any>[];
get last(): Magicolor<any>;
get first(): Magicolor<any>;
revert(deep?: number): void;
clear(): void;
clone(): Magicolor<T>;
set<T extends ColorType>(operate: string, value: unknown): this;
get(operate: string): number;
}
declare function deltaE(a: string, b: string, Kl?: number, Kc?: number, Kh?: number): number;
/**

@@ -137,103 +92,9 @@ * Color Hash

interface ThemeMetas {
50: string;
100: string;
200: string;
300: string;
400: string;
500: string;
600: string;
700: string;
800: string;
900: string;
950: string;
}
interface Shade {
key: keyof ThemeMetas;
color: string;
}
interface NormalizedShade extends Shade {
delta: number;
lightnessDiff: number;
}
interface HslShade extends Shade {
hsl: [number, number, number];
}
interface BasicColorShades {
id: string;
name: string;
shades: Shade[];
}
interface ClosestColorShades extends BasicColorShades {
shades: NormalizedShade[];
closestShade: NormalizedShade;
closestShadeLightness: NormalizedShade;
}
interface ThemeOptions {
/**
* Output color type
*
* @default same type as input
*/
type?: ColorType;
/**
* Custom render output color
*
* @param meta [name, color]
* @returns [CustomedName, CustomedColor]
*/
render?: (meta: [keyof ThemeMetas, string]) => [string, string];
}
interface GenerateMeta extends BasicColorShades {
shades: HslShade[];
}
declare function getColorName(color: string): string;
/**
* Generate a theme from a color
*
* @example
* ```ts
* theme('#9955FF')
* =>
{
"50": "#faf7ff",
"100": "#f5eeff",
"200": "#e6d5ff",
"300": "#d6bbff",
"400": "#b888ff",
"500": "#9955ff",
"600": "#8a4de6",
"700": "#5c3399",
"800": "#452673",
"900": "#2e1a4d",
"950": "#1f1133",
}
* ```
*
* @param color string color, if not provided, a random color will be generated
* @param options ThemeOptions
* @returns ThemeMetas
*/
declare function theme(color?: string, options?: ThemeOptions): ThemeMetas;
/**
* Generate a random color
*
* @param type ColorType, default is 'hex'
* @returns any color type
*/
declare function random(type?: ColorType): string;
declare const SupportTypes: string[];
declare function valid(color: string): boolean;
interface MagicolorInstance {
<T extends ColorType>(value: Colors[T] | Record<string, number>, type?: T, alpha?: Opacity): Magicolor<T>;
<T extends ColorType = 'rgb'>(v1: number, v2: number, v3: number, type?: T, alpha?: Opacity): Magicolor<T>;
valid: typeof valid;
valid: typeof guessType;
random: typeof random;
hash: typeof hash;
theme: typeof theme;
nameOf: typeof getColorName;
wcag: typeof calcWCAG;

@@ -246,5 +107,6 @@ apca: typeof calcAPCA;

deltaE: typeof deltaE;
nameOf: typeof getColorName;
}
declare const mc: MagicolorInstance;
export { type BasicColorShades, type ClosestColorShades, type ColorObject, type GenerateMeta, Magicolor, type MagicolorInstance, type ThemeMetas, type ThemeOptions, calcAPCA, calcWCAG, getColorName, getReadableTextColor, hash, isWarmColor, mc, random, reverseAPCA, theme };
export { type MagicolorInstance, mc };

5

package.json
{
"name": "magic-color",
"type": "module",
"version": "1.3.0",
"version": "2.0.0",
"description": "Magic color creator.",

@@ -41,3 +41,4 @@ "author": "Chris <hizyyv@gmail.com>",

"dependencies": {
"@magic-color/core": "1.3.0"
"@magic-color/core": "2.0.0",
"@magic-color/theme": "2.0.0"
},

@@ -44,0 +45,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc