mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
feat(loading): add loading indicator component and styles
this is the initial commit - still needs work references #5426
This commit is contained in:
4
ionic/components/loading/test/basic/e2e.ts
Normal file
4
ionic/components/loading/test/basic/e2e.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
it('should open default spinner', function() {
|
||||
element(by.css('.e2eLoadingDefaultSpinner')).click();
|
||||
});
|
||||
115
ionic/components/loading/test/basic/index.ts
Normal file
115
ionic/components/loading/test/basic/index.ts
Normal file
@@ -0,0 +1,115 @@
|
||||
import {App, Page, ActionSheet, Loading, NavController, ViewController, Platform} from 'ionic-angular';
|
||||
|
||||
|
||||
@Page({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class E2EPage {
|
||||
constructor(private nav: NavController, private platform: Platform) {}
|
||||
|
||||
showLoadingIos() {
|
||||
let loading = Loading.create({
|
||||
icon: 'ios',
|
||||
enableBackdropDismiss: true
|
||||
});
|
||||
|
||||
this.nav.present(loading);
|
||||
}
|
||||
|
||||
showLoadingDots() {
|
||||
let loading = Loading.create({
|
||||
icon: 'dots',
|
||||
content: 'Loading...',
|
||||
enableBackdropDismiss: true
|
||||
});
|
||||
|
||||
this.nav.present(loading);
|
||||
}
|
||||
|
||||
showLoadingBubbles() {
|
||||
let loading = Loading.create({
|
||||
icon: 'bubbles',
|
||||
content: 'Loading...',
|
||||
enableBackdropDismiss: true
|
||||
});
|
||||
|
||||
this.nav.present(loading);
|
||||
}
|
||||
|
||||
showLoadingCircles() {
|
||||
let loading = Loading.create({
|
||||
icon: 'circles',
|
||||
content: 'Loading...',
|
||||
enableBackdropDismiss: true
|
||||
});
|
||||
|
||||
this.nav.present(loading);
|
||||
}
|
||||
|
||||
showLoadingCrescent() {
|
||||
let loading = Loading.create({
|
||||
icon: 'crescent',
|
||||
content: 'Please wait...',
|
||||
enableBackdropDismiss: true,
|
||||
duration: 1500
|
||||
});
|
||||
|
||||
this.nav.present(loading);
|
||||
}
|
||||
|
||||
showLoadingDefault() {
|
||||
let loading = Loading.create({
|
||||
icon: 'platform',
|
||||
content: 'Please wait...',
|
||||
enableBackdropDismiss: true,
|
||||
});
|
||||
|
||||
this.nav.present(loading);
|
||||
}
|
||||
|
||||
showLoadingCustom() {
|
||||
let loading = Loading.create({
|
||||
content: `
|
||||
<div class="custom-spinner-container">
|
||||
<div class="custom-spinner-box"></div>
|
||||
</div>`,
|
||||
enableBackdropDismiss: true
|
||||
});
|
||||
|
||||
this.nav.present(loading);
|
||||
}
|
||||
|
||||
showLoadingText() {
|
||||
let loading = Loading.create({
|
||||
content: 'Loading Please Wait...',
|
||||
enableBackdropDismiss: true
|
||||
});
|
||||
|
||||
this.nav.present(loading);
|
||||
}
|
||||
|
||||
goToPage2() {
|
||||
this.nav.push(Page2);
|
||||
}
|
||||
}
|
||||
|
||||
@Page({
|
||||
template: `
|
||||
<ion-navbar *navbar>
|
||||
<ion-title>Page 2</ion-title>
|
||||
</ion-navbar>
|
||||
<ion-content padding>Some content</ion-content>
|
||||
`
|
||||
})
|
||||
class Page2 {
|
||||
constructor(private nav: NavController, private platform: Platform) {}
|
||||
}
|
||||
|
||||
@App({
|
||||
template: '<ion-nav [root]="root"></ion-nav>'
|
||||
})
|
||||
class E2EApp {
|
||||
root = E2EPage;
|
||||
}
|
||||
|
||||
document.body.innerHTML += '<link href="styles.css" rel="stylesheet">'
|
||||
24
ionic/components/loading/test/basic/main.html
Normal file
24
ionic/components/loading/test/basic/main.html
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
<ion-navbar *navbar>
|
||||
<ion-title>Loading</ion-title>
|
||||
</ion-navbar>
|
||||
|
||||
<ion-content padding>
|
||||
<button block (click)="showLoadingIos()">iOS Spinner</button>
|
||||
<button block (click)="showLoadingDots()">Dots Spinner</button>
|
||||
<button block (click)="showLoadingBubbles()">Bubbles Spinner</button>
|
||||
<button block (click)="showLoadingCircles()">Circles Spinner</button>
|
||||
<button block (click)="showLoadingCrescent()">Crescent Spinner 1500 Duration</button>
|
||||
<button block (click)="showLoadingDefault()" secondary class="e2eLoadingDefaultSpinner">Default Spinner</button>
|
||||
<button block (click)="showLoadingCustom()" danger>Custom Spinner</button>
|
||||
<button block (click)="showLoadingText()" dark>Content Only</button>
|
||||
</ion-content>
|
||||
|
||||
<ion-toolbar position="bottom">
|
||||
<ion-buttons end>
|
||||
<button (click)="goToPage2()">
|
||||
Navigate
|
||||
<ion-icon name="arrow-forward"></ion-icon>
|
||||
</button>
|
||||
</ion-buttons>
|
||||
</ion-toolbar>
|
||||
56
ionic/components/loading/test/basic/styles.css
Normal file
56
ionic/components/loading/test/basic/styles.css
Normal file
@@ -0,0 +1,56 @@
|
||||
.custom-spinner-container {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.custom-spinner-box {
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
border: 4px solid #000;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
animation: spin 3s infinite linear;
|
||||
}
|
||||
|
||||
.custom-spinner-box:before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
box-sizing: border-box;
|
||||
border: 4px solid #000;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
animation: pulse 1.5s infinite ease;
|
||||
}
|
||||
|
||||
.wp .custom-spinner-box,
|
||||
.wp .custom-spinner-box:before {
|
||||
border-color: #fff;
|
||||
}
|
||||
|
||||
@-webkit-keyframes pulse {
|
||||
50% {
|
||||
border-width: 20px;
|
||||
}
|
||||
}
|
||||
@keyframes pulse {
|
||||
50% {
|
||||
border-width: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes spin {
|
||||
100% {
|
||||
-webkit-transform: rotate(360deg);
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
@keyframes spin {
|
||||
100% {
|
||||
-webkit-transform: rotate(360deg);
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user