[improvement] rename packages dir to src (#3659)
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
@import '../style/var';
|
||||
|
||||
.van-goods-action-icon {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
min-width: @goods-action-icon-width;
|
||||
height: @goods-action-icon-height;
|
||||
color: @goods-action-icon-color;
|
||||
font-size: @goods-action-icon-font-size;
|
||||
line-height: 1;
|
||||
text-align: center;
|
||||
background-color: @white;
|
||||
|
||||
&:not(:first-child)::after {
|
||||
border-left-width: 1px;
|
||||
}
|
||||
|
||||
&:active {
|
||||
background-color: @goods-action-icon-active-color;
|
||||
}
|
||||
|
||||
&__icon {
|
||||
width: 1em;
|
||||
margin: 0 auto 5px;
|
||||
font-size: @goods-action-icon-size;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
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 } from '../utils/types';
|
||||
|
||||
export type GoodsActionIconProps = RouteProps & {
|
||||
icon: string;
|
||||
text?: string;
|
||||
info?: string | number;
|
||||
iconClass?: any;
|
||||
};
|
||||
|
||||
const [createComponent, bem] = createNamespace('goods-action-icon');
|
||||
|
||||
function GoodsActionIcon(
|
||||
h: CreateElement,
|
||||
props: GoodsActionIconProps,
|
||||
slots: DefaultSlots,
|
||||
ctx: RenderContext<GoodsActionIconProps>
|
||||
) {
|
||||
function onClick(event: Event) {
|
||||
emit(ctx, 'click', event);
|
||||
functionalRoute(ctx);
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
role="button"
|
||||
tabindex="0"
|
||||
class={[bem(), 'van-hairline']}
|
||||
onClick={onClick}
|
||||
{...inherit(ctx)}
|
||||
>
|
||||
<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: [String, Number],
|
||||
iconClass: null as any
|
||||
};
|
||||
|
||||
export default createComponent<GoodsActionIconProps, IconEvents>(GoodsActionIcon);
|
||||
Reference in New Issue
Block a user