diff --git a/src/goods-action-icon/index.js b/src/goods-action-icon/index.js index d2a030684..1137a2bb6 100644 --- a/src/goods-action-icon/index.js +++ b/src/goods-action-icon/index.js @@ -12,6 +12,7 @@ export default createComponent({ ...routeProps, text: String, icon: String, + color: String, info: [Number, String], iconClass: null }, @@ -20,22 +21,31 @@ export default createComponent({ onClick(event) { this.$emit('click', event); route(this.$router, this); + }, + + genIcon() { + const slot = this.slots('icon'); + + if (slot) { + return
{slot}
; + } + + return ( + + ); } }, render() { return (
- {this.slots('icon') ? ( -
{this.slots('icon')}
- ) : ( - - )} + {this.genIcon()} {this.slots() || this.text}
); diff --git a/src/goods-action/README.md b/src/goods-action/README.md index 3913991db..b723ad885 100644 --- a/src/goods-action/README.md +++ b/src/goods-action/README.md @@ -56,6 +56,18 @@ Use `info` prop to show badge in icon ``` +### Custom Icon Color + +```html + + + + + + + +``` + ### Custom Button Color ```html @@ -81,6 +93,7 @@ Use `info` prop to show badge in icon |------|------|------|------| | text | Button text | *string* | - | | icon | Icon | *string* | - | +| color `v2.4.2` | Icon color | *string* | `#323233` | | icon-class | Icon class name | *any* | `''` | | info | Content of the badge | *string \| number* | - | | url | Link | *string* | - | diff --git a/src/goods-action/README.zh-CN.md b/src/goods-action/README.zh-CN.md index e13ca1098..a9121dfe5 100644 --- a/src/goods-action/README.zh-CN.md +++ b/src/goods-action/README.zh-CN.md @@ -56,9 +56,23 @@ export default { ``` +### 自定义图标颜色 + +通过 GoodsActionIcon 的`color`属性可以自定义图标的颜色 + +```html + + + + + + + +``` + ### 自定义按钮颜色 -通过`color`属性可以自定义按钮的颜色,支持传入`linear-gradient`渐变色 +通过 GoodsActionButton 的`color`属性可以自定义按钮的颜色,支持传入`linear-gradient`渐变色 ```html @@ -83,6 +97,7 @@ export default { |------|------|------|------| | text | 按钮文字 | *string* | - | | icon | 图标 | *string* | - | +| color `v2.4.2` | 图标颜色 | *string* | `#323233` | | icon-class | 图标额外类名 | *any* | - | | info | 图标右上角徽标的内容 | *string \| number* | - | | url | 点击后跳转的链接地址 | *string* | - | diff --git a/src/goods-action/demo/index.vue b/src/goods-action/demo/index.vue index 2fe00b579..0c39a2126 100644 --- a/src/goods-action/demo/index.vue +++ b/src/goods-action/demo/index.vue @@ -10,7 +10,7 @@ - + @@ -20,6 +20,16 @@ + + + + + + + + + + @@ -35,25 +45,29 @@ export default { i18n: { 'zh-CN': { - clickIcon: '点击图标', - clickButton: '点击按钮', icon1: '客服', icon2: '购物车', icon3: '店铺', button1: '加入购物车', button2: '立即购买', - title2: '徽标提示', + iconInfo: '徽标提示', + collected: '已收藏', + clickIcon: '点击图标', + clickButton: '点击按钮', + customIconColor: '自定义图标颜色', customButtonColor: '自定义按钮颜色' }, 'en-US': { - clickIcon: 'Click Icon', - clickButton: 'Click Button', icon1: 'Icon1', icon2: 'Icon2', icon3: 'Icon3', button1: 'Button1', button2: 'Button2', - title2: 'Icon info', + iconInfo: 'Icon info', + collected: 'Collected', + clickIcon: 'Click Icon', + clickButton: 'Click Button', + customIconColor: 'Custom Icon Color', customButtonColor: 'Custom Button Color' } }, diff --git a/src/goods-action/test/__snapshots__/demo.spec.js.snap b/src/goods-action/test/__snapshots__/demo.spec.js.snap index 7e1ee1706..1cc517051 100644 --- a/src/goods-action/test/__snapshots__/demo.spec.js.snap +++ b/src/goods-action/test/__snapshots__/demo.spec.js.snap @@ -35,6 +35,25 @@ exports[`renders demo correctly 1`] = ` +
+
+
+
+ +
客服 +
+
+
+ +
购物车 +
+
+
+ +
已收藏 +
+
+