refactor(toolbar): restructure toolbar component to separate modules

restructure toolbar component to separate modules
This commit is contained in:
Dan Bucholtz
2017-03-02 15:03:13 -06:00
parent 5364d00671
commit 49723c3b81
7 changed files with 117 additions and 101 deletions

View File

@@ -0,0 +1,32 @@
import { ElementRef, Renderer } from '@angular/core';
import { Config } from '../../config/config';
import { Ion } from '../ion';
import { ToolbarTitle } from './toolbar-title';
/**
* @private
*/
export class ToolbarBase extends Ion {
private _title: ToolbarTitle;
constructor(config: Config, elementRef: ElementRef, renderer: Renderer) {
super(config, elementRef, renderer, 'toolbar');
}
/**
* @private
*/
_setTitle(titleCmp: ToolbarTitle) {
this._title = titleCmp;
}
/**
* @private
* Returns the toolbar title text if it exists or an empty string
*/
getTitleText() {
return (this._title && this._title.getTitleText()) || '';
}
}

View File

@@ -0,0 +1,35 @@
import { Directive, ElementRef, Optional, Renderer } from '@angular/core';
import { Config } from '../../config/config';
import { Ion } from '../ion';
import { ViewController } from '../../navigation/view-controller';
/**
* @name Footer
* @description
* Footer is a root component of a page that sits at the bottom of the page.
* Footer can be a wrapper for `ion-toolbar` to make sure the content area is sized correctly.
*
* @usage
*
* ```html
* <ion-content></ion-content>
*
* <ion-footer>
* <ion-toolbar>
* <ion-title>Footer</ion-title>
* </ion-toolbar>
* </ion-footer>
* ```
*
*/
@Directive({
selector: 'ion-footer'
})
export class Footer extends Ion {
constructor(config: Config, elementRef: ElementRef, renderer: Renderer, @Optional() viewCtrl: ViewController) {
super(config, elementRef, renderer, 'footer');
viewCtrl && viewCtrl._setFooter(this);
}
}

View File

@@ -0,0 +1,39 @@
import { Directive, ElementRef, Optional, Renderer } from '@angular/core';
import { Config } from '../../config/config';
import { Ion } from '../ion';
import { ViewController } from '../../navigation/view-controller';
/**
* @name Header
* @description
* Header is a parent component that holds the navbar and toolbar component.
* It's important to note that `ion-header` needs to be the one of the three root elements of a page
*
* @usage
*
* ```html
* <ion-header>
* <ion-navbar>
* <ion-title>Page1</ion-title>
* </ion-navbar>
*
* <ion-toolbar>
* <ion-title>Subheader</ion-title>
* </ion-toolbar>
* </ion-header>
*
* <ion-content></ion-content>
* ```
*
*/
@Directive({
selector: 'ion-header'
})
export class Header extends Ion {
constructor(config: Config, elementRef: ElementRef, renderer: Renderer, @Optional() viewCtrl: ViewController) {
super(config, elementRef, renderer, 'header');
viewCtrl && viewCtrl._setHeader(this);
}
}

View File

@@ -39,6 +39,8 @@ $toolbar-ios-button-border-radius: 4px !default;
/// @prop - Height of the navigation bar
$navbar-ios-height: $toolbar-ios-height !default;
$toolbar-button-ios-strong-font-weight: 600 !default;
.toolbar-ios {
padding: $toolbar-ios-padding;
@@ -378,5 +380,5 @@ $navbar-ios-height: $toolbar-ios-height !default;
// --------------------------------------------------
.bar-button-strong-ios {
font-weight: $button-ios-strong-font-weight;
font-weight: $toolbar-button-ios-strong-font-weight;
}

View File

@@ -33,6 +33,8 @@ $toolbar-md-button-border-radius: 2px !default;
/// @prop - Height of the navigation bar
$navbar-md-height: $toolbar-md-height !default;
$toolbar-button-md-strong-font-weight: bold !default;
.toolbar-md {
padding: $toolbar-md-padding;
@@ -396,5 +398,5 @@ $navbar-md-height: $toolbar-md-height !default;
// --------------------------------------------------
.bar-button-strong-md {
font-weight: $button-md-strong-font-weight;
font-weight: $toolbar-button-md-strong-font-weight;
}

View File

@@ -1,106 +1,10 @@
import { ChangeDetectionStrategy, Component, Directive, ElementRef, Input, Optional, Renderer } from '@angular/core';
import { ChangeDetectionStrategy, Component, ElementRef, Input, Optional, Renderer } from '@angular/core';
import { Config } from '../../config/config';
import { Ion } from '../ion';
import { ToolbarTitle } from './toolbar-title';
import { ViewController } from '../../navigation/view-controller';
import { ToolbarBase } from './toolbar-base';
/**
* @name Header
* @description
* Header is a parent component that holds the navbar and toolbar component.
* It's important to note that `ion-header` needs to be the one of the three root elements of a page
*
* @usage
*
* ```html
* <ion-header>
* <ion-navbar>
* <ion-title>Page1</ion-title>
* </ion-navbar>
*
* <ion-toolbar>
* <ion-title>Subheader</ion-title>
* </ion-toolbar>
* </ion-header>
*
* <ion-content></ion-content>
* ```
*
*/
@Directive({
selector: 'ion-header'
})
export class Header extends Ion {
constructor(config: Config, elementRef: ElementRef, renderer: Renderer, @Optional() viewCtrl: ViewController) {
super(config, elementRef, renderer, 'header');
viewCtrl && viewCtrl._setHeader(this);
}
}
/**
* @name Footer
* @description
* Footer is a root component of a page that sits at the bottom of the page.
* Footer can be a wrapper for `ion-toolbar` to make sure the content area is sized correctly.
*
* @usage
*
* ```html
* <ion-content></ion-content>
*
* <ion-footer>
* <ion-toolbar>
* <ion-title>Footer</ion-title>
* </ion-toolbar>
* </ion-footer>
* ```
*
*/
@Directive({
selector: 'ion-footer'
})
export class Footer extends Ion {
constructor(config: Config, elementRef: ElementRef, renderer: Renderer, @Optional() viewCtrl: ViewController) {
super(config, elementRef, renderer, 'footer');
viewCtrl && viewCtrl._setFooter(this);
}
}
/**
* @private
*/
export class ToolbarBase extends Ion {
private _title: ToolbarTitle;
constructor(config: Config, elementRef: ElementRef, renderer: Renderer) {
super(config, elementRef, renderer, 'toolbar');
}
/**
* @private
*/
_setTitle(titleCmp: ToolbarTitle) {
this._title = titleCmp;
}
/**
* @private
* Returns the toolbar title text if it exists or an empty string
*/
getTitleText() {
return (this._title && this._title.getTitleText()) || '';
}
}
/**
* @name Toolbar
* @description

View File

@@ -42,6 +42,8 @@ $toolbar-wp-button-border-radius: 2px !default;
/// @prop - Height of the navigation bar
$navbar-wp-height: $toolbar-wp-height !default;
$toolbar-button-wp-strong-font-weight: bold !default;
.toolbar-wp {
padding: $toolbar-wp-padding;
@@ -350,5 +352,5 @@ $navbar-wp-height: $toolbar-wp-height !default;
// --------------------------------------------------
.bar-button-strong-wp {
font-weight: $button-wp-strong-font-weight;
font-weight: $toolbar-button-wp-strong-font-weight;
}