feat(ActionBarIcon): add icon-prefix prop (#8748)

This commit is contained in:
neverland
2021-05-23 08:55:19 +08:00
committed by GitHub
parent 41805992a3
commit 4c69fdba30
6 changed files with 30 additions and 5 deletions
+3 -1
View File
@@ -22,6 +22,7 @@ export default defineComponent({
color: String,
badge: [Number, String],
iconClass: unknownProp,
iconPrefix: String,
}),
setup(props, { slots }) {
@@ -30,7 +31,7 @@ export default defineComponent({
useParent(ACTION_BAR_KEY);
const renderIcon = () => {
const { dot, badge, icon, color, iconClass } = props;
const { dot, badge, icon, color, iconClass, iconPrefix } = props;
if (slots.icon) {
return (
@@ -48,6 +49,7 @@ export default defineComponent({
badge={badge}
color={color}
class={[bem('icon'), iconClass]}
classPrefix={iconPrefix}
/>
);
};
@@ -51,3 +51,13 @@ exports[`should render icon slot with dot correctly 1`] = `
Content
</div>
`;
exports[`should render icon-prefix correctly 1`] = `
<div role="button"
class="van-action-bar-icon"
tabindex="0"
>
<div class="van-badge__wrapper my-icon my-icon-success van-action-bar-icon__icon">
</div>
</div>
`;
+11
View File
@@ -21,6 +21,17 @@ test('should render icon slot correctly', () => {
expect(wrapper.html()).toMatchSnapshot();
});
test('should render icon-prefix correctly', () => {
const wrapper = mount(ActionBarIcon, {
props: {
icon: 'success',
iconPrefix: 'my-icon',
},
});
expect(wrapper.html()).toMatchSnapshot();
});
test('should render icon slot with badge correctly', () => {
const wrapper = mount(ActionBarIcon, {
props: {