Skip to content

Commit 7803278

Browse files
author
Ibrahim Odev
committed
[fix] remove color name support
1 parent 2779ce8 commit 7803278

File tree

3 files changed

+4
-189
lines changed

3 files changed

+4
-189
lines changed

src/data/colors.ts

Lines changed: 0 additions & 155 deletions
This file was deleted.

src/main.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import chroma from 'chroma-js';
22
import colorResult from './colorResult';
3-
import colors from './data/colors';
43
import { checkParam, initalOptions } from './helpers';
54
import type { IColorResultOptions, Palette } from './types';
65

7-
const getPalette = (params: Palette[] | Palette | keyof typeof colors | string): any => {
6+
const getPalette = (params: Palette[] | Palette | string): any => {
87
const palette: any = {};
98
if (Array.isArray(params)) {
109
for (let i = 0; i < params.length; i++) {
@@ -36,16 +35,9 @@ const getPalette = (params: Palette[] | Palette | keyof typeof colors | string):
3635
shades: initalOptions.shades,
3736
};
3837

39-
const stringColor = colors[params as keyof typeof colors];
40-
if (colors && stringColor) {
41-
options = Object.assign(initalOptions, {
42-
primaryColor: stringColor ?? initalOptions.primaryColor,
43-
});
44-
} else {
45-
options = Object.assign(initalOptions, {
46-
primaryColor: chroma(params).hex(),
47-
});
48-
}
38+
options = Object.assign(initalOptions, {
39+
primaryColor: chroma(params).hex(),
40+
});
4941

5042
palette['primary'] = colorResult(options);
5143
}

test/lib.test.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import getPalette from '../src/main';
22

33
const stringPalette = getPalette('#FFBD00');
44

5-
const colorNameStringPalette = getPalette('olivedrab');
6-
75
const objectPalette = getPalette({
86
color: '#FFBD00', // required
97
name: 'primary', // required
@@ -41,22 +39,6 @@ const stringPaletteReturn = {
4139
},
4240
};
4341

44-
const colorNameStringPaletteReturn = {
45-
primary: {
46-
'50': '#dcfe8e',
47-
'100': '#cff182',
48-
'200': '#b5d76a',
49-
'300': '#9cbe53',
50-
'400': '#83a63b',
51-
'500': '#6b8e23',
52-
'600': '#537704',
53-
'700': '#3c6000',
54-
'800': '#264b00',
55-
'900': '#183600',
56-
DEFAULT: '#6b8e23',
57-
},
58-
};
59-
6042
const objectPaletteReturn = {
6143
primary: {
6244
'100': '#ffef4e',
@@ -96,10 +78,6 @@ test('return string palette', () => {
9678
expect(stringPalette).toEqual(stringPaletteReturn);
9779
});
9880

99-
test('return color name string palette', () => {
100-
expect(colorNameStringPalette).toEqual(colorNameStringPaletteReturn);
101-
});
102-
10381
test('return object palette', () => {
10482
expect(objectPalette).toEqual(objectPaletteReturn);
10583
});

0 commit comments

Comments
 (0)