Skip to content

Commit

Permalink
docs(core): 📖 添加基础使用文档
Browse files Browse the repository at this point in the history
  • Loading branch information
skiyee committed Apr 2, 2024
1 parent 0fe885f commit 42cece2
Showing 1 changed file with 142 additions and 2 deletions.
144 changes: 142 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,151 @@ pnpm install @claxjs/ucv

## <a name="usage">🎯 使用</a>

待添加
会不断添加详细使用文档,目前只是基础使用部分(若方便的话,朋友们可以先看测试用例)

细节方面还需要补充 💜

### Slot(插槽)

``` javascript
const clax = ucv({
base: {
root: 'base-root-style-1',
title: 'base-title-style-1'
}
})

const { root, title } = clax()

/**
* root() => 'base-root-style-1'
* title() => 'base-title-style-1'
*/
```

### Vars(变量)

``` javascript
const clax = ucv({
base: {
root: 'base-root-style-1',
},
vars: {
color: {
primary: {
root: 'vars-color-primary-root-style-1'
},
},
disabled: {
true: {
root: 'vars-disabled-true-root-style-1'
}
}
}
})

const { root } = clax({ color: 'primary', disabled: true })
/**
* root() => 'base-root-style-1 vars-color-primary-root-style-1 vars-disabled-true-root-style-1'
*/
```

### DefaultProps(默认属性)

``` javascript
const clax = ucv({
base: {
root: 'base-root-style-1',
},
vars: {
color: {
primary: {
root: 'vars-color-primary-root-style-1',
},
},
disabled: {
true: {
root: 'vars-disabled-true-root-style-1',
},
},
},
defaultProps: {
color: 'primary',
disabled: true,
},
})

const { root } = clax()
/**
* root() => 'base-root-style-1 vars-color-primary-root-style-1 vars-disabled-true-root-style-1'
*/
```

### Combos(组合变量)

``` javascript
const clax = ucv({
base: {
root: 'base-root-style-1',
title: 'base-title-style-1',
},
vars: {
color: {
primary: {
root: 'vars-color-primary-root-style-1',
},
secondary: {
root: 'vars-color-secondary-root-style-1',
title: 'vars-color-secondary-title-style-1',
},
},
disabled: {
true: {
root: 'vars-disabled-true-root-style-1',
},
false: {
root: 'vars-disabled-false-root-style-1',
title: 'vars-disabled-false-title-style-1',
},
},
},
combosVars: [
{
color: 'primary',
disabled: true,
class: {
root: 'combos-vars-color-primary-disabled-true-root-style-1',
},
},
{
color: ['primary', 'secondary'],
disabled: false,
class: {
root: 'combos-vars-color-primary-disabled-false-root-style-1',
},
},
],
defaultProps: {
color: 'primary',
disabled: true,
},
})

const { root } = clax()
const { title } = clax({ color: 'secondary', disabled: false })

/**
* root() => 'base-root-style-1 vars-color-primary-root-style-1 vars-disabled-true-root-style-1 combos-vars-color-primary-disabled-true-root-style-1'
*
* root({ color: 'primary', disabled: false }) => 'base-root-style-1 vars-color-primary-root-style-1 vars-disabled-false-root-style-1 combos-vars-color-primary-disabled-false-root-style-1'
*
* title() => 'base-title-style-1 vars-color-secondary-title-style-1 vars-disabled-false-title-style-1'
*/
```

## <a name="todo">👀 待办</a>

- [ ] 添加语法糖
- [ ] 添加插槽语法糖
- [ ] 解决工具类冲突

## <a name="why">❓ WHY</a>
Expand Down

0 comments on commit 42cece2

Please sign in to comment.