-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(demos): add popover API demo, tweak e2e demo
references #5420
- Loading branch information
1 parent
b0d71da
commit 04a59d2
Showing
6 changed files
with
356 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
import {ViewChild, ElementRef} from '@angular/core'; | ||
import {App, Page, Popover, NavController, Content, NavParams} from 'ionic-angular'; | ||
|
||
|
||
@Page({ | ||
template: ` | ||
<ion-list radio-group [(ngModel)]="fontFamily" (change)="changeFontFamily()"> | ||
<ion-row> | ||
<ion-col> | ||
<button (click)="changeFontSize('smaller')" ion-item detail-none class="text-button text-smaller">A</button> | ||
</ion-col> | ||
<ion-col> | ||
<button (click)="changeFontSize('larger')" ion-item detail-none class="text-button text-larger">A</button> | ||
</ion-col> | ||
</ion-row> | ||
<ion-row class="row-dots"> | ||
<ion-col> | ||
<button (click)="changeBackground('white')" category="dot" class="dot-white" [class.selected]="background == 'white'"></button> | ||
</ion-col> | ||
<ion-col> | ||
<button (click)="changeBackground('tan')" category="dot" class="dot-tan" [class.selected]="background == 'tan'"></button> | ||
</ion-col> | ||
<ion-col> | ||
<button (click)="changeBackground('grey')" category="dot" class="dot-grey" [class.selected]="background == 'grey'"></button> | ||
</ion-col> | ||
<ion-col> | ||
<button (click)="changeBackground('black')" category="dot" class="dot-black" [class.selected]="background == 'black'"></button> | ||
</ion-col> | ||
</ion-row> | ||
<ion-item class="text-athelas"> | ||
<ion-label>Athelas</ion-label> | ||
<ion-radio value="Athelas"></ion-radio> | ||
</ion-item> | ||
<ion-item class="text-charter"> | ||
<ion-label>Charter</ion-label> | ||
<ion-radio value="Charter"></ion-radio> | ||
</ion-item> | ||
<ion-item class="text-iowan"> | ||
<ion-label>Iowan</ion-label> | ||
<ion-radio value="Iowan"></ion-radio> | ||
</ion-item> | ||
<ion-item class="text-palatino"> | ||
<ion-label>Palatino</ion-label> | ||
<ion-radio value="Palatino"></ion-radio> | ||
</ion-item> | ||
<ion-item class="text-san-francisco"> | ||
<ion-label>San Francisco</ion-label> | ||
<ion-radio value="San Francisco"></ion-radio> | ||
</ion-item> | ||
<ion-item class="text-seravek"> | ||
<ion-label>Seravek</ion-label> | ||
<ion-radio value="Seravek"></ion-radio> | ||
</ion-item> | ||
<ion-item class="text-times-new-roman"> | ||
<ion-label>Times New Roman</ion-label> | ||
<ion-radio value="Times New Roman"></ion-radio> | ||
</ion-item> | ||
</ion-list> | ||
`, | ||
}) | ||
class PopoverRadioPage { | ||
background: string; | ||
contentEle: any; | ||
textEle: any; | ||
fontFamily; | ||
|
||
colors = { | ||
'white': { | ||
'bg': 'rgb(255, 255, 255)', | ||
'fg': 'rgb(0, 0, 0)' | ||
}, | ||
'tan': { | ||
'bg': 'rgb(249, 241, 228)', | ||
'fg': 'rgb(0, 0, 0)' | ||
}, | ||
'grey': { | ||
'bg': 'rgb(76, 75, 80)', | ||
'fg': 'rgb(255, 255, 255)' | ||
}, | ||
'black': { | ||
'bg': 'rgb(0, 0, 0)', | ||
'fg': 'rgb(255, 255, 255)' | ||
}, | ||
}; | ||
|
||
constructor(private navParams: NavParams) { | ||
|
||
} | ||
|
||
ngOnInit() { | ||
if (this.navParams.data) { | ||
this.contentEle = this.navParams.data.contentEle; | ||
this.textEle = this.navParams.data.textEle; | ||
|
||
this.background = this.getColorName(this.contentEle.style.backgroundColor); | ||
this.setFontFamily(); | ||
} | ||
} | ||
|
||
getColorName(background) { | ||
let colorName = 'white'; | ||
|
||
if (!background) return 'white'; | ||
|
||
for(var key in this.colors) { | ||
if (this.colors[key].bg == background) { | ||
colorName = key; | ||
} | ||
} | ||
|
||
return colorName; | ||
} | ||
|
||
setFontFamily() { | ||
if (this.textEle.style.fontFamily) { | ||
this.fontFamily = this.textEle.style.fontFamily.replace(/'/g, ""); | ||
} | ||
} | ||
|
||
changeBackground(color) { | ||
this.background = color; | ||
this.contentEle.style.backgroundColor = this.colors[color].bg; | ||
this.textEle.style.color = this.colors[color].fg; | ||
} | ||
|
||
changeFontSize(direction) { | ||
this.textEle.style.fontSize = direction; | ||
} | ||
|
||
changeFontFamily() { | ||
if (this.fontFamily) this.textEle.style.fontFamily = this.fontFamily; | ||
} | ||
} | ||
|
||
|
||
@Page({ | ||
templateUrl: 'main.html' | ||
}) | ||
class PopoverPage { | ||
@ViewChild('popoverContent', {read: ElementRef}) content: ElementRef; | ||
@ViewChild('popoverText', {read: ElementRef}) text: ElementRef; | ||
|
||
constructor(private nav: NavController) { | ||
|
||
} | ||
|
||
presentRadioPopover(ev) { | ||
let popover = Popover.create(PopoverRadioPage, { | ||
contentEle: this.content.nativeElement, | ||
textEle: this.text.nativeElement | ||
}); | ||
|
||
this.nav.present(popover, { | ||
ev: ev | ||
}); | ||
} | ||
|
||
} | ||
|
||
|
||
@App({ | ||
template: '<ion-nav [root]="root"></ion-nav>' | ||
}) | ||
class ApiDemoApp { | ||
root = PopoverPage; | ||
} | ||
|
||
document.body.innerHTML += '<link href="style.css" rel="stylesheet">' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<ion-navbar *navbar primary> | ||
<ion-title>Popover</ion-title> | ||
<ion-buttons end> | ||
<button (click)="presentRadioPopover($event)"> | ||
<ion-icon name="more"></ion-icon> | ||
</button> | ||
</ion-buttons> | ||
</ion-navbar> | ||
|
||
<ion-content #popoverContent padding> | ||
<div #popoverText class="text-to-change"> | ||
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris vel ipsum in purus mollis dictum eget vitae purus. Nulla ultrices est odio, a maximus velit pretium ac. Donec vel elementum mi. Proin elementum pulvinar neque, in lacinia nibh tempus auctor. Nam sapien velit, commodo ac nibh a, maximus ullamcorper nunc. Integer luctus tortor dignissim, dictum neque at, scelerisque purus. Vivamus nec erat vel magna posuere euismod. Sed ac augue eu tellus tincidunt fermentum eget sit amet nunc. Donec sit amet mi libero. Cras nunc arcu, ultrices nec sapien eu, convallis posuere libero. Pellentesque vulputate lacus eros, at lobortis lorem egestas et. Vestibulum tempus quam in efficitur lobortis. Maecenas consectetur consequat sem pharetra aliquet. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.</div> | ||
|
||
<div>Mauris ac ligula elit. Nulla pulvinar eget leo ut aliquet. Praesent sit amet luctus quam. Nam fringilla iaculis mi, ut maximus mauris molestie feugiat. Curabitur nec scelerisque elit. Nunc eu odio facilisis, tempor enim eget, venenatis sem. Sed vitae lorem vehicula, auctor orci ultrices, finibus mauris. Donec vitae pulvinar diam. Nulla luctus congue quam, sed lacinia arcu dictum a.</div> | ||
|
||
<div>Morbi laoreet magna elit, id dapibus massa varius consequat. Praesent rhoncus nunc quam, eu mollis velit commodo ut. Etiam euismod elit mi, non auctor velit blandit ut. Aenean vitae pulvinar mi, ac pretium tellus. Morbi eu auctor sem, sollicitudin cursus felis. Praesent vestibulum velit sed eros iaculis ornare. Praesent diam diam, pellentesque eget scelerisque sed, bibendum ut risus. Sed sed fermentum sem. Integer vel justo felis. Proin eget quam est. In sit amet ipsum sagittis, convallis ipsum fringilla, interdum ante. Etiam vel tincidunt mauris. Nunc feugiat eros nunc, et vestibulum metus mollis et. Nullam eu viverra velit, id ultrices nisl. Donec non enim elementum, laoreet sapien id, feugiat tellus.</div> | ||
|
||
<div>Sed pellentesque ipsum eget ante hendrerit maximus. Aliquam id venenatis nulla. Nullam in nibh at enim vestibulum ullamcorper. Nam felis dolor, lobortis vel est non, condimentum malesuada nisl. In metus sapien, malesuada at nulla in, pretium aliquam turpis. Quisque elementum purus mi, sed tristique turpis ultricies in. Donec feugiat dolor non ultricies ultricies. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Proin ut purus et diam porta cursus vitae semper mi. Donec fringilla tellus orci. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nunc vitae commodo sem. Duis vehicula quam sit amet imperdiet facilisis. Pellentesque eget dignissim neque, et scelerisque libero. Maecenas molestie metus sed orci cursus, in venenatis justo dapibus.</div> | ||
|
||
<p>Aenean rhoncus urna at interdum blandit. Donec ac massa nec libero vehicula tincidunt. Sed sit amet hendrerit risus. Aliquam vitae vestibulum ipsum, non feugiat orci. Vivamus eu rutrum elit. Nulla dapibus tortor non dignissim pretium. Nulla in luctus turpis. Etiam non mattis tortor, at aliquet ex. Nunc ut ante varius, auctor dui vel, volutpat elit. Nunc laoreet augue sit amet ultrices porta. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vestibulum pellentesque lobortis est, ut tincidunt ligula mollis sit amet. In porta risus arcu, quis pellentesque dolor mattis non. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;</p> | ||
</div> | ||
</ion-content> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
.text-to-change div { | ||
margin: 10px auto; | ||
} | ||
|
||
ion-row, | ||
ion-col { | ||
padding: 0; | ||
} | ||
|
||
.text-button { | ||
padding-left: 0; | ||
text-align: center; | ||
min-height: 20px; | ||
line-height: 18px; | ||
} | ||
|
||
.text-button .item-inner { | ||
padding-right: 0; | ||
} | ||
|
||
.text-smaller { | ||
font-size: 12px; | ||
} | ||
|
||
.ios .text-smaller { | ||
border-right: 1px solid #c8c7cc; | ||
} | ||
|
||
.md .text-smaller { | ||
border-right: 1px solid #dedede; | ||
} | ||
|
||
.text-larger { | ||
font-size: 16px; | ||
} | ||
|
||
.row-dots { | ||
text-align: center; | ||
} | ||
|
||
.ios .row-dots { | ||
border-bottom: 1px solid #c8c7cc; | ||
} | ||
|
||
.md .row-dots { | ||
border-bottom: 1px solid #dedede; | ||
} | ||
|
||
.ios .dot { | ||
border: 1px solid #c8c7cc; | ||
} | ||
|
||
.md .dot { | ||
border: 1px solid #dedede; | ||
} | ||
|
||
.hairlines .text-smaller, | ||
.hairlines .row-dots, | ||
.hairlines .dot { | ||
border-width: 0.55px; | ||
} | ||
|
||
.row-dots .dot { | ||
height: 30px; | ||
width: 30px; | ||
border-radius: 50%; | ||
margin: 10px auto; | ||
} | ||
|
||
.dot-white { | ||
background-color: #fff; | ||
} | ||
|
||
.dot-tan { | ||
background-color: #f9f1e4; | ||
} | ||
|
||
.dot-grey { | ||
background-color: #4c4b50; | ||
} | ||
|
||
.dot-black { | ||
background-color: #000; | ||
} | ||
|
||
.dot.selected { | ||
border-width: 2px; | ||
border-color: #327eff; | ||
} | ||
|
||
.text-athelas { | ||
font-family: "Athelas"; | ||
} | ||
|
||
.text-charter { | ||
font-family: "Charter"; | ||
} | ||
|
||
.text-iowan { | ||
font-family: "Iowan"; | ||
} | ||
|
||
.text-palatino { | ||
font-family: "Palatino"; | ||
} | ||
|
||
.text-san-francisco { | ||
font-family: "San Francisco"; | ||
} | ||
|
||
.text-seravek { | ||
font-family: "Seravek"; | ||
} | ||
|
||
.text-times-new-roman { | ||
font-family: "Times New Roman"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.