[new feature] GoodsAction: update style (#3967)
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import { createNamespace } from '../utils';
|
||||
import { route, routeProps } from '../utils/router';
|
||||
import { ChildrenMixin } from '../mixins/relation';
|
||||
import Icon from '../icon';
|
||||
|
||||
const [createComponent, bem] = createNamespace('goods-action-icon');
|
||||
|
||||
export default createComponent({
|
||||
mixins: [ChildrenMixin('vanGoodsAction')],
|
||||
|
||||
props: {
|
||||
...routeProps,
|
||||
text: String,
|
||||
icon: String,
|
||||
info: [Number, String],
|
||||
iconClass: null
|
||||
},
|
||||
|
||||
methods: {
|
||||
onClick(event) {
|
||||
this.$emit('click', event);
|
||||
route(this.$router, this);
|
||||
}
|
||||
},
|
||||
|
||||
render(h) {
|
||||
return (
|
||||
<div role="button" tabindex="0" class={bem()} onClick={this.onClick}>
|
||||
{this.slots('icon') ? (
|
||||
<div class={bem('icon')}>{this.slots('icon')}</div>
|
||||
) : (
|
||||
<Icon
|
||||
class={[bem('icon'), this.iconClass]}
|
||||
tag="div"
|
||||
info={this.info}
|
||||
name={this.icon}
|
||||
/>
|
||||
)}
|
||||
{this.slots() || this.text}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -1,65 +0,0 @@
|
||||
import { createNamespace } from '../utils';
|
||||
import Icon, { IconEvents } from '../icon';
|
||||
import { emit, inherit } from '../utils/functional';
|
||||
import { functionalRoute, routeProps, RouteProps } from '../utils/router';
|
||||
|
||||
// Types
|
||||
import { CreateElement, RenderContext } from 'vue/types';
|
||||
import { DefaultSlots, ScopedSlot } from '../utils/types';
|
||||
|
||||
export type GoodsActionIconProps = RouteProps & {
|
||||
icon: string;
|
||||
text?: string;
|
||||
info?: string | number;
|
||||
iconClass?: any;
|
||||
};
|
||||
|
||||
export type GoodsActionIconSlots = DefaultSlots & {
|
||||
icon?: ScopedSlot;
|
||||
};
|
||||
|
||||
const [createComponent, bem] = createNamespace('goods-action-icon');
|
||||
|
||||
function GoodsActionIcon(
|
||||
h: CreateElement,
|
||||
props: GoodsActionIconProps,
|
||||
slots: GoodsActionIconSlots,
|
||||
ctx: RenderContext<GoodsActionIconProps>
|
||||
) {
|
||||
function onClick(event: Event) {
|
||||
emit(ctx, 'click', event);
|
||||
functionalRoute(ctx);
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
role="button"
|
||||
tabindex="0"
|
||||
class={bem()}
|
||||
onClick={onClick}
|
||||
{...inherit(ctx)}
|
||||
>
|
||||
{slots.icon ? (
|
||||
<div class={bem('icon')}>{slots.icon()}</div>
|
||||
) : (
|
||||
<Icon
|
||||
class={[bem('icon'), props.iconClass]}
|
||||
tag="div"
|
||||
info={props.info}
|
||||
name={props.icon}
|
||||
/>
|
||||
)}
|
||||
{slots.default ? slots.default() : props.text}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
GoodsActionIcon.props = {
|
||||
...routeProps,
|
||||
text: String,
|
||||
icon: String,
|
||||
info: [Number, String],
|
||||
iconClass: null as any
|
||||
};
|
||||
|
||||
export default createComponent<GoodsActionIconProps, IconEvents>(GoodsActionIcon);
|
||||
Reference in New Issue
Block a user