File tree Expand file tree Collapse file tree 3 files changed +4
-189
lines changed
Expand file tree Collapse file tree 3 files changed +4
-189
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11import chroma from 'chroma-js' ;
22import colorResult from './colorResult' ;
3- import colors from './data/colors' ;
43import { checkParam , initalOptions } from './helpers' ;
54import 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 }
Original file line number Diff line number Diff line change @@ -2,8 +2,6 @@ import getPalette from '../src/main';
22
33const stringPalette = getPalette ( '#FFBD00' ) ;
44
5- const colorNameStringPalette = getPalette ( 'olivedrab' ) ;
6-
75const 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-
6042const 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-
10381test ( 'return object palette' , ( ) => {
10482 expect ( objectPalette ) . toEqual ( objectPaletteReturn ) ;
10583} ) ;
You can’t perform that action at this time.
0 commit comments