breaking change: rename GoodsAction to ActionBar
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
import { createNamespace } from '../utils';
|
||||
import { route, routeProps } from '../utils/router';
|
||||
import { ChildrenMixin } from '../mixins/relation';
|
||||
import Button from '../button';
|
||||
|
||||
const [createComponent, bem] = createNamespace('action-bar-button');
|
||||
|
||||
export default createComponent({
|
||||
mixins: [ChildrenMixin('vanActionBar')],
|
||||
|
||||
props: {
|
||||
...routeProps,
|
||||
type: String,
|
||||
text: String,
|
||||
icon: String,
|
||||
color: String,
|
||||
loading: Boolean,
|
||||
disabled: Boolean,
|
||||
},
|
||||
|
||||
emits: ['click'],
|
||||
|
||||
computed: {
|
||||
isFirst() {
|
||||
const prev = this.parent && this.parent.children[this.index - 1];
|
||||
return !prev || prev.$options.name !== this.$options.name;
|
||||
},
|
||||
|
||||
isLast() {
|
||||
const next = this.parent && this.parent.children[this.index + 1];
|
||||
return !next || next.$options.name !== this.$options.name;
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
onClick(event) {
|
||||
this.$emit('click', event);
|
||||
route(this.$router, this);
|
||||
},
|
||||
},
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Button
|
||||
class={bem([
|
||||
{
|
||||
first: this.isFirst,
|
||||
last: this.isLast,
|
||||
},
|
||||
this.type,
|
||||
])}
|
||||
size="large"
|
||||
type={this.type}
|
||||
icon={this.icon}
|
||||
color={this.color}
|
||||
loading={this.loading}
|
||||
disabled={this.disabled}
|
||||
onClick={this.onClick}
|
||||
>
|
||||
{this.$slots.default ? this.$slots.default() : this.text}
|
||||
</Button>
|
||||
);
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,34 @@
|
||||
@import '../style/var';
|
||||
|
||||
.van-action-bar-button {
|
||||
flex: 1;
|
||||
height: @action-bar-button-height;
|
||||
font-weight: @font-weight-bold;
|
||||
font-size: @font-size-md;
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
|
||||
&--first {
|
||||
margin-left: 5px;
|
||||
border-top-left-radius: @border-radius-max;
|
||||
border-bottom-left-radius: @border-radius-max;
|
||||
}
|
||||
|
||||
&--last {
|
||||
margin-right: 5px;
|
||||
border-top-right-radius: @border-radius-max;
|
||||
border-bottom-right-radius: @border-radius-max;
|
||||
}
|
||||
|
||||
&--warning {
|
||||
background: @action-bar-button-warning-color;
|
||||
}
|
||||
|
||||
&--danger {
|
||||
background: @action-bar-button-danger-color;
|
||||
}
|
||||
|
||||
@media (max-width: 321px) {
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user