mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
47 lines
1.1 KiB
TypeScript
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>
|
|
];
|
|
}
|
|
}
|