Skip to content

Commit

Permalink
feat(style-provider): support custom tag
Browse files Browse the repository at this point in the history
  • Loading branch information
BeADre committed Sep 18, 2022
1 parent d4353b5 commit ed653e6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
6 changes: 5 additions & 1 deletion packages/varlet-ui/src/style-provider/StyleProvider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ export default defineComponent({
type: Object as PropType<StyleVars>,
default: () => ({}),
},
tag: {
type: String,
default: 'div',
},
},
setup(props, { slots }) {
return () =>
h(
'div',
props.tag,
{
class: n(),
style: formatStyleVars(props.styleVars),
Expand Down
7 changes: 4 additions & 3 deletions packages/varlet-ui/src/style-provider/docs/en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ const toggleRootTheme = () => {

### Props

| Prop | Description | Type | Default |
| --- | --- | --- | --- |
| `style-vars` | CSS variables | _Record<string, string>_ | `{}` |
| Prop | Description | Type | Default |
|--------------|---------------|--------------------------|---------|
| `style-vars` | CSS variables | _Record<string, string>_ | `{}` |
| `tag` | Tag name | _string_ | `div` |

### Slots

Expand Down
5 changes: 3 additions & 2 deletions packages/varlet-ui/src/style-provider/docs/zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@ const toggleRootTheme = () => {

### 属性

| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| 参数 | 说明 | 类型 | 默认值 |
|--------------| --- |--------------------------| -- |
| `style-vars` | css 变量 | _Record<string, string>_ | `{}` |
| `tag` | 自定义标签名 | _string_ | `div` |

### 插槽

Expand Down
1 change: 1 addition & 0 deletions packages/varlet-ui/types/styleProvider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type StyleVars = Record<string, string>

export interface StyleProviderProps extends BasicAttributes {
styleVars?: StyleVars
tag?: string
}

export class StyleProviderComponent extends VarComponent {
Expand Down

0 comments on commit ed653e6

Please sign in to comment.