diff --git a/core/package.json b/core/package.json index a64ebb2253..7f27363024 100644 --- a/core/package.json +++ b/core/package.json @@ -30,7 +30,7 @@ "ionicons": "4.4.8" }, "devDependencies": { - "@stencil/core": "0.16.0-6", + "@stencil/core": "0.16.0", "@stencil/sass": "0.1.1", "@stencil/utils": "latest", "@types/jest": "^23.3.1", diff --git a/core/src/components/action-sheet/readme.md b/core/src/components/action-sheet/readme.md index 86e7846dec..d396873624 100644 --- a/core/src/components/action-sheet/readme.md +++ b/core/src/components/action-sheet/readme.md @@ -14,6 +14,116 @@ A button's `role` property can either be `destructive` or `cancel`. Buttons with +## Usage + +### Angular + +```typescript +import { Component } from '@angular/core'; +import { ActionSheetController } from '@ionic/angular'; + +@Component({ + selector: 'action-sheet-example', + templateUrl: 'action-sheet-example.html', + styleUrls: ['./action-sheet-example.css'], +}) +export class ActionSheetExample { + + constructor(public actionSheetController: ActionSheetController) {} + + async presentActionSheet() { + const actionSheet = await this.actionSheetController.create({ + header: 'Albums', + buttons: [{ + text: 'Delete', + role: 'destructive', + icon: 'trash', + handler: () => { + console.log('Delete clicked'); + } + }, { + text: 'Share', + icon: 'share', + handler: () => { + console.log('Share clicked'); + } + }, { + text: 'Play (open modal)', + icon: 'arrow-dropright-circle', + handler: () => { + console.log('Play clicked'); + } + }, { + text: 'Favorite', + icon: 'heart', + handler: () => { + console.log('Favorite clicked'); + } + }, { + text: 'Cancel', + icon: 'close', + role: 'cancel', + handler: () => { + console.log('Cancel clicked'); + } + }] + }); + await actionSheet.present(); + } + +} +``` + + +### Javascript + +```javascript +async function presentActionSheet() { + const actionSheetController = document.querySelector('ion-action-sheet-controller'); + await actionSheetController.componentOnReady(); + + const actionSheet = await actionSheetController.create({ + header: "Albums", + buttons: [{ + text: 'Delete', + role: 'destructive', + icon: 'trash', + handler: () => { + console.log('Delete clicked'); + } + }, { + text: 'Share', + icon: 'share', + handler: () => { + console.log('Share clicked'); + } + }, { + text: 'Play (open modal)', + icon: 'arrow-dropright-circle', + handler: () => { + console.log('Play clicked'); + } + }, { + text: 'Favorite', + icon: 'heart', + handler: () => { + console.log('Favorite clicked'); + } + }, { + text: 'Cancel', + icon: 'close', + role: 'cancel', + handler: () => { + console.log('Cancel clicked'); + } + }] + }); + await actionSheet.present(); +} +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/alert/readme.md b/core/src/components/alert/readme.md index bdf2eb7c1a..e22d8abec6 100644 --- a/core/src/components/alert/readme.md +++ b/core/src/components/alert/readme.md @@ -23,6 +23,510 @@ Alerts can also include several different inputs whose data can be passed back t +## Usage + +### Angular + +```typescript +import { Component } from '@angular/core'; +import { AlertController } from '@ionic/angular'; + +@Component({ + selector: 'alert-example', + templateUrl: 'alert-example.html', + styleUrls: ['./alert-example.css'], +}) +export class AlertExample { + + constructor(public alertController: AlertController) {} + + async presentAlert() { + const alert = await this.alertController.create({ + header: 'Alert', + subHeader: 'Subtitle', + message: 'This is an alert message.', + buttons: ['OK'] + }); + + await alert.present(); + } + + async presentAlertMultipleButtons() { + const alert = await this.alertController.create({ + header: 'Alert', + subHeader: 'Subtitle', + message: 'This is an alert message.', + buttons: ['Cancel', 'Open Modal', 'Delete'] + }); + + await alert.present(); + } + + async presentAlertConfirm() { + const alert = await this.alertController.create({ + header: 'Confirm!', + message: 'Message text!!!', + buttons: [ + { + text: 'Cancel', + role: 'cancel', + cssClass: 'secondary', + handler: (blah) => { + console.log('Confirm Cancel: blah'); + } + }, { + text: 'Okay', + handler: () => { + console.log('Confirm Okay'); + } + } + ] + }); + + await alert.present(); + } + + async presentAlertPrompt() { + const alert = await this.alertController.create({ + header: 'Prompt!', + inputs: [ + { + name: 'name1', + type: 'text', + placeholder: 'Placeholder 1' + }, + { + name: 'name2', + type: 'text', + id: 'name2-id', + value: 'hello', + placeholder: 'Placeholder 2' + }, + { + name: 'name3', + value: 'http://ionicframework.com', + type: 'url', + placeholder: 'Favorite site ever' + }, + // input date with min & max + { + name: 'name4', + type: 'date', + min: '2017-03-01', + max: '2018-01-12' + }, + // input date without min nor max + { + name: 'name5', + type: 'date' + }, + { + name: 'name6', + type: 'number', + min: -5, + max: 10 + }, + { + name: 'name7', + type: 'number' + } + ], + buttons: [ + { + text: 'Cancel', + role: 'cancel', + cssClass: 'secondary', + handler: () => { + console.log('Confirm Cancel'); + } + }, { + text: 'Ok', + handler: () => { + console.log('Confirm Ok'); + } + } + ] + }); + + await alert.present(); + } + + async presentAlertRadio() { + const alert = await this.alertController.create({ + header: 'Radio', + inputs: [ + { + name: 'radio1', + type: 'radio', + label: 'Radio 1', + value: 'value1', + checked: true + }, + { + name: 'radio2', + type: 'radio', + label: 'Radio 2', + value: 'value2' + }, + { + name: 'radio3', + type: 'radio', + label: 'Radio 3', + value: 'value3' + }, + { + name: 'radio4', + type: 'radio', + label: 'Radio 4', + value: 'value4' + }, + { + name: 'radio5', + type: 'radio', + label: 'Radio 5', + value: 'value5' + }, + { + name: 'radio6', + type: 'radio', + label: 'Radio 6 Radio 6 Radio 6 Radio 6 Radio 6 Radio 6 Radio 6 Radio 6 Radio 6 Radio 6 ', + value: 'value6' + } + ], + buttons: [ + { + text: 'Cancel', + role: 'cancel', + cssClass: 'secondary', + handler: () => { + console.log('Confirm Cancel'); + } + }, { + text: 'Ok', + handler: () => { + console.log('Confirm Ok'); + } + } + ] + }); + + await alert.present(); + } + + async presentAlertCheckbox() { + const alert = await this.alertController.create({ + header: 'Checkbox', + inputs: [ + { + name: 'checkbox1', + type: 'checkbox', + label: 'Checkbox 1', + value: 'value1', + checked: true + }, + + { + name: 'checkbox2', + type: 'checkbox', + label: 'Checkbox 2', + value: 'value2' + }, + + { + name: 'checkbox3', + type: 'checkbox', + label: 'Checkbox 3', + value: 'value3' + }, + + { + name: 'checkbox4', + type: 'checkbox', + label: 'Checkbox 4', + value: 'value4' + }, + + { + name: 'checkbox5', + type: 'checkbox', + label: 'Checkbox 5', + value: 'value5' + }, + + { + name: 'checkbox6', + type: 'checkbox', + label: 'Checkbox 6 Checkbox 6 Checkbox 6 Checkbox 6 Checkbox 6 Checkbox 6 Checkbox 6 Checkbox 6 Checkbox 6 Checkbox 6', + value: 'value6' + } + ], + buttons: [ + { + text: 'Cancel', + role: 'cancel', + cssClass: 'secondary', + handler: () => { + console.log('Confirm Cancel'); + } + }, { + text: 'Ok', + handler: () => { + console.log('Confirm Ok'); + } + } + ] + }); + + await alert.present(); + } + +} +``` + + +### Javascript + +```javascript +async function presentAlert() { + const alertController = document.querySelector('ion-alert-controller'); + await alertController.componentOnReady(); + + const alert = await alertController.create({ + header: 'Alert', + subHeader: 'Subtitle', + message: 'This is an alert message.', + buttons: ['OK'] + }); + return await alert.present(); +} + +async function presentAlertMultipleButtons() { + const alertController = document.querySelector('ion-alert-controller'); + await alertController.componentOnReady(); + + const alert = await alertController.create({ + header: 'Alert', + subHeader: 'Subtitle', + message: 'This is an alert message.', + buttons: ['Cancel', 'Open Modal', 'Delete'] + }); + return await alert.present(); +} + +async function presentAlertConfirm() { + const alertController = document.querySelector('ion-alert-controller'); + await alertController.componentOnReady(); + + const alert = await alertController.create({ + header: 'Confirm!', + message: 'Message text!!!', + buttons: [ + { + text: 'Cancel', + role: 'cancel', + cssClass: 'secondary', + handler: (blah) => { + console.log('Confirm Cancel: blah'); + } + }, { + text: 'Okay', + handler: () => { + console.log('Confirm Okay') + } + } + ] + }); + return await alert.present(); +} + +async function presentAlertPrompt() { + const alertController = document.querySelector('ion-alert-controller'); + await alertController.componentOnReady(); + + const alert = await alertController.create({ + header: 'Prompt!', + inputs: [ + { + placeholder: 'Placeholder 1' + }, + { + name: 'name2', + id: 'name2-id', + value: 'hello', + placeholder: 'Placeholder 2' + }, + { + name: 'name3', + value: 'http://ionicframework.com', + type: 'url', + placeholder: 'Favorite site ever' + }, + // input date with min & max + { + name: 'name4', + type: 'date', + min: '2017-03-01', + max: '2018-01-12' + }, + // input date without min nor max + { + name: 'name5', + type: 'date' + }, + { + name: 'name6', + type: 'number', + min: -5, + max: 10 + }, + { + name: 'name7', + type: 'number' + } + ], + buttons: [ + { + text: 'Cancel', + role: 'cancel', + cssClass: 'secondary', + handler: () => { + console.log('Confirm Cancel') + } + }, { + text: 'Ok', + handler: () => { + console.log('Confirm Ok') + } + } + ] + }); + return await alert.present(); +} + +async function presentAlertRadio() { + const alertController = document.querySelector('ion-alert-controller'); + await alertController.componentOnReady(); + + const alert = await alertController.create({ + header: 'Radio', + inputs: [ + { + type: 'radio', + label: 'Radio 1', + value: 'value1', + checked: true + }, + { + type: 'radio', + label: 'Radio 2', + value: 'value2' + }, + { + type: 'radio', + label: 'Radio 3', + value: 'value3' + }, + { + type: 'radio', + label: 'Radio 4', + value: 'value4' + }, + { + type: 'radio', + label: 'Radio 5', + value: 'value5' + }, + { + type: 'radio', + label: 'Radio 6 Radio 6 Radio 6 Radio 6 Radio 6 Radio 6 Radio 6 Radio 6 Radio 6 Radio 6 ', + value: 'value6' + } + ], + buttons: [ + { + text: 'Cancel', + role: 'cancel', + cssClass: 'secondary', + handler: () => { + console.log('Confirm Cancel') + } + }, { + text: 'Ok', + handler: () => { + console.log('Confirm Ok') + } + } + ] + }); + return await alert.present(); +} + +async function presentAlertCheckbox() { + const alertController = document.querySelector('ion-alert-controller'); + await alertController.componentOnReady(); + + const alert = await alertController.create({ + header: 'Checkbox', + inputs: [ + { + type: 'checkbox', + label: 'Checkbox 1', + value: 'value1', + checked: true + }, + + { + type: 'checkbox', + label: 'Checkbox 2', + value: 'value2' + }, + + { + type: 'checkbox', + label: 'Checkbox 3', + value: 'value3' + }, + + { + type: 'checkbox', + label: 'Checkbox 4', + value: 'value4' + }, + + { + type: 'checkbox', + label: 'Checkbox 5', + value: 'value5' + }, + + { + type: 'checkbox', + label: 'Checkbox 6 Checkbox 6 Checkbox 6 Checkbox 6 Checkbox 6 Checkbox 6 Checkbox 6 Checkbox 6 Checkbox 6 Checkbox 6', + value: 'value6' + } + ], + buttons: [ + { + text: 'Cancel', + role: 'cancel', + cssClass: 'secondary', + handler: () => { + console.log('Confirm Cancel') + } + }, { + text: 'Ok', + handler: () => { + console.log('Confirm Ok') + } + } + ] + }); + return await alert.present(); +} +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/avatar/readme.md b/core/src/components/avatar/readme.md index 6708e9ec0f..c38010ef45 100644 --- a/core/src/components/avatar/readme.md +++ b/core/src/components/avatar/readme.md @@ -8,6 +8,55 @@ Avatars can be used by themselves or inside of any element. If placed inside of +## Usage + +### Angular + +```html + + + + + + + + + Chip Avatar + + + + + + + Item Avatar + +``` + + +### Javascript + +```html + + + + + + + + + Chip Avatar + + + + + + + Item Avatar + +``` + + + ## CSS Custom Properties | Name | Description | diff --git a/core/src/components/back-button/readme.md b/core/src/components/back-button/readme.md index a029b1fdf7..0864b10825 100644 --- a/core/src/components/back-button/readme.md +++ b/core/src/components/back-button/readme.md @@ -8,6 +8,114 @@ To change what is displayed in the back button, use the `text` and `icon` proper +## Usage + +### Angular + +```html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + + +### Javascript + +```html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/backdrop/readme.md b/core/src/components/backdrop/readme.md index aa3fa392b6..a28aba7673 100644 --- a/core/src/components/backdrop/readme.md +++ b/core/src/components/backdrop/readme.md @@ -6,6 +6,75 @@ Backdrops are full screen components that overlay other components. They are use +## Usage + +### Angular + +```html + + + + + + + + + + + + + + + +``` + +```typescript +import { Component } from '@angular/core'; + +@Component({ + selector: 'backdrop-example', + templateUrl: 'backdrop-example.html', + styleUrls: ['./backdrop-example.css'], +}) +export class BackdropExample { + backdropDismiss = false; + showBackdrop = false; + shouldPropagate = false; +} +``` + + +### Javascript + +```html + + + + + + + + + + + + + + +``` + +```javascript +var backdrop = document.getElementById('customBackdrop'); +backdrop.visible = false; +backdrop.tappable = false; +backdrop.stopPropagation = false; +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/badge/readme.md b/core/src/components/badge/readme.md index d3bbacd8e7..3995d9d096 100644 --- a/core/src/components/badge/readme.md +++ b/core/src/components/badge/readme.md @@ -6,6 +6,35 @@ Badges are inline block elements that usually appear near another element. Typic +## Usage + +### Angular / javascript + +```html + +99 + + +11 +22 +33 +44 +55 +66 +77 +88 +99 + + + + 11 + My Item + 22 + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/button/readme.md b/core/src/components/button/readme.md index d359e8525b..744276ce0a 100644 --- a/core/src/components/button/readme.md +++ b/core/src/components/button/readme.md @@ -35,6 +35,63 @@ This attribute specifies the size of the button. Setting this attribute will cha +## Usage + +### Angular / javascript + +```html + +Default + + +Anchor + + +Primary +Secondary +Tertiary +Success +Warning +Danger +Light +Medium +Dark + + +Full Button +Block Button + + +Round Button + + +Outline + Full +Outline + Block +Outline + Round + + + + + Left Icon + + + + Right Icon + + + + + + + + +Large +Default +Small +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/button/usage/angular.md b/core/src/components/button/usage/angular.md index 6924c01c1d..b8e957e77d 100644 --- a/core/src/components/button/usage/angular.md +++ b/core/src/components/button/usage/angular.md @@ -6,9 +6,6 @@ Anchor - -Backwards Anchor - Primary Secondary diff --git a/core/src/components/button/usage/javascript.md b/core/src/components/button/usage/javascript.md index bf83a28c86..b8e957e77d 100644 --- a/core/src/components/button/usage/javascript.md +++ b/core/src/components/button/usage/javascript.md @@ -6,9 +6,6 @@ Anchor - -Backwards Anchor - Primary Secondary diff --git a/core/src/components/buttons/readme.md b/core/src/components/buttons/readme.md index 9f04f6760e..675505e594 100644 --- a/core/src/components/buttons/readme.md +++ b/core/src/components/buttons/readme.md @@ -15,6 +15,95 @@ The `` element can be positioned inside of the toolbar using a name +## Usage + +### Angular + +```html + + + + + Back Button + + + + + + + + + + + + Default Buttons + + + + + + + + + + + + + + Right side menu toggle + + + + +``` + + +### Javascript + +```html + + + + + Back Button + + + + + + + + + + + + Default Buttons + + + + + + + + + + + + + + Right side menu toggle + + + + + + + + +``` + + + ---------------------------------------------- *Built with [StencilJS](https://stenciljs.com/)* diff --git a/core/src/components/card/readme.md b/core/src/components/card/readme.md index 5e76ea220f..2e84bfb69e 100644 --- a/core/src/components/card/readme.md +++ b/core/src/components/card/readme.md @@ -9,6 +9,61 @@ sub-components to reflect this. Please see `ion-card-content`, +## Usage + +### Angular / javascript + +```html + + + Card Subtitle + Card Title + + + + Keep close to Nature's heart... and break clear away, once in awhile, + and climb a mountain or spend a week in the woods. Wash your spirit clean. + + + + + + + ion-item in a card, icon left, button right + View + + + + This is content, without any paragraph or header tags, + within an ion-card-content element. + + + + + + + Card Link Item 1 .activated + + + + + Card Link Item 2 + + + + + Card Button Item 1 .activated + + + + + Card Button Item 2 + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/checkbox/readme.md b/core/src/components/checkbox/readme.md index b55f7b2bf9..b50ca07f53 100644 --- a/core/src/components/checkbox/readme.md +++ b/core/src/components/checkbox/readme.md @@ -8,6 +8,94 @@ Checkboxes allow the selection of multiple options from a set of options. They a +## Usage + +### Angular + +```html + + + + + + + + + + + + + + + + + + + + {{entry.val}} + + + +``` + +```typescript +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-page-home', + templateUrl: 'home.page.html', + styleUrls: ['home.page.scss'] +}) +export class HomePage { + public form = [ + { val: 'Pepperoni', isChecked: true }, + { val: 'Sausage', isChecked: false }, + { val: 'Mushroom', isChecked: false } + ]; +} +``` + + +### Javascript + +```html + + + + + + + + + + + + + + + + + + + + Pepperoni + + + + + Sausage + + + + + Mushrooms + + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/chip/readme.md b/core/src/components/chip/readme.md index 33af572488..a786897c77 100644 --- a/core/src/components/chip/readme.md +++ b/core/src/components/chip/readme.md @@ -5,6 +5,55 @@ Chips represent complex entities in small blocks, such as a contact. A chip can +## Usage + +### Angular / javascript + +```html + + Default + + + + Secondary Label + + + + Secondary w/ Dark label + + + + + Default + + + + + Default + + + + Button Chip + + + + + + Icon Chip + + + + + + + + Avatar Chip + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/content/readme.md b/core/src/components/content/readme.md index 57c09a0119..8695bc4447 100644 --- a/core/src/components/content/readme.md +++ b/core/src/components/content/readme.md @@ -7,6 +7,36 @@ view component. +## Usage + +### Angular + +```html + + +``` + + +### Javascript + +```html + +``` + +```javascript +var content = document.querySelector('ion-content'); +content.scrollEvents = true; +content.addEventListener('ionScrollStart', () => console.log('scroll start')); +content.addEventListener('ionScroll', (ev) => console.log('scroll', ev.detail)); +content.addEventListener('ionScrollEnd', () => console.log('scroll end')); +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/datetime/readme.md b/core/src/components/datetime/readme.md index 0efc6f75b5..f94daa7f3b 100644 --- a/core/src/components/datetime/readme.md +++ b/core/src/components/datetime/readme.md @@ -202,6 +202,234 @@ dates in JavaScript. +## Usage + +### Angular + +```html + + MMMM + + + + + MM DD YY + + + + + Disabled + + + + + YYYY + + + + + MMMM YY + + + + + MM/DD/YYYY + + + + + MM/DD/YYYY + + + + + DDD. MMM DD, YY (custom locale) + + + + + D MMM YYYY H:mm + + + + + DDDD MMM D, YYYY + + + + + HH:mm + + + + + h:mm a + + + + + hh:mm A (15 min steps) + + + + + Leap years, summer months + + + + + Specific days/months/years + + +``` + +```javascript +this.customYearValues = [2020, 2016, 2008, 2004, 2000, 1996]; + +this.customDayShortNames = [ + 's\u00f8n', + 'man', + 'tir', + 'ons', + 'tor', + 'fre', + 'l\u00f8r' +]; + +this.customPickerOptions = { + buttons: [{ + text: 'Save', + handler: () => console.log('Clicked Save!') + }, { + text: 'Log', + handler: () => { + console.log('Clicked Log. Do not Dismiss.'); + return false; + } + }] +} +``` + + +### Javascript + +```html + + MMMM + + + + + MM DD YY + + + + + Disabled + + + + + YYYY + + + + + MMMM YY + + + + + MM/DD/YYYY + + + + + MM/DD/YYYY + + + + + DDD. MMM DD, YY (custom locale) + + + + + D MMM YYYY H:mm + + + + + DDDD MMM D, YYYY + + + + + HH:mm + + + + + h:mm a + + + + + hh:mm A (15 min steps) + + + + + Leap years, summer months + + + + + Specific days/months/years + + +``` + +```javascript +var yearValuesArray = [2020, 2016, 2008, 2004, 2000, 1996]; +var customYearValues = document.getElementById('customYearValues'); +customYearValues.yearValues = yearValuesArray; + +var dayShortNamesArray = [ + 's\u00f8n', + 'man', + 'tir', + 'ons', + 'tor', + 'fre', + 'l\u00f8r' +]; +var customDayShortNames = document.getElementById('customDayShortNames'); +customDayShortNames.dayShortNames = dayShortNamesArray; + +var customPickerButtons = { + buttons: [{ + text: 'Save', + handler: () => console.log('Clicked Save!') + }, { + text: 'Log', + handler: () => { + console.log('Clicked Log. Do not Dismiss.'); + return false; + } + }] +} +var customPickerOptions = document.getElementById('customPickerOptions'); +customPickerOptions.pickerOptions = customPickerButtons; +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/fab-button/readme.md b/core/src/components/fab-button/readme.md index c48ec87600..23207ae3d4 100644 --- a/core/src/components/fab-button/readme.md +++ b/core/src/components/fab-button/readme.md @@ -7,6 +7,36 @@ If the FAB button is not wrapped with ``, it will scroll with the conte +## Usage + +### Angular / javascript + +```html + + + + + Button + + + + Default + + + Mini + + + Primary + Secondary + Danger + Light + Dark + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/fab-list/readme.md b/core/src/components/fab-list/readme.md index 069718ed98..611a0e29ad 100644 --- a/core/src/components/fab-list/readme.md +++ b/core/src/components/fab-list/readme.md @@ -5,6 +5,29 @@ The `ion-fab-list` element is a container for multiple fab buttons. This collect +## Usage + +### Angular / javascript + +```html + + Share + + + Facebook + Twitter + Youtube + + + + Vimeo + + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/fab/readme.md b/core/src/components/fab/readme.md index be51a3c36b..e399e36b38 100644 --- a/core/src/components/fab/readme.md +++ b/core/src/components/fab/readme.md @@ -5,6 +5,94 @@ Fabs are container elements that contain one or more fab buttons. They should be +## Usage + +### Angular / javascript + +```html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/footer/readme.md b/core/src/components/footer/readme.md index e410837e70..923affa9a5 100644 --- a/core/src/components/footer/readme.md +++ b/core/src/components/footer/readme.md @@ -6,6 +6,22 @@ Footer can be a wrapper for ion-toolbar to make sure the content area is sized c +## Usage + +### Javascript + +```html + + + + + Footer + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/grid/readme.md b/core/src/components/grid/readme.md index dff2cbc996..78453a01a1 100644 --- a/core/src/components/grid/readme.md +++ b/core/src/components/grid/readme.md @@ -10,6 +10,192 @@ See [Grid Layout](/docs/layout/grid) for more information. +## Usage + +### Angular / javascript + +```html + + + + ion-col + + + ion-col + + + ion-col + + + ion-col + + + + + + ion-col [size="6"] + + + ion-col + + + ion-col + + + + + + ion-col [size="3"] + + + ion-col + + + ion-col [size="3"] + + + + + + ion-col [size="3"] + + + ion-col [size="3"] [offset="3"] + + + + + + ion-col + + + ion-col +
# +
+ + ion-col +
# +
# +
+ + ion-col +
# +
# +
# +
+
+ + + + ion-col [start] + + + ion-col [center] + + + ion-col [end] + + + ion-col +
# +
# +
+
+ + + + [start] ion-col + + + [start] ion-col + + + [start] ion-col [end] + + + ion-col +
# +
# +
+
+ + + + [center] ion-col + + + [center] ion-col + + + [center] ion-col + + + ion-col +
# +
# +
+
+ + + + [end] ion-col + + + [end] ion-col [start] + + + [end] ion-col + + + ion-col +
# +
# +
+
+ + + + ion-col [size="12"] [size-sm] + + + ion-col [size="12"] [size-sm] + + + ion-col [size="12"] [size-sm] + + + ion-col [size="12"] [size-sm] + + + + + + ion-col [size="12"] [size-md] + + + ion-col [size="12"] [size-md] + + + ion-col [size="12"] [size-md] + + + ion-col [size="12"] [size-md] + + + + + + ion-col [size="6"] [size-lg] [offset="3"] + + + ion-col [size="3"] [size-lg] + + +
+``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/header/readme.md b/core/src/components/header/readme.md index 03c6fdee8e..771ac19b87 100644 --- a/core/src/components/header/readme.md +++ b/core/src/components/header/readme.md @@ -8,6 +8,29 @@ It's important to note that ion-header needs to be the one of the three root ele +## Usage + +### Javascript + +```html + + + + + + My Navigation Bar + + + + Subheader + + + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/img/readme.md b/core/src/components/img/readme.md index ee249b4cc3..a51ad2699e 100644 --- a/core/src/components/img/readme.md +++ b/core/src/components/img/readme.md @@ -6,6 +6,23 @@ Img is a tag that will lazily load an image when ever the tag is in the viewport +## Usage + +### Angular + +```html + + + + + + {{item.text}} + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/infinite-scroll-content/readme.md b/core/src/components/infinite-scroll-content/readme.md index 7515af7b56..5cc32ec48f 100644 --- a/core/src/components/infinite-scroll-content/readme.md +++ b/core/src/components/infinite-scroll-content/readme.md @@ -5,6 +5,37 @@ The `ion-infinite-scroll-content` component is the default child used by the `io +## Usage + +### Angular + +```html + + + + + + +``` + + +### Javascript + +```html + + + + + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/infinite-scroll/readme.md b/core/src/components/infinite-scroll/readme.md index 354e880c11..42535bcb14 100644 --- a/core/src/components/infinite-scroll/readme.md +++ b/core/src/components/infinite-scroll/readme.md @@ -15,6 +15,103 @@ Separating the `ion-infinite-scroll` and `ion-infinite-scroll-content` component +## Usage + +### Angular + +```html + + + Toggle Infinite Scroll + + + + + + + + + +``` + +```typescript +import { Component, ViewChild } from '@angular/core'; +import { InfiniteScroll } from '@ionic/angular'; + +@Component({ + selector: 'infinite-scroll-example', + templateUrl: 'infinite-scroll-example.html', + styleUrls: ['./infinite-scroll-example.css'] +}) +export class InfiniteScrollExample { + @ViewChild(InfiniteScroll) infiniteScroll: InfiniteScroll; + + constructor() {} + + loadData(event) { + setTimeout(() => { + console.log('Done'); + event.target.complete(); + + // App logic to determine if all data is loaded + // and disable the infinite scroll + if (data.length == 1000) { + event.target.disabled = true; + } + }, 500); + } + + toggleInfiniteScroll() { + infiniteScroll.disabled = !infiniteScroll.disabled; + } +} +``` + + +### Javascript + +```html + + + Toggle Infinite Scroll + + + + + + + + + +``` + +```javascript +const infiniteScroll = document.getElementById('infinite-scroll'); + +infiniteScroll.addEventListener('ionInfinite', function(event) { + setTimeout(function() { + console.log('Done'); + event.target.complete(); + + // App logic to determine if all data is loaded + // and disable the infinite scroll + if (data.length == 1000) { + event.target.disabled = true; + } + }, 500); +}); + +function toggleInfiniteScroll() { + infiniteScroll.disabled = !infiniteScroll.disabled; +} +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/input/readme.md b/core/src/components/input/readme.md index cf17dfcfda..030e1b7063 100644 --- a/core/src/components/input/readme.md +++ b/core/src/components/input/readme.md @@ -8,6 +8,103 @@ It is meant for text `type` inputs only, such as `"text"`, `"password"`, `"email +## Usage + +### Angular + +```html + + + + + + + + + + + + + + + + + + + + + + + + Default Label + + + + + Floating Label + + + + + Fixed Label + + + + + Stacked Label + + +``` + + +### Javascript + +```html + + + + + + + + + + + + + + + + + + + + + + + + Default Label + + + + + Floating Label + + + + + Fixed Label + + + + + Stacked Label + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/item-divider/readme.md b/core/src/components/item-divider/readme.md index 185f69a211..5009c15f8e 100644 --- a/core/src/components/item-divider/readme.md +++ b/core/src/components/item-divider/readme.md @@ -5,6 +5,53 @@ Item Dividers are block elements that can be used to separate items in a list. T +## Usage + +### Angular / javascript + +```html + + + Basic Item Divider + + + + + + Secondary Item Divider + + + + + + + + Section A + + + + A1 + A2 + A3 + A4 + A5 + + + + Section B + + + + B1 + B2 + B3 + B4 + B5 + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/item-group/readme.md b/core/src/components/item-group/readme.md index 71c7fc65a8..5c4eb3d67c 100644 --- a/core/src/components/item-group/readme.md +++ b/core/src/components/item-group/readme.md @@ -8,6 +8,116 @@ Item groups are containers that organize similar items together. They can contai +## Usage + +### Angular / javascript + +```html + + + A + + + + Angola + + + Argentina + + + Armenia + + + + + + B + + + + Bangladesh + + + Belarus + + + Belgium + + + + + + + + + Fruits + + + + + + +

Grapes

+
+
+ + + Favorite + + +
+ + + + +

Apples

+
+
+ + + Favorite + + +
+
+ + + + + Vegetables + + + + + + +

Carrots

+
+
+ + + Favorite + + +
+ + + + +

Celery

+
+
+ + + Favorite + + +
+
+``` + + + ---------------------------------------------- *Built with [StencilJS](https://stenciljs.com/)* diff --git a/core/src/components/item-sliding/readme.md b/core/src/components/item-sliding/readme.md index d75d575759..308882d731 100644 --- a/core/src/components/item-sliding/readme.md +++ b/core/src/components/item-sliding/readme.md @@ -29,6 +29,51 @@ Options can be expanded to take up the full width of the item if you swipe past +## Usage + +### Angular + +```html + + + + Item + + + Favorite + Share + + + + Unread + + + +``` + + +### Javascript + +```html + + + + Item + + + Favorite + Share + + + + Unread + + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/item/readme.md b/core/src/components/item/readme.md index be2936515c..181161eb3e 100644 --- a/core/src/components/item/readme.md +++ b/core/src/components/item/readme.md @@ -54,6 +54,649 @@ The highlight color changes based on the item state, but all of the states use I +## Usage + +### Angular + +Basic Usage + +```html + + + + Item + + + + + + + Button Item + + + + + + + Anchor Item + + + + + + Secondary Color Item + + +``` + +Detail Arrows + +```html + + + Standard Item with Detail Arrow + + + + + + Button Item with Detail Arrow + + + + + + Anchor Item with no Detail Arrow + + +``` + +List Items + +```html + + + + Item + + + + + + No Lines Item + + + + + + Multiline text that should wrap when it is too long + to fit on one line in the item. + + + + + + +

H3 Primary Title

+
+

Paragraph line 1

+ +

Paragraph line 2 secondary

+
+
+
+ + + + Item with Full Lines + + + +
+``` + +Item Lines + +```html + + + Item Lines Inset + + + + + Item Lines Full + + + + + Item Lines None + + + + + + Item + + + + Item + + + + + + + Item + + + + Item + + + + + + + Item + + + + Item + + +``` + + +Media Items + +```html + + + + + + Avatar Start, Button Item + + + + + + Thumbnail End, Anchor Item + + + + + + + + + + + +

H2 Title Text

+

Button on right

+
+ View +
+ + + + + + +

H3 Title Text

+

Icon on right

+
+ +
+``` + +Buttons in Items + +```html + + + Start + + Button Start/End + + End + + + + + + Start Icon + + + Buttons with Icons + + + End Icon + + + + + + + + Icon only Buttons + + + + +``` + +Icons in Items + +```html + + + Icon End + + + + + + + Large Icon End + + + + + + + Small Icon End + + + + + + + + Icon Start + + + + + + Two Icons End + + + + +``` + +Item Inputs + +```html + + Datetime + + + + + Select + + No Game Console + NES + Nintendo64 + PlayStation + Sega Genesis + Sega Saturn + SNES + + + + + Toggle + + + + + Floating Input + + + + + Input (placeholder) + + + + + Checkbox + + + + + Range + + +``` + + +### Javascript + +Basic Usage + +```html + + + + Item + + + + + + + Button Item + + + + + + + Anchor Item + + + + + + Secondary Color Item + + +``` + +Detail Arrows + +```html + + + Standard Item with Detail Arrow + + + + + + Button Item with Detail Arrow + + + + + + Anchor Item with no Detail Arrow + + +``` + +List Items + +```html + + + + Item + + + + + + No Lines Item + + + + + + Multiline text that should wrap when it is too long + to fit on one line in the item. + + + + + + +

H3 Primary Title

+
+

Paragraph line 1

+ +

Paragraph line 2 secondary

+
+
+
+ + + + Item with Full Lines + + + +
+``` + +Item Lines + +```html + + + Item Lines Inset + + + + + Item Lines Full + + + + + Item Lines None + + + + + + Item + + + + Item + + + + + + + Item + + + + Item + + + + + + + Item + + + + Item + + +``` + + +Media Items + +```html + + + + + + Avatar Start, Button Item + + + + + + Thumbnail End, Anchor Item + + + + + + + + + + + +

H2 Title Text

+

Button on right

+
+ View +
+ + + + + + +

H3 Title Text

+

Icon on right

+
+ +
+``` + +Buttons in Items + +```html + + + Start + + Button Start/End + + End + + + + + + Start Icon + + + Buttons with Icons + + + End Icon + + + + + + + + Icon only Buttons + + + + +``` + +Icons in Items + +```html + + + Icon End + + + + + + + Large Icon End + + + + + + + Small Icon End + + + + + + + + Icon Start + + + + + + Two Icons End + + + + +``` + +Item Inputs + +```html + + Datetime + + + + + Select + + No Game Console + NES + Nintendo64 + PlayStation + Sega Genesis + Sega Saturn + SNES + + + + + Toggle + + + + + Floating Input + + + + + Input (placeholder) + + + + + Checkbox + + + + + Range + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/label/readme.md b/core/src/components/label/readme.md index d19cae71f0..d79479df4c 100644 --- a/core/src/components/label/readme.md +++ b/core/src/components/label/readme.md @@ -6,6 +6,67 @@ Label is a wrapper element that can be used in combination with `ion-item`, `ion +## Usage + +### Angular / javascript + +```html + +Label + + +Primary Label +Secondary Label +Danger Label +Light Label +Dark Label + + + + Default Item + + + + + Multi-line text that should wrap when it is too long + to fit on one line in the item. + + + + + + Default Input + + + + + Fixed + + + + + Floating + + + + + Stacked + + + + + Toggle + + + + + + Checkbox + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/list-header/readme.md b/core/src/components/list-header/readme.md index c88157e6d5..a680ecf73d 100644 --- a/core/src/components/list-header/readme.md +++ b/core/src/components/list-header/readme.md @@ -7,6 +7,25 @@ Unlike ItemDivider, ListHeaders are styled to be stand-out from the rest of the +## Usage + +### Javascript + +```html + + + Items + + Item 1 + Item 2 + Item 3 + Item 4 + Item 5 + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/list/readme.md b/core/src/components/list/readme.md index 4f622a1fd2..4613c50e61 100644 --- a/core/src/components/list/readme.md +++ b/core/src/components/list/readme.md @@ -9,6 +9,139 @@ Lists support several interactions including swiping items to reveal options, dr +## Usage + +### Angular + +```html + + + + Pokémon Yellow + + + Mega Man X + + + The Legend of Zelda + + + Pac-Man + + + Super Mario World + + + + + + + Input + + + + Toggle + + + + Radio + + + + Checkbox + + + + + + + + + Item + + + Unread + + + + + + Item + + + Unread + + + +``` + + +### Javascript + +```html + + + + Pokémon Yellow + + + Mega Man X + + + The Legend of Zelda + + + Pac-Man + + + Super Mario World + + + + + + + Input + + + + Toggle + + + + Radio + + + + Checkbox + + + + + + + + + Item + + + Unread + + + + + + Item + + + Unread + + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/loading-controller/readme.md b/core/src/components/loading-controller/readme.md index 2b3e9d391a..b6ffccad66 100644 --- a/core/src/components/loading-controller/readme.md +++ b/core/src/components/loading-controller/readme.md @@ -8,6 +8,26 @@ Loading controllers programmatically control the loading component. Loadings can +## Usage + +### Javascript + +```javascript +async function presentLoading() { + const loadingController = document.querySelector('ion-loading-controller'); + await loadingController.componentOnReady(); + + const loadingElement = await loadingController.create({ + message: 'Please wait...', + spinner: 'crescent', + duration: 2000 + }); + return await loadingElement.present(); +} +``` + + + ## Methods ### `create(opts?: LoadingOptions | undefined) => Promise` diff --git a/core/src/components/loading/readme.md b/core/src/components/loading/readme.md index a11fd3d758..679b02e87c 100644 --- a/core/src/components/loading/readme.md +++ b/core/src/components/loading/readme.md @@ -16,6 +16,75 @@ The loading indicator can be dismissed automatically after a specific amount of +## Usage + +### Angular + +```typescript +import { Component } from '@angular/core'; +import { LoadingController } from '@ionic/angular'; + +@Component({ + selector: 'loading-example', + templateUrl: 'loading-example.html', + styleUrls: ['./loading-example.css'] +}) +export class LoadingExample { + constructor(public loadingController: LoadingController) {} + + async presentLoading() { + const loading = await this.loadingController.create({ + message: 'Hellooo', + duration: 2000 + }); + return await loading.present(); + } + + async presentLoadingWithOptions() { + const loading = await this.loadingController.create({ + spinner: null, + duration: 5000, + message: 'Please wait...', + translucent: true, + cssClass: 'custom-class custom-loading' + }); + return await loading.present(); + } +} +``` + + +### Javascript + +```javascript +async function presentLoading() { + const loadingController = document.querySelector('ion-loading-controller'); + await loadingController.componentOnReady(); + + const loading = await loadingController.create({ + message: 'Hellooo', + duration: 2000 + }); + return await loading.present(); +} + +async function presentLoadingWithOptions() { + const loadingController = document.querySelector('ion-loading-controller'); + await loadingController.componentOnReady(); + + const loading = await loadingController.create({ + spinner: null, + duration: 5000, + message: 'Please wait...', + translucent: true, + cssClass: 'custom-class custom-loading' + }); + return await loading.present(); +} +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/menu/readme.md b/core/src/components/menu/readme.md index 296af33726..82ec4352b1 100644 --- a/core/src/components/menu/readme.md +++ b/core/src/components/menu/readme.md @@ -11,6 +11,60 @@ These can be controlled from the templates, or programmatically using the MenuCo +## Usage + +### Angular + +```html + + + + Menu + + + + +``` + + +### Javascript + +```html + + + + + Left Menu + + + + + + + + Hola + + + + + hola macho + + + +
+ + + Menu - Basic + + +
+ +
+ +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/modal/readme.md b/core/src/components/modal/readme.md index f5d3ed0e5d..2c6c43b241 100644 --- a/core/src/components/modal/readme.md +++ b/core/src/components/modal/readme.md @@ -12,6 +12,72 @@ Modals can be created using a [Modal Controller](../../modal-controller/ModalCon +## Usage + +### Angular + +```typescript +import { Component } from '@angular/core'; +import { ModalController } from '@ionic/angular'; +import { ModalPage } from '../modal/modal.page'; +@Component({ + selector: 'modal-example', + templateUrl: 'modal-example.html', + styleUrls: ['./modal-example.css'] +}) +export class ModalExample { + constructor(public modalController: ModalController) {} + + async presentModal() { + const modal = await this.modalController.create({ + component: ModalPage, + componentProps: { value: 123 } + }); + return await modal.present(); + } +} +``` + + +### Javascript + +```javascript +async function presentModal() { + // initialize controller + const modalController = document.querySelector('ion-modal-controller'); + await modalController.componentOnReady(); + + // create component to open + const element = document.createElement('div'); + element.innerHTML = ` + <ion-header> + <ion-toolbar> + <ion-title>Super Modal</ion-title> + </ion-toolbar> + </ion-header> + <ion-content> + <h1>Content of doom</h1> + <div>Here's some more content</div> + <ion-button class="dismiss">Dismiss Modal</ion-button> + </ion-content> + `; + + // listen for close event + const button = element.querySelector('ion-button'); + button.addEventListener('click', () => { + modalController.dismiss(); + }); + + // present the modal + const modalElement = await modalController.create({ + component: element + }); + modalElement.present(); +} +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/note/readme.md b/core/src/components/note/readme.md index 4120403816..82fda1ee2d 100644 --- a/core/src/components/note/readme.md +++ b/core/src/components/note/readme.md @@ -6,6 +6,37 @@ Notes are text elements generally used as subtitles that provide more informatio +## Usage + +### Angular / javascript + +```html + +Default Note + + +Primary Note +Secondary Note +Danger Note +Light Note +Dark Note + + + + + Note (End) + On + + + + Off + Note (Start) + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/popover-controller/readme.md b/core/src/components/popover-controller/readme.md index 62cc1ab0b8..e39f36f241 100644 --- a/core/src/components/popover-controller/readme.md +++ b/core/src/components/popover-controller/readme.md @@ -6,6 +6,25 @@ Popover controllers programmatically control the popover component. Popovers can +## Usage + +### Javascript + +```javascript +async function presentPopover() { + const popoverController = document.querySelector('ion-popover-controller'); + await popoverController.componentOnReady(); + + const popoverElement = await popoverController.create({ + component: 'profile-page', + event: event + }); + return await popoverElement.present(); +} +``` + + + ## Methods ### `create(opts: PopoverOptions) => Promise` diff --git a/core/src/components/popover/readme.md b/core/src/components/popover/readme.md index 011cc4a268..21c9d6c02f 100644 --- a/core/src/components/popover/readme.md +++ b/core/src/components/popover/readme.md @@ -14,6 +14,53 @@ To present a popover, call the `present` method on a popover instance. In order +## Usage + +### Angular + +```typescript +import { Component } from '@angular/core'; +import { PopoverController } from '@ionic/angular'; +import { PopoverComponent } from '../../component/popover/popover.component'; + +@Component({ + selector: 'popover-example', + templateUrl: 'popover-example.html', + styleUrls: ['./popover-example.css'] +}) +export class PopoverExample { + constructor(public popoverController: PopoverController) {} + + async presentPopover(ev: any) { + const popover = await this.popoverController.create({ + component: PopoverComponent, + event: ev, + translucent: true + }); + return await popover.present(); + } +} +``` + + +### Javascript + +```javascript +async function presentPopover(ev) { + const popoverController = document.querySelector('ion-popover-controller'); + await popoverController.componentOnReady(); + + const popover = await popoverController.create({ + component: 'popover-example-page', + translucent: true + event: ev, + }); + return await popover.present(); +} +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/radio-group/readme.md b/core/src/components/radio-group/readme.md index cf2f4ce836..423d5aefe1 100644 --- a/core/src/components/radio-group/readme.md +++ b/core/src/components/radio-group/readme.md @@ -11,6 +11,47 @@ radio button within the same group. +## Usage + +### Angular / javascript + +```html + + + + Auto Manufacturers + + + + Cord + + + + + Duesenberg + + + + + Hudson + + + + + Packard + + + + + Studebaker + + + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/radio/readme.md b/core/src/components/radio/readme.md index b6738bf054..da71ca445b 100644 --- a/core/src/components/radio/readme.md +++ b/core/src/components/radio/readme.md @@ -10,6 +10,37 @@ An `ion-radio-group` can be used to group a set of radios. When radios are insid +## Usage + +### Angular / javascript + +```html + + + + Name + + + + Biff + + + + + Griff + + + + + Buford + + + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/range/readme.md b/core/src/components/range/readme.md index e587216223..afa19b6537 100644 --- a/core/src/components/range/readme.md +++ b/core/src/components/range/readme.md @@ -15,6 +15,75 @@ left or right of the range. +## Usage + +### Angular + +```html + + + + + + + + -200 + 200 + + + + + + + + + + + + + + + + + + +``` + + +### Javascript + +```html + + + + + + + + -200 + 200 + + + + + + + + + + + + + + + + + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/refresher/readme.md b/core/src/components/refresher/readme.md index e648dc0859..b009bf4b66 100644 --- a/core/src/components/refresher/readme.md +++ b/core/src/components/refresher/readme.md @@ -13,6 +13,79 @@ refresher. +## Usage + +### Angular + +```html + + + + + + + + + + + + + + +``` + +```typescript +import { Component } from '@angular/core'; + +@Component({ + selector: 'refresher-example', + templateUrl: 'refresher-example.html', + styleUrls: ['./refresher-example.css'], +}) +export class RefresherExample { + constructor() {} + + doRefresh(event) { + console.log('Begin async operation'); + + setTimeout(() => { + console.log('Async operation has ended'); + event.target.complete(); + }, 2000); + } +} +``` + + +### Javascript + +```html + + + + + + + + + + + + + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/reorder-group/readme.md b/core/src/components/reorder-group/readme.md index 2e8ba5584f..f85cb52fe0 100644 --- a/core/src/components/reorder-group/readme.md +++ b/core/src/components/reorder-group/readme.md @@ -49,6 +49,126 @@ This utility is really handy when +## Usage + +### Angular + +```html + + + + + + + Item 1 + + + + + + + Item 2 (default ion-reorder slot="start") + + + + + + + Item 3 (custom ion-reorder) + + + + + + + + + Item 4 (custom ion-reorder slot="start") + + + + + + + + + + Item 5 (the whole item can be dragged) + + + + + + + +``` + + +### Javascript + +```html + + + + + + + Item 1 + + + + + + + Item 2 (default ion-reorder slot="start") + + + + + + + Item 3 (custom ion-reorder) + + + + + + + + + Item 4 (custom ion-reorder slot="start") + + + + + + + + + + Item 5 (the whole item can be dragged) + + + + + + + +``` + +```javascript +const reorderGroup = document.querySelector('ion-reorder-group'); +reorderGroup.addEventListener('ionItemReorder', ({detail}) => { + // finishing the reorder, true means ion-reorder-group with reorder the DOM + detail.complete(true); + + // or: + // reorderGroup.complete(true) +}); +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/ripple-effect/readme.md b/core/src/components/ripple-effect/readme.md index 5f734b56e1..1ef5e31ac1 100644 --- a/core/src/components/ripple-effect/readme.md +++ b/core/src/components/ripple-effect/readme.md @@ -6,6 +6,24 @@ The ripple effect component adds the [Material Design ink ripple interaction eff +## Usage + +### Javascript + +```html +
+ + A plain div with a ripple effect +
+ + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/router/readme.md b/core/src/components/router/readme.md index 298d6b1a91..920277f08c 100644 --- a/core/src/components/router/readme.md +++ b/core/src/components/router/readme.md @@ -18,6 +18,39 @@ If you're using Angular, please see [ion-router-outlet](../router-outlet) instea +## Usage + +### Javascript + +```html + + + + + + + + + + + + + + + + + + + + + + + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/searchbar/readme.md b/core/src/components/searchbar/readme.md index bd57f70d6b..ea8fa984f4 100644 --- a/core/src/components/searchbar/readme.md +++ b/core/src/components/searchbar/readme.md @@ -9,6 +9,77 @@ A Searchbar should be used instead of an input to search lists. A clear button i +## Usage + +### Angular + +```html + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + + +### Javascript + +```html + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/segment-button/readme.md b/core/src/components/segment-button/readme.md index 67894517e1..1d33348fb5 100644 --- a/core/src/components/segment-button/readme.md +++ b/core/src/components/segment-button/readme.md @@ -6,6 +6,316 @@ Segment buttons are groups of related buttons inside of a [Segment](../../segmen +## Usage + +### Angular + +```html + + + + Friends + + + Enemies + + + + + + + Paid + + + Free + + + Top + + + + + + + + + + + + + + + + + Bookmarks + + + Reading List + + + Shared Links + + + + + + + Item One + + + Item Two + + + Item Three + + + + + + + + + + + + + + + + + + + + Item One + + + + Item Two + + + + Item Three + + + + + + + + + Item One + + + + Item Two + + + + Item Three + + + + + + + Item One + + + + Item Two + + + + Item Three + + + + + + + + + Item One + + + + Item Two + + + + Item Three + + +``` + +```typescript +import { Component } from '@angular/core'; + +@Component({ + selector: 'segment-button-example', + templateUrl: 'segment-button-example.html', + styleUrls: ['./segment-button-example.css'], +}) +export class SegmentButtonExample { + segmentButtonClicked(ev: any) { + console.log('Segment button clicked', ev); + } +} +``` + + +### Javascript + +```html + + + + Friends + + + Enemies + + + + + + + Paid + + + Free + + + Top + + + + + + + + + + + + + + + + + Bookmarks + + + Reading List + + + Shared Links + + + + + + + Item One + + + Item Two + + + Item Three + + + + + + + + + + + + + + + + + + + + Item One + + + + Item Two + + + + Item Three + + + + + + + + + Item One + + + + Item Two + + + + Item Three + + + + + + + Item One + + + + Item Two + + + + Item Three + + + + + + + + + Item One + + + + Item Two + + + + Item Three + + +``` + +```javascript +// Listen for ionClick on all segment buttons +const segmentButtons = document.querySelectorAll('ion-segment-button') +for (let i = 0; i < segmentButtons.length; i++) { + segmentButtons[i].addEventListener('ionSelect', (ev) => { + console.log('Segment button clicked', ev); + }) +} +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/segment/readme.md b/core/src/components/segment/readme.md index 12292034cc..a5f80ba150 100644 --- a/core/src/components/segment/readme.md +++ b/core/src/components/segment/readme.md @@ -8,6 +8,204 @@ Their functionality is similar to tabs, where selecting one will deselect all ot +## Usage + +### Angular + +```html + + + + Friends + + + Enemies + + + + + + + Sunny + + + Rainy + + + + + + + Dogs + + + Cats + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Standard + + + Hybrid + + + Satellite + + + + + + + + + + + + + + +``` + +```typescript +import { Component } from '@angular/core'; + +@Component({ + selector: 'segment-example', + templateUrl: 'segment-example.html', + styleUrls: ['./segment-example.css'], +}) +export class SegmentExample { + segmentChanged(ev: any) { + console.log('Segment changed', ev); + } +} +``` + + +### Javascript + +```html + + + + Friends + + + Enemies + + + + + + + Sunny + + + Rainy + + + + + + + Dogs + + + Cats + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Standard + + + Hybrid + + + Satellite + + + + + + + + + + + + + + +``` + +```javascript +// Listen for ionChange on all segments +const segments = document.querySelectorAll('ion-segment') +for (let i = 0; i < segments.length; i++) { + segments[i].addEventListener('ionChange', (ev) => { + console.log('Segment changed', ev); + }) +} +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/select/readme.md b/core/src/components/select/readme.md index 2fb458e2f8..21fc5ce7dc 100644 --- a/core/src/components/select/readme.md +++ b/core/src/components/select/readme.md @@ -39,6 +39,284 @@ Since select uses the alert, action sheet and popover interfaces, options can be +## Usage + +### Angular + +## Single Selection + +```html + + Single Selection + + + Gender + + Female + Male + + + + + Hair Color + + Brown + Blonde + Black + Red + + + + +``` + +## Multiple Selection + +```html + + Multiple Selection + + + Toppings + + Bacon + Black Olives + Extra Cheese + Green Peppers + Mushrooms + Onions + Pepperoni + Pineapple + Sausage + Spinach + + + + + Pets + + Bird + Cat + Dog + Honey Badger + + + +``` + +## Interface Options + +```html + + Interface Options + + + Alert + + Bacon + Black Olives + Extra Cheese + Green Peppers + Mushrooms + Onions + Pepperoni + Pineapple + Sausage + Spinach + + + + + Popover + + Brown + Blonde + Black + Red + + + + + Action Sheet + + Red + Purple + Yellow + Orange + Green + + + + +``` + +```typescript +import { Component } from '@angular/core'; + +@Component({ + selector: 'select-example', + templateUrl: 'select-example.html', + styleUrls: ['./select-example.css'], +}) +export class SelectExample { + customAlertOptions: any = { + header: 'Pizza Toppings', + subHeader: 'Select your toppings', + message: '$1.00 per topping', + translucent: true + }; + + customPopoverOptions: any = { + header: 'Hair Color', + subHeader: 'Select your hair color', + message: 'Only select your dominant hair color' + }; + + customActionSheetOptions: any = { + header: 'Colors', + subHeader: 'Select your favorite color' + }; +} +``` + + +### Javascript + +## Single Selection + +```html + + Single Selection + + + Gender + + Female + Male + + + + + Hair Color + + Brown + Blonde + Black + Red + + + + +``` + +## Multiple Selection + +```html + + Multiple Selection + + + Toppings + + Bacon + Black Olives + Extra Cheese + Green Peppers + Mushrooms + Onions + Pepperoni + Pineapple + Sausage + Spinach + + + + + Pets + + Bird + Cat + Dog + Honey Badger + + + +``` + +## Interface Options + +```html + + Interface Options + + + Alert + + Bacon + Black Olives + Extra Cheese + Green Peppers + Mushrooms + Onions + Pepperoni + Pineapple + Sausage + Spinach + + + + + Popover + + Brown + Blonde + Black + Red + + + + + Action Sheet + + Red + Purple + Yellow + Orange + Green + + + + +``` + +```javascript +var customAlertSelect = document.getElementById('customAlertSelect'); +var customAlertOptions = { + header: 'Pizza Toppings', + subHeader: 'Select your toppings', + message: '$1.00 per topping', + translucent: true +}; +customAlertSelect.interfaceOptions = customAlertOptions; + +var customPopoverSelect = document.getElementById('customPopoverSelect'); +var customPopoverOptions = { + header: 'Hair Color', + subHeader: 'Select your hair color', + message: 'Only select your dominant hair color' +}; +customPopoverSelect.interfaceOptions = customPopoverOptions; + +var customActionSheetSelect = document.getElementById('customActionSheetSelect'); +var customActionSheetOptions = { + header: 'Colors', + subHeader: 'Select your favorite color' +}; +customActionSheetSelect.interfaceOptions = customActionSheetOptions; +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/skeleton-text/readme.md b/core/src/components/skeleton-text/readme.md index 007fbb1cf6..7debd73f65 100644 --- a/core/src/components/skeleton-text/readme.md +++ b/core/src/components/skeleton-text/readme.md @@ -6,6 +6,14 @@ Skeleton Text is a component for rendering placeholder content. The element will +## Usage + +### Javascript + + + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/slides/readme.md b/core/src/components/slides/readme.md index bb02ffde58..564621ada1 100644 --- a/core/src/components/slides/readme.md +++ b/core/src/components/slides/readme.md @@ -19,6 +19,66 @@ Licensed under MIT +## Usage + +### Angular + +```typescript +import { Component } from '@angular/core'; + +@Component({ + selector: 'slides-example', + template: ` + + +

Slide 1

+
+ +

Slide 2

+
+ +

Slide 3

+
+
+ ` +}) +export class SlideExample { + slideOpts = { + effect: 'flip' + }; + constructor() {} +} +``` + + +### Javascript + +```html + + + +

Slide 1

+
+ + +

Slide 2

+
+ + +

Slide 3

+
+
+``` + +```javascript +var slides = document.querySelector('ion-slides'); +slides.options = { + effect: 'flip' +} +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/spinner/readme.md b/core/src/components/spinner/readme.md index d8459830d2..63e7e1a067 100644 --- a/core/src/components/spinner/readme.md +++ b/core/src/components/spinner/readme.md @@ -9,6 +9,38 @@ The default spinner to use is based on the platform. The default spinner for `io +## Usage + +### Angular / javascript + +```html + + + + + + + + + + + + + + + + + + + + + + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/split-pane/readme.md b/core/src/components/split-pane/readme.md index 46fde9fa69..639d849d99 100644 --- a/core/src/components/split-pane/readme.md +++ b/core/src/components/split-pane/readme.md @@ -40,6 +40,49 @@ SplitPane also provides some predefined media queries that can be used. +## Usage + +### Angular + +```html + + + + + + Menu + + + + + + + +``` + + +### Javascript + +```html + + + + + + Menu + + + + + + +

Hello

+
+
+``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/tab-bar/readme.md b/core/src/components/tab-bar/readme.md index 6f76c67124..72183fe844 100644 --- a/core/src/components/tab-bar/readme.md +++ b/core/src/components/tab-bar/readme.md @@ -6,6 +6,34 @@ The tab bar is a UI component that contains a set of [tab buttons](../tab-button +## Usage + +### Angular / javascript + +```html + + + + + + + + + + + + + + + + + + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/tab-button/readme.md b/core/src/components/tab-button/readme.md index 4a327e8520..0ba3c5ede3 100644 --- a/core/src/components/tab-button/readme.md +++ b/core/src/components/tab-button/readme.md @@ -8,6 +8,56 @@ See the [tabs documentation](../tabs) for more details on configuring tabs. +## Usage + +### Javascript + +```html + + + + + + Schedule + + + + + Speakers + + + + + Map + + + + + About + + + + + + + + + + + + + + + + + + + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/tabs/readme.md b/core/src/components/tabs/readme.md index 32298cd8f2..de0eecdb1b 100644 --- a/core/src/components/tabs/readme.md +++ b/core/src/components/tabs/readme.md @@ -87,6 +87,105 @@ Using tabs with Angular's router is fairly straight forward. The only additional +## Usage + +### Angular + +```html + + + + + + + + + + + + + + + + + + + + + + Schedule + 6 + + + + + Speakers + + + + + Map + + + + + About + + + + +``` + + +### Javascript + +```html + + + + + + + + + + + + + + + + + + + + + + Schedule + 6 + + + + + Speakers + + + + + Map + + + + + About + + + + +``` + + + ## Events | Event | Description | Detail | diff --git a/core/src/components/text/readme.md b/core/src/components/text/readme.md index d721cdfaff..028cf9c548 100644 --- a/core/src/components/text/readme.md +++ b/core/src/components/text/readme.md @@ -6,6 +6,42 @@ The text component is a simple component that can be used to style the text colo +## Usage + +### Javascript + +```html + +

H1: The quick brown fox jumps over the lazy dog

+
+ + +

H2: The quick brown fox jumps over the lazy dog

+
+ + +

H3: The quick brown fox jumps over the lazy dog

+
+ + +

H4: The quick brown fox jumps over the lazy dog

+
+ + +
H5: The quick brown fox jumps over the lazy dog
+
+ +

+ I saw a werewolf with a Chinese menu in his hand. + Walking through the streets of Soho in the rain. + He was looking for a place called Lee Ho Fook's. + Gonna get a big dish of beef chow mein. + +

+``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/textarea/readme.md b/core/src/components/textarea/readme.md index bab7a26f47..3659375621 100644 --- a/core/src/components/textarea/readme.md +++ b/core/src/components/textarea/readme.md @@ -11,6 +11,91 @@ The textarea component accepts the [native textarea attributes](https://develope +## Usage + +### Angular + +```html + + + + + + + + + + + Description + + + + + + Summary + + + + + + + Comment + + + + + + Notes + + +``` + + +### Javascript + +```html + + + + + + + + + + + Description + + + + + + Summary + + + + + + + Comment + + + + + + Notes + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/thumbnail/readme.md b/core/src/components/thumbnail/readme.md index c170499bbe..b44e868e59 100644 --- a/core/src/components/thumbnail/readme.md +++ b/core/src/components/thumbnail/readme.md @@ -8,6 +8,25 @@ Thumbnails can be used by themselves or inside of any element. If placed inside +## Usage + +### Javascript + +```html + + + + + + + + + Item Thumbnail + +``` + + + ## CSS Custom Properties | Name | Description | diff --git a/core/src/components/title/readme.md b/core/src/components/title/readme.md index 34c9821810..dd554b1e84 100644 --- a/core/src/components/title/readme.md +++ b/core/src/components/title/readme.md @@ -7,6 +7,22 @@ +## Usage + +### Javascript + +```html + + + + Settings + + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/toast/readme.md b/core/src/components/toast/readme.md index 6201a9de9f..9938acc328 100644 --- a/core/src/components/toast/readme.md +++ b/core/src/components/toast/readme.md @@ -18,6 +18,75 @@ The toast can be dismissed automatically after a specific amount of time by pass +## Usage + +### Angular + +```typescript +import { Component } from '@angular/core'; +import { ToastController } from '@ionic/angular'; + +@Component({ + selector: 'toast-example', + templateUrl: 'toast-example.html', + styleUrls: ['./toast-example.css'], +}) +export class ToastExample { + + constructor(public toastController: ToastController) {} + + async presentToast() { + const toast = await this.toastController.create({ + message: 'Your settings have been saved.', + duration: 2000 + }); + toast.present(); + } + + async presentToastWithOptions() { + const toast = await this.toastController.create({ + message: 'Click to Close', + showCloseButton: true, + position: 'top', + closeButtonText: 'Done' + }); + toast.present(); + } + +} +``` + + +### Javascript + +```javascript +async function presentToast() { + const toastController = document.querySelector('ion-toast-controller'); + await toastController.componentOnReady(); + + const toast = await toastController.create({ + message: 'Your settings have been saved.', + duration: 2000 + }); + return await toast.present(); +} + +async function presentToastWithOptions() { + const toastController = document.querySelector('ion-toast-controller'); + await toastController.componentOnReady(); + + const toast = await toastController.create({ + message: 'Click to Close', + showCloseButton: true, + position: 'top', + closeButtonText: 'Done' + }); + return await toast.present(); +} +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/toggle/readme.md b/core/src/components/toggle/readme.md index 3f5466d5ce..c21a20aff9 100644 --- a/core/src/components/toggle/readme.md +++ b/core/src/components/toggle/readme.md @@ -7,6 +7,87 @@ Toggles change the state of a single option. Toggles can be switched on or off b +## Usage + +### Angular + +```html + + + + + + + + + + + + + + + + + + + + Pepperoni + + + + + Sausage + + + + + Mushrooms + + + +``` + + +### Javascript + +```html + + + + + + + + + + + + + + + + + + + + Pepperoni + + + + + Sausage + + + + + Mushrooms + + + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/toolbar/readme.md b/core/src/components/toolbar/readme.md index 6c1594e61b..1f9f75c8c2 100644 --- a/core/src/components/toolbar/readme.md +++ b/core/src/components/toolbar/readme.md @@ -24,6 +24,325 @@ In `md` mode, the `` will receive a box-shadow on the bottom, and th +## Usage + +### Angular + +```html + + Title Only + + + + + + + Back Button + + + + + + + + + + + + + + + + + Default Buttons + + + + + + + Contact + + + Solid Buttons + + + Help + + + + + + + + + + Star + + + Outline Buttons + + + Edit + + + + + + + + + Account + + + + + Edit + + + Text Only Buttons + + + + + + + + + + + + + Left side menu toggle + + + + + + + + + Right side menu toggle + + + + + + + + + + + + + + + + + + + All + + + Favorites + + + + + + + + + + + + + + + + + + + Secondary Toolbar + + + + + + + + + + + + + + + + + Dark Toolbar + +``` + + +### Javascript + +```html + + Title Only + + + + + + + Back Button + + + + + + + + + + + + + + + + + Default Buttons + + + + + + + Contact + + + Solid Buttons + + + Help + + + + + + + + + + Star + + + Outline Buttons + + + Edit + + + + + + + + + Account + + + + + Edit + + + Text Only Buttons + + + + + + + + + + + + Left side menu toggle + + + + + + + + + Right side menu toggle + + + + + + + + + + + + + + + + + + All + + + Favorites + + + + + + + + + + + + + + + + + + + Secondary Toolbar + + + + + + + + + + + + + + + + + Dark Toolbar + +``` + + + ## Properties | Property | Attribute | Description | Type | Default | diff --git a/core/src/components/virtual-scroll/readme.md b/core/src/components/virtual-scroll/readme.md index 0b15cfd298..de12ee25dd 100644 --- a/core/src/components/virtual-scroll/readme.md +++ b/core/src/components/virtual-scroll/readme.md @@ -181,6 +181,77 @@ dataset, so please make sure they're performant. +## Usage + +### Angular + +```html + + + +
+ +
+ + {{ item.name }} + + {{ item.content }} +
+
+
+``` + +```typescript +export class VirtualScrollPageComponent { + items: any[] = []; + + constructor() { + for (let i = 0; i < 1000; i++) { + this.items.push({ + name: i + ' - ' + images[rotateImg], + imgSrc: getImgSrc(), + avatarSrc: getImgSrc(), + imgHeight: Math.floor(Math.random() * 50 + 150), + content: lorem.substring(0, Math.random() * (lorem.length - 100) + 100) + }); + + rotateImg++; + if (rotateImg === images.length) { + rotateImg = 0; + } + } + } +} + +const lorem = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, seddo eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'; + +const images = [ + 'bandit', + 'batmobile', + 'blues-brothers', + 'bueller', + 'delorean', + 'eleanor', + 'general-lee', + 'ghostbusters', + 'knight-rider', + 'mirth-mobile' +]; + +function getImgSrc() { + const src = 'https://dummyimage.com/600x400/${Math.round( Math.random() * 99999)}/fff.png'; + rotateImg++; + if (rotateImg === images.length) { + rotateImg = 0; + } + return src; +} + +let rotateImg = 0; +``` + + + ## Properties | Property | Attribute | Description | Type | Default |