11import { transparentize } from 'polished'
2+ import { cssDiv } from '../utils/css'
3+ import { cssLength } from '../utils/length'
24
35const defaultPalette = {
46 white : '#ffffff' ,
@@ -50,23 +52,22 @@ const defaultPalette = {
5052 } ,
5153}
5254
55+ export type CSSLength = number | string
56+
57+ export interface SolvedTextColor {
58+ main : string
59+ inverted : string
60+ light : string
61+ dark : string
62+ }
63+
5364export interface SolvedTheme {
5465 name : string
5566 color : {
5667 solvedAc : string
5768 text : {
58- primary : {
59- main : string
60- inverted : string
61- light : string
62- dark : string
63- }
64- secondary : {
65- main : string
66- inverted : string
67- light : string
68- dark : string
69- }
69+ primary : SolvedTextColor
70+ secondary : SolvedTextColor
7071 }
7172 background : {
7273 page : string
@@ -95,7 +96,7 @@ export interface SolvedTheme {
9596 }
9697 styles : {
9798 border : ( color ?: string ) => string
98- shadow : ( color ?: string , length ?: number ) => string
99+ shadow : ( color ?: string , length ?: CSSLength ) => string
99100 }
100101}
101102
@@ -139,10 +140,11 @@ const Light: SolvedTheme = {
139140 styles : {
140141 border : ( color ?: string ) =>
141142 `1px solid ${ color || defaultPalette . gray [ 200 ] } ` ,
142- shadow : ( color ?: string , length ?: number ) =>
143- `${ transparentize ( 0.6 , color || defaultPalette . gray [ 200 ] ) } 0px ${
144- ( length || 8 ) / 2
145- } px ${ length || 8 } px`,
143+ shadow : ( color ?: string , length ?: CSSLength ) =>
144+ `${ transparentize (
145+ 0.6 ,
146+ color || defaultPalette . gray [ 200 ]
147+ ) } 0px ${ cssLength ( cssDiv ( length || 8 , 2 ) ) } ${ cssLength ( length || 8 ) } `,
146148 } ,
147149}
148150
@@ -177,10 +179,11 @@ const Dark: SolvedTheme = {
177179 styles : {
178180 border : ( color ?: string ) =>
179181 `1px solid ${ ( color || defaultPalette . gray [ 700 ] ) . toString ( ) } ` ,
180- shadow : ( color ?: string , length ?: number ) =>
181- `${ transparentize ( 0.6 , color || defaultPalette . gray [ 200 ] ) } 0px ${
182- ( length || 8 ) / 2
183- } px ${ length || 8 } px`,
182+ shadow : ( color ?: string , length ?: CSSLength ) =>
183+ `${ transparentize (
184+ 0.6 ,
185+ color || defaultPalette . gray [ 200 ]
186+ ) } 0px ${ cssLength ( cssDiv ( length || 8 , 2 ) ) } ${ cssLength ( length || 8 ) } `,
184187 } ,
185188}
186189
@@ -200,10 +203,11 @@ const Black: SolvedTheme = {
200203 styles : {
201204 border : ( color ?: string ) =>
202205 `1px solid ${ ( color || defaultPalette . gray [ 900 ] ) . toString ( ) } ` ,
203- shadow : ( color ?: string , length ?: number ) =>
204- `${ transparentize ( 0.6 , color || defaultPalette . gray [ 200 ] ) } 0px ${
205- ( length || 8 ) / 2
206- } px ${ length || 8 } px`,
206+ shadow : ( color ?: string , length ?: CSSLength ) =>
207+ `${ transparentize (
208+ 0.6 ,
209+ color || defaultPalette . gray [ 200 ]
210+ ) } 0px ${ cssLength ( cssDiv ( length || 8 , 2 ) ) } ${ cssLength ( length || 8 ) } `,
207211 } ,
208212}
209213
0 commit comments