Skip to content

Commit

Permalink
feat(button): add third-party icon support (jd-opensource#1018)
Browse files Browse the repository at this point in the history
  • Loading branch information
p3psi-boo authored Feb 22, 2022
1 parent 795a0b9 commit ae26d18
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/packages/__VUE/button/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ app.use(Button);

:::

#### 自定义图标

参照 `Icon` 组件说明中的自定义图标,其中 `icon-font-class-name` 对应 Icon 组件的 `font-class-name``icon-class-prefix` 对应 Icon 组件的 `class-prefix`

```html
<template>
<nut-button shape="square" plain type="primary" icon-font-class-name="iconfont" icon-class-prefix="icon" icon="close"></nut-button>
</template>
```

### 按钮尺寸

支持 `large``normal``small``mini` 四种尺寸,默认为 `normal`
Expand Down
15 changes: 14 additions & 1 deletion src/packages/__VUE/button/index.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
<button :class="classes" :style="getStyle" @click="handleClick">
<view class="nut-button__warp">
<nut-icon class="nut-icon-loading" v-if="loading"></nut-icon>
<nut-icon :class="icon" v-if="icon && !loading" :name="icon"></nut-icon>
<nut-icon
v-if="icon && !loading"
:name="icon"
:class-prefix="iconClassPrefix"
:font-class-name="iconFontClassName"
></nut-icon>
<view :class="{ text: icon || loading }" v-if="$slots.default">
<slot></slot>
</view>
Expand Down Expand Up @@ -55,6 +60,14 @@ export default create({
icon: {
type: String,
default: ''
},
iconClassPrefix: {
type: String,
default: 'nut-icon'
},
iconFontClassName: {
type: String,
default: 'nutui-iconfont'
}
},
emits: ['click'],
Expand Down
15 changes: 14 additions & 1 deletion src/packages/__VUE/button/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
<view :class="classes" :style="getStyle" @click="handleClick">
<view class="nut-button__warp">
<nut-icon class="nut-icon-loading" v-if="loading"></nut-icon>
<nut-icon :class="icon" v-if="icon && !loading" :name="icon"></nut-icon>
<nut-icon
v-if="icon && !loading"
:name="icon"
:class-prefix="iconClassPrefix"
:font-class-name="iconFontClassName"
></nut-icon>
<view :class="{ text: icon || loading }" v-if="$slots.default">
<slot></slot>
</view>
Expand Down Expand Up @@ -56,6 +61,14 @@ export default create({
icon: {
type: String,
default: ''
},
iconClassPrefix: {
type: String,
default: 'nut-icon'
},
iconFontClassName: {
type: String,
default: 'nutui-iconfont'
}
},
emits: ['click'],
Expand Down

0 comments on commit ae26d18

Please sign in to comment.