feat(GoodsActionButton): add color prop (#4255)

This commit is contained in:
neverland 2019-08-27 17:13:12 +08:00 committed by GitHub
parent 339cbdc1dd
commit a842da803f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 84 additions and 132 deletions

View File

@ -97,7 +97,7 @@ Vue.use(Button);
| type | Can be set to `primary` `info` `warning` `danger` | `string` | `default` | | type | Can be set to `primary` `info` `warning` `danger` | `string` | `default` |
| size | Can be set to `large` `small` `mini` | `string` | `normal` | | size | Can be set to `large` `small` `mini` | `string` | `normal` |
| text | Text | `string` | - | | text | Text | `string` | - |
| color | Color | `string` | - | | color | Color, support linear-gradient | `string` | - |
| icon | Left Icon | `string` | - | | icon | Left Icon | `string` | - |
| tag | HTML Tag | `string` | `button` | | tag | HTML Tag | `string` | `button` |
| native-type | Native Type Attribute | `string` | `''` | | native-type | Native Type Attribute | `string` | `''` |

View File

@ -117,7 +117,7 @@ Vue.use(Button);
| type | 类型,可选值为 `primary` `info` `warning` `danger` | `string` | `default` | 1.6.6 | | type | 类型,可选值为 `primary` `info` `warning` `danger` | `string` | `default` | 1.6.6 |
| size | 尺寸,可选值为 `large` `small` `mini` | `string` | `normal` | - | | size | 尺寸,可选值为 `large` `small` `mini` | `string` | `normal` | - |
| text | 按钮文字 | `string` | - | - | | text | 按钮文字 | `string` | - | - |
| color | 按钮颜色 | `string` | - | 2.1.3 | | color | 按钮颜色,支持传入`linear-gradient`渐变色 | `string` | - | 2.1.3 |
| icon | 左侧图标名称或图片链接,可选值见 Icon 组件 | `string` | - | 2.0.0 | | icon | 左侧图标名称或图片链接,可选值见 Icon 组件 | `string` | - | 2.0.0 |
| tag | HTML 标签 | `string` | `button` | - | | tag | HTML 标签 | `string` | `button` | - |
| native-type | 原生 button 标签 type 属性 | `string` | - | - | | native-type | 原生 button 标签 type 属性 | `string` | - | - |

View File

@ -12,6 +12,7 @@ export default createComponent({
...routeProps, ...routeProps,
type: String, type: String,
text: String, text: String,
color: String,
loading: Boolean, loading: Boolean,
disabled: Boolean disabled: Boolean
}, },
@ -48,6 +49,7 @@ export default createComponent({
square square
size="large" size="large"
type={this.type} type={this.type}
color={this.color}
loading={this.loading} loading={this.loading}
disabled={this.disabled} disabled={this.disabled}
onClick={this.onClick} onClick={this.onClick}

View File

@ -22,26 +22,10 @@ Vue
```html ```html
<van-goods-action> <van-goods-action>
<van-goods-action-icon <van-goods-action-icon icon="chat-o" text="Icon1" @click="onClickIcon" />
icon="chat-o" <van-goods-action-icon icon="cart-o" text="Icon2" @click="onClickIcon" />
text="Icon1" <van-goods-action-button type="warning" text="Button1" @click="onClickButton" />
@click="onClickIcon" <van-goods-action-button type="danger" text="Button2" @click="onClickButton" />
/>
<van-goods-action-icon
icon="cart-o"
text="Icon2"
@click="onClickIcon"
/>
<van-goods-action-button
type="warning"
text="Button1"
@click="onClickButton"
/>
<van-goods-action-button
type="danger"
text="Button2"
@click="onClickButton"
/>
</van-goods-action> </van-goods-action>
``` ```
@ -64,27 +48,22 @@ Use `info` prop to show messages in upper right corner of icon
```html ```html
<van-goods-action> <van-goods-action>
<van-goods-action-icon <van-goods-action-icon icon="chat-o" text="Icon1" />
icon="chat-o" <van-goods-action-icon icon="cart-o" text="Icon2" info="5" />
text="Icon1" <van-goods-action-icon icon="shop-o" text="Icon3" />
/> <van-goods-action-button type="warning" text="Button1" />
<van-goods-action-icon <van-goods-action-button type="danger" text="Button2" />
info="5" </van-goods-action>
icon="cart-o" ```
text="Icon2"
/> ### Custom Button Color
<van-goods-action-icon
icon="shop-o" ```html
text="Icon3" <van-goods-action>
/> <van-goods-action-icon icon="chat-o" text="Icon1" />
<van-goods-action-button <van-goods-action-icon icon="shop-o" text="Icon2" />
type="warning" <van-goods-action-button color="#be99ff" type="warning" text="Button1" />
text="Button1" <van-goods-action-button color="#7232dd" type="danger" text="Button2" />
/>
<van-goods-action-button
type="danger"
text="Button2"
/>
</van-goods-action> </van-goods-action>
``` ```
@ -114,6 +93,7 @@ Use `info` prop to show messages in upper right corner of icon
|------|------|------|------| |------|------|------|------|
| type | Button type, Can be set to `primary` `info` `warning` `danger` | `string` | `default` | | type | Button type, Can be set to `primary` `info` `warning` `danger` | `string` | `default` |
| text | Button text | `string` | - | | text | Button text | `string` | - |
| color | Button color, support linear-gradient | `string` | - |
| primary | Is primary button (red color) | `boolean` | `false` | | primary | Is primary button (red color) | `boolean` | `false` |
| disabled | Whether to disable button | `boolean` | `false` | | disabled | Whether to disable button | `boolean` | `false` |
| loading | Whether show loading status | `boolean` | `false` | | loading | Whether show loading status | `boolean` | `false` |

View File

@ -22,26 +22,10 @@ Vue
```html ```html
<van-goods-action> <van-goods-action>
<van-goods-action-icon <van-goods-action-icon icon="chat-o" text="客服" @click="onClickIcon" />
icon="chat-o" <van-goods-action-icon icon="cart-o" text="购物车" @click="onClickIcon" />
text="客服" <van-goods-action-button type="warning" text="加入购物车" @click="onClickButton" />
@click="onClickIcon" <van-goods-action-button type="danger" text="立即购买" @click="onClickButton" />
/>
<van-goods-action-icon
icon="cart-o"
text="购物车"
@click="onClickIcon"
/>
<van-goods-action-button
type="warning"
text="加入购物车"
@click="onClickButton"
/>
<van-goods-action-button
type="danger"
text="立即购买"
@click="onClickButton"
/>
</van-goods-action> </van-goods-action>
``` ```
@ -64,27 +48,24 @@ export default {
```html ```html
<van-goods-action> <van-goods-action>
<van-goods-action-icon <van-goods-action-icon icon="chat-o" text="客服" />
icon="chat-o" <van-goods-action-icon icon="cart-o" text="购物车" info="5" />
text="客服" <van-goods-action-icon icon="shop-o" text="店铺" />
/> <van-goods-action-button type="warning" text="加入购物车" />
<van-goods-action-icon <van-goods-action-button type="danger" text="立即购买" />
info="5" </van-goods-action>
icon="cart-o" ```
text="购物车"
/> ### 自定义按钮颜色
<van-goods-action-icon
icon="shop-o" 通过`color`属性可以自定义按钮的颜色,支持传入`linear-gradient`渐变色
text="店铺"
/> ```html
<van-goods-action-button <van-goods-action>
type="warning" <van-goods-action-icon icon="chat-o" text="客服" />
text="加入购物车" <van-goods-action-icon icon="shop-o" text="店铺" />
/> <van-goods-action-button color="#be99ff" type="warning" text="加入购物车" />
<van-goods-action-button <van-goods-action-button color="#7232dd" type="danger" text="立即购买" />
type="danger"
text="立即购买"
/>
</van-goods-action> </van-goods-action>
``` ```
@ -114,6 +95,7 @@ export default {
|------|------|------|------|------| |------|------|------|------|------|
| text | 按钮文字 | `string` | - | - | | text | 按钮文字 | `string` | - | - |
| type | 按钮类型,可选值为 `primary` `info` `warning` `danger` | `string` | `default` | 2.0.0 | | type | 按钮类型,可选值为 `primary` `info` `warning` `danger` | `string` | `default` | 2.0.0 |
| color | 按钮颜色,支持传入`linear-gradient`渐变色 | `string` | - | 2.1.8 |
| disabled | 是否禁用按钮 | `boolean` | `false` | - | - | | disabled | 是否禁用按钮 | `boolean` | `false` | - | - |
| loading | 是否显示为加载状态 | `boolean` | `false` | - | - | | loading | 是否显示为加载状态 | `boolean` | `false` | - | - |
| url | 跳转链接 | `string` | - | - | | url | 跳转链接 | `string` | - | - |

View File

@ -3,57 +3,29 @@
<demo-section> <demo-section>
<demo-block :title="$t('basicUsage')"> <demo-block :title="$t('basicUsage')">
<van-goods-action> <van-goods-action>
<van-goods-action-icon <van-goods-action-icon icon="chat-o" :text="$t('icon1')" @click="onClickIcon" />
icon="chat-o" <van-goods-action-icon icon="cart-o" :text="$t('icon2')" @click="onClickIcon" />
:text="$t('icon1')" <van-goods-action-button type="warning" :text="$t('button1')" @click="onClickButton" />
@click="onClickIcon" <van-goods-action-button type="danger" :text="$t('button2')" @click="onClickButton" />
/>
<van-goods-action-icon
icon="cart-o"
:text="$t('icon2')"
@click="onClickIcon"
/>
<van-goods-action-button
type="warning"
:text="$t('button1')"
@click="onClickButton"
/>
<van-goods-action-button
type="danger"
:text="$t('button2')"
@click="onClickButton"
/>
</van-goods-action> </van-goods-action>
</demo-block> </demo-block>
<demo-block :title="$t('title2')"> <demo-block :title="$t('title2')">
<van-goods-action> <van-goods-action>
<van-goods-action-icon <van-goods-action-icon icon="chat-o" :text="$t('icon1')" />
icon="chat-o" <van-goods-action-icon icon="cart-o" info="5" :text="$t('icon2')" />
:text="$t('icon1')" <van-goods-action-icon icon="shop-o" :text="$t('icon3')" />
@click="onClickIcon" <van-goods-action-button type="warning" :text="$t('button1')" />
/> <van-goods-action-button type="danger" :text="$t('button2')" />
<van-goods-action-icon </van-goods-action>
icon="cart-o" </demo-block>
info="5"
:text="$t('icon2')" <demo-block :title="$t('customButtonColor')">
@click="onClickIcon" <van-goods-action>
/> <van-goods-action-icon icon="chat-o" :text="$t('icon1')" />
<van-goods-action-icon <van-goods-action-icon icon="cart-o" :text="$t('icon2')" />
icon="shop-o" <van-goods-action-button color="#be99ff" type="warning" :text="$t('button1')" />
:text="$t('icon3')" <van-goods-action-button color="#7232dd" type="danger" :text="$t('button2')" />
@click="onClickIcon"
/>
<van-goods-action-button
type="warning"
:text="$t('button1')"
@click="onClickButton"
/>
<van-goods-action-button
type="danger"
:text="$t('button2')"
@click="onClickButton"
/>
</van-goods-action> </van-goods-action>
</demo-block> </demo-block>
</demo-section> </demo-section>
@ -70,7 +42,8 @@ export default {
icon3: '店铺', icon3: '店铺',
button1: '加入购物车', button1: '加入购物车',
button2: '立即购买', button2: '立即购买',
title2: '图标提示' title2: '图标提示',
customButtonColor: '自定义按钮颜色'
}, },
'en-US': { 'en-US': {
clickIcon: 'Click Icon', clickIcon: 'Click Icon',
@ -80,7 +53,8 @@ export default {
icon3: 'Icon3', icon3: 'Icon3',
button1: 'Button1', button1: 'Button1',
button2: 'Button2', button2: 'Button2',
title2: 'Icon info' title2: 'Icon info',
customButtonColor: 'Custom Button Color'
} }
}, },
methods: { methods: {

View File

@ -35,5 +35,19 @@ exports[`renders demo correctly 1`] = `
</div> <button class="van-button van-button--warning van-button--large van-button--square van-goods-action-button van-goods-action-button--first van-goods-action-button--warning"><span class="van-button__text">加入购物车</span></button> <button class="van-button van-button--danger van-button--large van-button--square van-goods-action-button van-goods-action-button--last van-goods-action-button--danger"><span class="van-button__text">立即购买</span></button> </div> <button class="van-button van-button--warning van-button--large van-button--square van-goods-action-button van-goods-action-button--first van-goods-action-button--warning"><span class="van-button__text">加入购物车</span></button> <button class="van-button van-button--danger van-button--large van-button--square van-goods-action-button van-goods-action-button--last van-goods-action-button--danger"><span class="van-button__text">立即购买</span></button>
</div> </div>
</div> </div>
<div>
<div class="van-goods-action">
<div role="button" tabindex="0" class="van-goods-action-icon">
<div class="van-icon van-icon-chat-o van-goods-action-icon__icon">
<!---->
</div>客服
</div>
<div role="button" tabindex="0" class="van-goods-action-icon">
<div class="van-icon van-icon-cart-o van-goods-action-icon__icon">
<!---->
</div>购物车
</div> <button class="van-button van-button--warning van-button--large van-button--square van-goods-action-button van-goods-action-button--first van-goods-action-button--warning" style="border-color: #be99ff; color: rgb(255, 255, 255); background: rgb(190, 153, 255);"><span class="van-button__text">加入购物车</span></button> <button class="van-button van-button--danger van-button--large van-button--square van-goods-action-button van-goods-action-button--last van-goods-action-button--danger" style="border-color: #7232dd; color: rgb(255, 255, 255); background: rgb(114, 50, 221);"><span class="van-button__text">立即购买</span></button>
</div>
</div>
</div> </div>
`; `;