Skip to content

Commit

Permalink
feat: merge nested themes for client api
Browse files Browse the repository at this point in the history
  • Loading branch information
yarastqt committed Apr 21, 2020
1 parent 24f3f94 commit 1049ff5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import toColor from 'color'
import Color from 'color'
import deepmerge from 'deepmerge'

import { ThemeTokens } from './core/token.h'

export function theme(shape1: ThemeTokens, shape2?: ThemeTokens): ThemeTokens {
return shape1
export function theme(shape1: ThemeTokens, shape2: ThemeTokens = {}): ThemeTokens {
return deepmerge(shape1, shape2)
}

export function color(inputColor: string, options: { h?: number; s?: number; l?: number }): string {
let color = toColor(inputColor)
return color.hsl(options.h, options.s, options.l).hex()
return Color(inputColor)
.hsl(options.h, options.s, options.l)
.hex()
}

0 comments on commit 1049ff5

Please sign in to comment.