fix(vue): correctly handle platform specific icons (#22200)

resolves #19078
This commit is contained in:
Liam DeBeasi
2020-09-28 15:07:21 -04:00
committed by GitHub
parent e84f80493c
commit 25d3ea6b8d
4 changed files with 48 additions and 16 deletions

View File

@ -81,7 +81,9 @@ export const config: Config = {
'ion-modal', 'ion-modal',
'ion-picker', 'ion-picker',
'ion-popover', 'ion-popover',
'ion-toast' 'ion-toast',
'ion-icon'
], ],
routerLinkComponents: [ routerLinkComponents: [
'ion-card', 'ion-card',

View File

@ -0,0 +1,44 @@
import { h, defineComponent } from 'vue';
import { isPlatform } from '@ionic/core';
export const IonIcon = defineComponent({
name: 'IonIcon',
props: {
ariaLabel: String,
color: String,
flipRtl: Boolean,
icon: String,
ios: String,
lazy: String,
md: String,
mode: String,
name: String,
size: String,
src: String
},
setup(props, { slots }) {
return () => {
const { icon, ios, md } = props;
let iconToUse: typeof icon;
if (ios || md) {
if (isPlatform('ios')) {
iconToUse = ios ?? md ?? icon;
} else {
iconToUse = md ?? ios ?? icon;
}
} else {
iconToUse = icon;
}
return h(
'ion-icon',
{
...props,
icon: iconToUse
},
slots
)
}
}
});

View File

@ -10,6 +10,7 @@ export { IonRouterOutlet } from './components/IonRouterOutlet';
export { IonTabButton } from './components/IonTabButton'; export { IonTabButton } from './components/IonTabButton';
export { IonTabs } from './components/IonTabs'; export { IonTabs } from './components/IonTabs';
export { IonTabBar } from './components/IonTabBar'; export { IonTabBar } from './components/IonTabBar';
export { IonIcon } from './components/IonIcon';
export * from './components/Overlays'; export * from './components/Overlays';
export { IonKeyboardRef, IonRouter, useBackButton, useIonRouter, useKeyboard } from './hooks'; export { IonKeyboardRef, IonRouter, useBackButton, useIonRouter, useKeyboard } from './hooks';

View File

@ -248,21 +248,6 @@ export const IonHeader = /*@__PURE__*/ defineContainer<JSX.IonHeader>('ion-heade
]); ]);
export const IonIcon = /*@__PURE__*/ defineContainer<JSX.IonIcon>('ion-icon', [
'mode',
'color',
'ariaLabel',
'ios',
'md',
'flipRtl',
'name',
'src',
'icon',
'size',
'lazy'
]);
export const IonImg = /*@__PURE__*/ defineContainer<JSX.IonImg>('ion-img', [ export const IonImg = /*@__PURE__*/ defineContainer<JSX.IonImg>('ion-img', [
'alt', 'alt',
'src', 'src',