-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: merge nested themes for client api
- Loading branch information
Showing
1 changed file
with
7 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |