Skip to content

Commit 5153345

Browse files
committed
Allow multiple CSS values over arrays
1 parent 0592bff commit 5153345

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,15 @@ export function useStyle<T extends FreeStyle>(Style: T): T {
129129
* React hook for dynamically registering CSS values in a component.
130130
*/
131131
export function useCss(...cssValue: CssValue[]): string {
132-
const { className, Style } = React.useMemo(() => css(cssValue), cssValue);
132+
const { className, Style } = React.useMemo(() => css(...cssValue), cssValue);
133133
useStyle(Style);
134134
return className;
135135
}
136136

137137
/**
138138
* Create a cached CSS object.
139139
*/
140-
export function css(cssValue: CssValue): CachedCss {
140+
export function css(...cssValue: CssValue[]): CachedCss {
141141
const Style = create();
142142
const className = cssValueToString(Style, cssValue);
143143
return new CachedCss(className, Style);
@@ -148,10 +148,10 @@ export function css(cssValue: CssValue): CachedCss {
148148
*/
149149
export function styled<T extends keyof JSX.IntrinsicElements>(
150150
type: T,
151-
cssValue?: CssValue
151+
...cssValue: CssValue[]
152152
) {
153153
const displayName = `styled(${type})`;
154-
const style = css(cssValue);
154+
const style = css(...cssValue);
155155

156156
return Object.assign(
157157
React.forwardRef(function Component(
@@ -300,11 +300,13 @@ export interface CssValueArray extends Array<CssValue> {}
300300
* Any supported CSS value.
301301
*/
302302
export type CssValue =
303+
| string
304+
| null
305+
| undefined
306+
| void
303307
| Css
304308
| CachedCss
305309
| ComputedCss
306-
| string
307-
| void
308310
| CssValueArray;
309311

310312
/**

0 commit comments

Comments
 (0)