mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(Popover): add icon-prefix prop (#8703)
* fix: popover 增加 icon-prefix 属性 * fix: popover icon-prefix属性跑单测 Co-authored-by: 冷开俊 <lengkj@travelsky.com.cn>
This commit is contained in:
parent
bb7dccfeec
commit
908210a225
@ -101,6 +101,7 @@ export default defineComponent({
|
|||||||
type: [String, Object] as PropType<TeleportProps['to']>,
|
type: [String, Object] as PropType<TeleportProps['to']>,
|
||||||
default: 'body',
|
default: 'body',
|
||||||
},
|
},
|
||||||
|
iconPrefix: String,
|
||||||
},
|
},
|
||||||
|
|
||||||
emits: ['select', 'touchstart', 'update:show'],
|
emits: ['select', 'touchstart', 'update:show'],
|
||||||
@ -190,7 +191,13 @@ export default defineComponent({
|
|||||||
style={{ color }}
|
style={{ color }}
|
||||||
onClick={() => onClickAction(action, index)}
|
onClick={() => onClickAction(action, index)}
|
||||||
>
|
>
|
||||||
{icon && <Icon name={icon} class={bem('action-icon')} />}
|
{icon && (
|
||||||
|
<Icon
|
||||||
|
name={icon}
|
||||||
|
classPrefix={props.iconPrefix}
|
||||||
|
class={bem('action-icon')}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<div class={[bem('action-text'), BORDER_BOTTOM]}>{text}</div>
|
<div class={[bem('action-text'), BORDER_BOTTOM]}>{text}</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -224,6 +224,7 @@ export default {
|
|||||||
| close-on-click-outside | Whether to close when clicking outside | _boolean_ | `true` |
|
| close-on-click-outside | Whether to close when clicking outside | _boolean_ | `true` |
|
||||||
| close-on-click-overlay `v3.0.10` | Whether to close when clicking overlay | _boolean_ | `true` |
|
| close-on-click-overlay `v3.0.10` | Whether to close when clicking overlay | _boolean_ | `true` |
|
||||||
| teleport | Return the mount node for Popover | _string \| Element_ | `body` |
|
| teleport | Return the mount node for Popover | _string \| Element_ | `body` |
|
||||||
|
| icon-prefix | Icon className prefix | _string_ | `van-icon` |
|
||||||
|
|
||||||
### Data Structure of Action
|
### Data Structure of Action
|
||||||
|
|
||||||
|
@ -234,6 +234,7 @@ export default {
|
|||||||
| close-on-click-outside | 是否在点击外部元素后关闭菜单 | _boolean_ | `true` |
|
| close-on-click-outside | 是否在点击外部元素后关闭菜单 | _boolean_ | `true` |
|
||||||
| close-on-click-overlay `v3.0.10` | 是否在点击遮罩层后关闭菜单 | _boolean_ | `true` |
|
| close-on-click-overlay `v3.0.10` | 是否在点击遮罩层后关闭菜单 | _boolean_ | `true` |
|
||||||
| teleport | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| Element_ | `body` |
|
| teleport | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| Element_ | `body` |
|
||||||
|
| icon-prefix | 图标类名前缀,同 Icon 组件的 [class-prefix 属性](#/zh-CN/icon#props) | _string_ | `van-icon` |
|
||||||
|
|
||||||
### Action 数据结构
|
### Action 数据结构
|
||||||
|
|
||||||
|
@ -10,6 +10,11 @@ exports[`should allow to custom the className of action 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`should change icon class prefix when using icon-prefix prop 1`] = `
|
||||||
|
<span class="van-popover__wrapper">
|
||||||
|
</span>
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`should locate to reference element when showed 1`] = `
|
exports[`should locate to reference element when showed 1`] = `
|
||||||
<transition-stub>
|
<transition-stub>
|
||||||
</transition-stub>
|
</transition-stub>
|
||||||
|
@ -187,3 +187,15 @@ test('should not close Popover when outside is clicked and close-on-click-outsid
|
|||||||
trigger(document.body, 'touchstart');
|
trigger(document.body, 'touchstart');
|
||||||
expect(wrapper.emitted('update:show')).toBeFalsy();
|
expect(wrapper.emitted('update:show')).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should change icon class prefix when using icon-prefix prop', () => {
|
||||||
|
const wrapper = mount(Popover, {
|
||||||
|
props: {
|
||||||
|
show: true,
|
||||||
|
icon: 'success',
|
||||||
|
iconPrefix: 'my-icon',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper.html()).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user