Skip to content

Commit

Permalink
docs: update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangfisher committed May 29, 2024
1 parent 1ffcfc2 commit f7d39d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# flexstyled

## 2.0.8

### Patch Changes

- 0d5b3c6: [特性]: 更新`StyledClassName`的入参类型,从`string[]`变更为`(string | undefined)[]`提高容错性

## 2.0.7

### Patch Changes
Expand Down
12 changes: 6 additions & 6 deletions src/className.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { createStyled } from "./styled";
import { CSSRuleObject, StyledObject, StyledOptions } from "./types";
import { isStyledObject } from "./utils";

export type StyledClassName = (...args:string[])=>string
export type StyledClassName = (...args:(string | undefined)[])=>string

export function className(styles:CSSRuleObject,options?:StyledOptions): StyledClassName
export function className(styles:CSSRuleObject,combindStyles?:(StyledObject | StyledClassName)[],options?:StyledOptions):StyledClassName
Expand All @@ -31,11 +31,11 @@ export function className(){
typeof(arguments[1])=='object' ? arguments[1] : Object.assign({},arguments[2])
) : {}
const combindClasss = (combindStyles || []).map(item=>{
if(typeof item === "function"){
return item()
}else if(isStyledObject(item)){
return item.className
}
try{
return typeof item === "function" ? item() : (isStyledObject(item) ? item.className : '')
}catch{
return ''
}
}).join(" ")
const styleObject = createStyled(styles,options)
return (...args:string[])=>{
Expand Down

0 comments on commit f7d39d7

Please sign in to comment.