docs: add descriptions and examples for core components

This commit is contained in:
Drew Rygh
2015-09-06 18:02:26 -05:00
parent dc7b04fbd4
commit d464f8f02c
9 changed files with 241 additions and 21 deletions

View File

@ -15,6 +15,44 @@ import {Animation} from '../../animations/animation';
import * as util from 'ionic/util';
/**
* @name ActionMenu
* @classdesc
* The Action Menu is a slide-up pane that lets the user choose from a set of options. Dangerous options are made obvious.
*
* There are easy ways to cancel out of the action sheet, such as tapping the backdrop or even hitting escape on the keyboard for desktop testing.
*
* @example
* ```ts
* openMenu() {
*
* this.actionMenu.open({
* buttons: [
* { text: 'Share This' },
* { text: 'Move' }
* ],
* destructiveText: 'Delete',
* titleText: 'Modify your album',
* cancelText: 'Cancel',
* cancel: function() {
* console.log('Canceled');
* },
* destructiveButtonClicked: () => {
* console.log('Destructive clicked');
* },
* buttonClicked: function(index) {
* console.log('Button clicked', index);
* if(index == 1) { return false; }
* return true;
* }
*
* }).then(actionMenuRef => {
* this.actionMenuRef = actionMenuRef;
* });
*
* }
* ```
*/
@View({
template:
'<backdrop (click)="_cancel()" tappable></backdrop>' +
@ -61,9 +99,6 @@ class ActionMenuDirective {
}
}
/**
* TODO
*/
@Injectable()
export class ActionMenu extends Overlay {
/**

View File

@ -13,7 +13,18 @@ import {IonicComponent, IonicView} from '../../config/annotations';
import {TapClick} from '../button/button';
/**
* Checkbox control value accessor.
* @name ionCheckbox
* @classdesc
* The checkbox is no different than the HTML checkbox input, except it's styled differently
*
* See the [Angular 2 Docs](https://angular.io/docs/js/latest/api/forms/) for more info on forms and input.
*
* @example
* ```html
* <ion-checkbox checked="true" value="isChecked" ng-control="htmlCtrl">
* HTML5
* </ion-checkbox>
* ```
*/
@IonicComponent({
selector: 'ion-checkbox',

View File

@ -7,7 +7,10 @@ import {ScrollTo} from '../../animations/scroll-to';
import {hasFocusedTextInput} from '../../util/dom';
/**
* @name ionContent
* @classdesc
* TODO
*
*/
@Component({
selector: 'ion-content',

View File

@ -5,7 +5,27 @@ import {Animation} from '../../animations/animation';
import * as util from 'ionic/util';
/**
* TODO
* @name ionModal
* @classdesc
* The Modal is a content pane that can go over the user's main view temporarily. Usually used for making a choice or editing an item.
*
* @example
* ```ts
* class MyApp {
*
* constructor(modal: Modal, app: IonicApp, ionicConfig: IonicConfig) {
* this.modal = modal;
* }
*
* openModal() {
* this.modal.open(ContactModal, {
* enterAnimation: 'my-fade-in',
* leaveAnimation: 'my-fade-out',
* handle: 'my-modal'
* });
* }
* }
* ```
*/
@Injectable()
export class Modal extends Overlay {

View File

@ -7,7 +7,43 @@ import * as util from 'ionic/util';
/**
* TODO
* @name ionPopup
* @classdesc
* The Ionic Popup service allows programmatically creating and showing popup windows that require the user to respond in order to continue.
*
* The popup system has support for more flexible versions of the built in `alert()`, `prompt()`, and `confirm()` functions that users are used to, in addition to allowing popups with completely custom content and look.
*
* @example
* ```ts
* class myApp {
*
* constructor(popup: Popup) {
* this.popup = popup;
* }
*
* doAlert() {
* this.popup.alert('Alert').then(() => {
* console.log('Alert closed');
* });
* }
*
* doPrompt() {
* this.popup.prompt('What is your name?').then((name) => {
* console.log('Name entered:', name);
* }, () => {
* console.error('Prompt closed');
* });
* }
*
* doConfirm() {
* this.popup.confirm('Are you sure?').then((result, ev) => {
* console.log('Confirmed!', result);
* }, () => {
* console.error('Not confirmed!');
* });
* }
* }
* ```
*/
@Injectable()
export class Popup extends Overlay {

View File

@ -6,9 +6,46 @@ import {Ion} from '../ion';
import {TapClick} from '../button/button';
import {ListHeader} from '../list/list';
/**
* A radio group component.
*/
* @name ionRadioGroup
* @classdesc
* A radio group is a group of radio components.
*
* Selecting a radio button in the group unselects all others in the group.
*
* New radios can be registered dynamically.
*
* See the [Angular 2 Docs](https://angular.io/docs/js/latest/api/forms/) for more info on forms and input.
*
* @example
* ```html
* <ion-radio-group ng-control="clientside">
*
* <ion-header>
* Clientside
* </ion-header>
*
* <ion-radio value="ember">
* Ember
* </ion-radio>
*
* <ion-radio value="angular1">
* Angular 1
* </ion-radio>
*
* <ion-radio value="angular2" checked="true">
* Angular 2
* </ion-radio>
*
* <ion-radio value="react">
* React
* </ion-radio>
*
* </ion-radio-group>
* ```
*/
@IonicDirective({
selector: 'ion-radio-group',
host: {
@ -114,7 +151,19 @@ export class RadioGroup extends Ion {
}
/**
* A radio button component.
* @name ionRadio
* @classdesc
* A single radio component.
*
* See the [Angular 2 Docs](https://angular.io/docs/js/latest/api/forms/) for more info on forms and input.
*
* @example
* ```html
* <ion-radio value="isChecked" checked="true">
* Radio Label
* </ion-radio>
* ```
*
*/
@IonicComponent({
selector: 'ion-radio',

View File

@ -6,7 +6,38 @@ import * as util from 'ionic/util';
import {raf, ready, CSS} from 'ionic/util/dom';
/**
* TODO
* @name ionRefresher
* @classdesc
* Allows you to add pull-to-refresh to an ionContent component.
*
* Place it as the first child of your ionContent or ionScroll element.
*
* When refreshing is complete, call `refresher.complete()` from your controller.
*
* @example
* ```html
* <ion-refresher (starting)="doStarting()" (refresh)="doRefresh($event, refresher)" (pulling)="doPulling($event, amt)">
* ```
*
* @example
* ```ts
* doRefresh(refresher) {
* console.log('Refreshing!', refresher);
*
* setTimeout(() => {
* console.log('Pull to refresh complete!', refresher);
* refresher.complete();
* })
* }
*
* doStarting() {
* console.log('Pull started!');
* }
*
* doPulling(amt) {
* console.log('You have pulled', amt);
* }
* ```
*/
@Component({
selector: 'ion-refresher',
@ -94,7 +125,7 @@ export class Refresher {
this.showIcon = util.isDefined(this.refreshingIcon);
this._touchMoveListener = this._handleTouchMove.bind(this);
this._touchMoveListener = this._handleTouchMov.bind(this);
this._touchEndListener = this._handleTouchEnd.bind(this);
this._handleScrollListener = this._handleScroll.bind(this);
sc.addEventListener('touchmove', this._touchMoveListener);

View File

@ -17,7 +17,8 @@ import {IonicComponent, IonicView} from '../../config/annotations';
import {pointerCoord} from '../../util/dom';
/**
* TODO
* @name mediaSwitch
* @private
*/
@Directive({
selector: '.media-switch',
@ -46,7 +47,41 @@ class MediaSwitch {
/**
* TODO
* @name ionSwitch
* @classdesc
* A switch technically is the same thing as an HTML checkbox input, except it looks different and is easier to use on a touch device. Ionic prefers to wrap the checkbox input with the <label> in order to make the entire toggle easy to tap or drag.
*
* Toggles can also have colors assigned to them, by adding the `toggle-assertive` attribute to assign the assertive color.
*
* See the [Angular 2 Docs](https://angular.io/docs/js/latest/api/forms/) for more info on forms and input.
*
* @example
* ```html
* <ion-switch checked="true">
* Pineapple
* </ion-switch>
* ````
*
* @example
* Create a list of switch components:
* ```html
* <ion-list>
*
* <ion-switch checked="true">
* Apple
* </ion-switch>
*
* <ion-switch checked="false">
* Banana
* </ion-switch>
*
* <ion-switch disabled="true">
* Cherry
* </ion-switch>
*
* </ion-list>
* ```
*
*/
@IonicComponent({
selector: 'ion-switch',