mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-09 08:09:32 +08:00
feat(toast): add "color" prop (#16100)
This commit also refactors ion-toast, so it uses shadow-dom, this is required since CSS variables does not work well in non-shadow-dom components. fixes #16099
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
import { Component, ComponentInterface, Element, Event, EventEmitter, Method, Prop } from '@stencil/core';
|
||||
|
||||
import { Animation, AnimationBuilder, Config, Mode, OverlayEventDetail, OverlayInterface } from '../../interface';
|
||||
import { Animation, AnimationBuilder, Color, Config, Mode, OverlayEventDetail, OverlayInterface } from '../../interface';
|
||||
import { dismiss, eventMethod, present } from '../../utils/overlays';
|
||||
import { createThemedClasses, getClassMap } from '../../utils/theme';
|
||||
import { createColorClasses, getClassMap } from '../../utils/theme';
|
||||
|
||||
import { iosEnterAnimation } from './animations/ios.enter';
|
||||
import { iosLeaveAnimation } from './animations/ios.leave';
|
||||
@ -14,7 +14,8 @@ import { mdLeaveAnimation } from './animations/md.leave';
|
||||
styleUrls: {
|
||||
ios: 'toast.ios.scss',
|
||||
md: 'toast.md.scss'
|
||||
}
|
||||
},
|
||||
shadow: true
|
||||
})
|
||||
export class Toast implements ComponentInterface, OverlayInterface {
|
||||
|
||||
@ -38,6 +39,13 @@ export class Toast implements ComponentInterface, OverlayInterface {
|
||||
*/
|
||||
@Prop() mode!: Mode;
|
||||
|
||||
/**
|
||||
* The color to use from your application's color palette.
|
||||
* Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`.
|
||||
* For more information on colors, see [theming](/docs/theming/basics).
|
||||
*/
|
||||
@Prop() color?: Color;
|
||||
|
||||
/**
|
||||
* Animation to use when the toast is presented.
|
||||
*/
|
||||
@ -173,16 +181,14 @@ export class Toast implements ComponentInterface, OverlayInterface {
|
||||
}
|
||||
|
||||
hostData() {
|
||||
const themedClasses = this.translucent ? createThemedClasses(this.mode, 'toast-translucent') : {};
|
||||
|
||||
return {
|
||||
style: {
|
||||
zIndex: 60000 + this.overlayIndex,
|
||||
},
|
||||
class: {
|
||||
...themedClasses,
|
||||
...createThemedClasses(this.mode, 'toast'),
|
||||
...getClassMap(this.cssClass)
|
||||
...createColorClasses(this.color),
|
||||
...getClassMap(this.cssClass),
|
||||
'toast-translucent': this.translucent
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user