[new feature] GoodsActionIcon: add icon slot (#3705)
This commit is contained in:
@@ -5,7 +5,7 @@ import { functionalRoute, routeProps, RouteProps } from '../utils/router';
|
||||
|
||||
// Types
|
||||
import { CreateElement, RenderContext } from 'vue/types';
|
||||
import { DefaultSlots } from '../utils/types';
|
||||
import { DefaultSlots, ScopedSlot } from '../utils/types';
|
||||
|
||||
export type GoodsActionIconProps = RouteProps & {
|
||||
icon: string;
|
||||
@@ -14,12 +14,16 @@ export type GoodsActionIconProps = RouteProps & {
|
||||
iconClass?: any;
|
||||
};
|
||||
|
||||
export type GoodsActionIconSlots = DefaultSlots & {
|
||||
icon?: ScopedSlot;
|
||||
};
|
||||
|
||||
const [createComponent, bem] = createNamespace('goods-action-icon');
|
||||
|
||||
function GoodsActionIcon(
|
||||
h: CreateElement,
|
||||
props: GoodsActionIconProps,
|
||||
slots: DefaultSlots,
|
||||
slots: GoodsActionIconSlots,
|
||||
ctx: RenderContext<GoodsActionIconProps>
|
||||
) {
|
||||
function onClick(event: Event) {
|
||||
@@ -35,12 +39,16 @@ function GoodsActionIcon(
|
||||
onClick={onClick}
|
||||
{...inherit(ctx)}
|
||||
>
|
||||
<Icon
|
||||
class={[bem('icon'), props.iconClass]}
|
||||
tag="div"
|
||||
info={props.info}
|
||||
name={props.icon}
|
||||
/>
|
||||
{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>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user