Skip to content

Commit

Permalink
fix(tabs): badgeColor works again
Browse files Browse the repository at this point in the history
fixes #15559
fixes #14840
  • Loading branch information
manucorporat committed Oct 2, 2018
1 parent d9e0bd3 commit 3d98587
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 31 deletions.
4 changes: 2 additions & 2 deletions angular/src/directives/proxies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ export class Tab {
}

export declare interface Tabs extends StencilComponents<'IonTabs'> {}
@Component({ selector: 'ion-tabs', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: '<ng-content></ng-content>', inputs: ['color', 'name', 'tabbarHidden', 'tabbarHighlight', 'tabbarLayout', 'tabbarPlacement', 'translucent', 'useRouter'] })
@Component({ selector: 'ion-tabs', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: '<ng-content></ng-content>', inputs: ['mode', 'color', 'name', 'tabbarHidden', 'tabbarHighlight', 'tabbarLayout', 'tabbarPlacement', 'translucent', 'useRouter'] })
export class Tabs {
ionChange: EventEmitter<CustomEvent>;
ionNavWillLoad: EventEmitter<CustomEvent>;
Expand All @@ -831,7 +831,7 @@ export class Tabs {
constructor(r: ElementRef) {
const el = r.nativeElement;
proxyMethods(this, el, ['select', 'setRouteId', 'getRouteId', 'getTab', 'getSelected']);
proxyInputs(this, el, ['color', 'name', 'tabbarHidden', 'tabbarHighlight', 'tabbarLayout', 'tabbarPlacement', 'translucent', 'useRouter']);
proxyInputs(this, el, ['mode', 'color', 'name', 'tabbarHidden', 'tabbarHighlight', 'tabbarLayout', 'tabbarPlacement', 'translucent', 'useRouter']);
proxyOutputs(this, el, ['ionChange', 'ionNavWillLoad', 'ionNavWillChange', 'ionNavDidChange']);
}
}
Expand Down
8 changes: 8 additions & 0 deletions core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4595,6 +4595,10 @@ export namespace Components {
*/
'getTab': (tabOrIndex: string | number | HTMLIonTabElement) => Promise<HTMLIonTabElement | undefined>;
/**
* The mode determines which platform styles to use. Possible values are: `"ios"` or `"md"`.
*/
'mode': Mode;
/**
* A unique name for the tabs.
*/
'name'?: string;
Expand Down Expand Up @@ -4634,6 +4638,10 @@ export namespace Components {
*/
'color'?: Color;
/**
* The mode determines which platform styles to use. Possible values are: `"ios"` or `"md"`.
*/
'mode'?: Mode;
/**
* A unique name for the tabs.
*/
'name'?: string;
Expand Down
2 changes: 1 addition & 1 deletion core/src/components/tabbar/tabbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { createColorClasses } from '../../utils/theme';
ios: 'tabbar.ios.scss',
md: 'tabbar.md.scss'
},
shadow: true
scoped: true
})
export class Tabbar implements ComponentInterface {

Expand Down
1 change: 1 addition & 0 deletions core/src/components/tabs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The component is a container of individual [Tab](../Tab/) components.
| Property | Attribute | Description | Type |
| ----------------- | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- |
| `color` | `color` | 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). | `Color` |
| `mode` | `mode` | The mode determines which platform styles to use. Possible values are: `"ios"` or `"md"`. | `Mode` |
| `name` | `name` | A unique name for the tabs. | `string` |
| `tabbarHidden` | `tabbar-hidden` | If true, the tabbar will be hidden. Defaults to `false`. | `boolean` |
| `tabbarHighlight` | `tabbar-highlight` | If true, show the tab highlight bar under the selected tab. | `boolean` |
Expand Down
19 changes: 15 additions & 4 deletions core/src/components/tabs/tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,21 @@
z-index: $z-index-page-container;
}

.tabs-inner {
position: relative;
ion-tabbar {
@include position(null, 0, 0, 0);

flex: 1;
display: none;
position: absolute;
}

contain: layout size style;
:host(.tabbar-visible.tabs-md)::slotted(ion-tab) {
bottom: 56px; // tabbar height (it's fixed!)
}

:host(.tabbar-visible.tabs-ios)::slotted(ion-tab) {
bottom: 50px; // tabbar height (it's fixed!)
}

:host(.tabbar-visible) ion-tabbar {
display: flex;
}
50 changes: 27 additions & 23 deletions core/src/components/tabs/tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Build, Component, Element, Event, EventEmitter, Listen, Method, Prop, State } from '@stencil/core';

import { Color, Config, IonicConfig, NavOutlet, RouteID, RouteWrite, TabbarLayout, TabbarPlacement } from '../../interface';
import { createColorClasses } from '../../utils/theme';
import { Color, Config, IonicConfig, Mode, NavOutlet, RouteID, RouteWrite, TabbarLayout, TabbarPlacement } from '../../interface';
import { createThemedClasses } from '../../utils/theme';

@Component({
tag: 'ion-tabs',
styleUrl: 'tabs.scss',
shadow: true
scoped: true
})
export class Tabs implements NavOutlet {

Expand All @@ -23,6 +23,12 @@ export class Tabs implements NavOutlet {
@Prop({ context: 'config' }) config!: Config;
@Prop({ context: 'document' }) doc!: Document;

/**
* The mode determines which platform styles to use.
* Possible values are: `"ios"` or `"md"`.
*/
@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"`.
Expand Down Expand Up @@ -103,7 +109,7 @@ export class Tabs implements NavOutlet {
}

componentDidLoad() {
return this.initSelect();
this.initSelect();
}

componentDidUnload() {
Expand Down Expand Up @@ -293,29 +299,27 @@ export class Tabs implements NavOutlet {

hostData() {
return {
class: createColorClasses(this.color)
class: {
...createThemedClasses(this.mode, 'tabs'),
'tabbar-visible': !this.tabbarHidden
}
};
}

render() {
return [
<div class="tabs-inner">
<slot></slot>
</div>,

!this.tabbarHidden && (
<ion-tabbar
tabs={this.tabs.slice()}
color={this.color}
selectedTab={this.selectedTab}
highlight={this.tabbarHighlight}
placement={this.tabbarPlacement}
layout={this.tabbarLayout}
translucent={this.translucent}
>
</ion-tabbar>
)
];
return (
<ion-tabbar
mode={this.mode}
tabs={this.tabs.slice()}
color={this.color}
selectedTab={this.selectedTab}
highlight={this.tabbarHighlight}
placement={this.tabbarPlacement}
layout={this.tabbarLayout}
translucent={this.translucent}
>
</ion-tabbar>
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/components/tabs/test/basic/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h1>Tab One</h1>
</ion-content>
</ion-tab>

<ion-tab label="Schedule" icon="globe">
<ion-tab label="Schedule" icon="globe" badge="6" badge-color="danger">
<ion-header>
<ion-toolbar>
<ion-title>Tab Two</ion-title>
Expand Down

0 comments on commit 3d98587

Please sign in to comment.