Files
ionic-framework/core/src/components/title/title.tsx
2018-09-14 18:47:00 +02:00

47 lines
1.1 KiB
TypeScript

import { Component, ComponentInterface, Element, Prop } from '@stencil/core';
import { Color, Mode } from '../../interface';
import { createColorClasses } from '../../utils/theme';
@Component({
tag: 'ion-title',
styleUrl: 'title.scss',
shadow: true
})
export class ToolbarTitle implements ComponentInterface {
mode!: Mode;
@Element() el!: HTMLElement;
/**
* 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;
private getMode() {
const toolbar = this.el.closest('ion-toolbar');
return (toolbar && toolbar.mode) || this.mode;
}
hostData() {
const mode = this.getMode();
return {
class: {
...createColorClasses(this.color),
[`title-${mode}`]: true
}
};
}
render() {
return [
<div class="toolbar-title">
<slot></slot>
</div>
];
}
}