Skip to content

Commit b0d71da

Browse files
committed
feat(popover): change popover item background color to match wrapper
updated e2e test and added a test to open the popover references #5420
1 parent 1373108 commit b0d71da

File tree

7 files changed

+287
-20
lines changed

7 files changed

+287
-20
lines changed

src/components/popover/popover.ios.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ $popover-ios-border-radius: 10px !default;
1111
$popover-ios-text-color: #000 !default;
1212

1313
$popover-ios-background: #f3f3f3 !default;
14+
$popover-ios-item-background: $popover-ios-background !default;
1415
$popover-ios-arrow-background: $popover-ios-background !default;
1516

1617

@@ -25,6 +26,10 @@ $popover-ios-arrow-background: $popover-ios-background !default;
2526
background: $popover-ios-background;
2627
}
2728

29+
.popover-wrapper .item {
30+
background-color: $popover-ios-item-background;
31+
}
32+
2833

2934
// Popover Arrow
3035
// -----------------------------------------

src/components/popover/popover.md.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
// Material Design Popover
55
// --------------------------------------------------
66

7-
$popover-md-min-width: 150px !default;
7+
$popover-md-min-width: 200px !default;
88
$popover-md-max-width: 270px !default;
99
$popover-md-max-height: 90% !default;
1010
$popover-md-border-radius: 2px !default;
1111
$popover-md-text-color: #000 !default;
12+
1213
$popover-md-background: #fafafa !default;
14+
$popover-md-item-background: $popover-md-background !default;
1315

1416

1517
.popover-wrapper {
@@ -22,3 +24,7 @@ $popover-md-background: #fafafa !default;
2224
color: $popover-md-text-color;
2325
background: $popover-md-background;
2426
}
27+
28+
.popover-wrapper .item {
29+
background-color: $popover-md-item-background;
30+
}

src/components/popover/popover.wp.scss

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
// Windows Popover
55
// --------------------------------------------------
66

7-
$popover-wp-min-width: 150px !default;
7+
$popover-wp-min-width: 200px !default;
88
$popover-wp-max-width: 270px !default;
99
$popover-wp-max-height: 90% !default;
1010
$popover-wp-border-radius: 2px !default;
1111
$popover-wp-text-color: #000 !default;
12-
$popover-wp-background: #fff !default;
12+
13+
$popover-wp-background: #e6e6e6 !default;
14+
$popover-wp-item-background: $popover-wp-background !default;
1315

1416

1517
.popover-wrapper {
@@ -22,3 +24,7 @@ $popover-wp-background: #fff !default;
2224
color: $popover-wp-text-color;
2325
background: $popover-wp-background;
2426
}
27+
28+
.popover-wrapper .item {
29+
background-color: $popover-wp-item-background;
30+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
it('should open list popover', function() {
3+
element(by.css('.e2eOpenListPopover')).click();
4+
});

src/components/popover/test/basic/index.ts

Lines changed: 131 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,113 @@
1-
import {App, Page, Popover, NavController} from '../../../../../src';
1+
import {ViewChild, ElementRef} from '@angular/core';
2+
import {App, Page, Popover, NavController, Content, NavParams} from '../../../../../src';
3+
4+
5+
@Page({
6+
template: `
7+
<ion-list radio-group [(ngModel)]="fontFamily" (change)="changeFontFamily()">
8+
<ion-row>
9+
<ion-col>
10+
<button (click)="changeFontSize('smaller')" ion-item detail-none class="text-button text-smaller">A</button>
11+
</ion-col>
12+
<ion-col>
13+
<button (click)="changeFontSize('larger')" ion-item detail-none class="text-button text-larger">A</button>
14+
</ion-col>
15+
</ion-row>
16+
<ion-row class="row-dots">
17+
<ion-col>
18+
<button (click)="changeBackground('white')" category="dot" class="dot-white" [class.selected]="background == 'white'"></button>
19+
</ion-col>
20+
<ion-col>
21+
<button (click)="changeBackground('tan')" category="dot" class="dot-tan" [class.selected]="background == 'tan'"></button>
22+
</ion-col>
23+
<ion-col>
24+
<button (click)="changeBackground('grey')" category="dot" class="dot-grey" [class.selected]="background == 'grey'"></button>
25+
</ion-col>
26+
<ion-col>
27+
<button (click)="changeBackground('black')" category="dot" class="dot-black" [class.selected]="background == 'black'"></button>
28+
</ion-col>
29+
</ion-row>
30+
<ion-item class="text-athelas">
31+
<ion-label>Athelas</ion-label>
32+
<ion-radio value="Athelas"></ion-radio>
33+
</ion-item>
34+
<ion-item class="text-charter">
35+
<ion-label>Charter</ion-label>
36+
<ion-radio value="Charter"></ion-radio>
37+
</ion-item>
38+
<ion-item class="text-iowan">
39+
<ion-label>Iowan</ion-label>
40+
<ion-radio value="Iowan"></ion-radio>
41+
</ion-item>
42+
<ion-item class="text-palatino">
43+
<ion-label>Palatino</ion-label>
44+
<ion-radio value="Palatino"></ion-radio>
45+
</ion-item>
46+
<ion-item class="text-san-francisco">
47+
<ion-label>San Francisco</ion-label>
48+
<ion-radio value="San Francisco"></ion-radio>
49+
</ion-item>
50+
<ion-item class="text-seravek">
51+
<ion-label>Seravek</ion-label>
52+
<ion-radio value="Seravek"></ion-radio>
53+
</ion-item>
54+
<ion-item class="text-times-new-roman">
55+
<ion-label>Times New Roman</ion-label>
56+
<ion-radio value="Times New Roman"></ion-radio>
57+
</ion-item>
58+
</ion-list>
59+
`,
60+
})
61+
class PopoverRadioPage {
62+
background: string = 'white';
63+
contentEle: any;
64+
textEle: any;
65+
fontFamily;
66+
67+
colors = {
68+
"white": {
69+
"bg": "#fff",
70+
"fg": "#000"
71+
},
72+
"tan": {
73+
"bg": "#f9f1e4",
74+
"fg": "#000"
75+
},
76+
"grey": {
77+
"bg": "#4c4b50",
78+
"fg": "#fff"
79+
},
80+
"black": {
81+
"bg": "#000",
82+
"fg": "#fff"
83+
},
84+
};
85+
86+
constructor(private navParams: NavParams) {
87+
88+
}
89+
90+
ngOnInit() {
91+
if (this.navParams.data) {
92+
this.contentEle = this.navParams.data.contentEle;
93+
this.textEle = this.navParams.data.textEle;
94+
}
95+
}
96+
97+
changeBackground(color) {
98+
this.background = color;
99+
this.contentEle.style.background = this.colors[color].bg;
100+
this.textEle.style.color = this.colors[color].fg;
101+
}
102+
103+
changeFontSize(direction) {
104+
this.textEle.style.fontSize = direction;
105+
}
106+
107+
changeFontFamily() {
108+
if (this.fontFamily) this.textEle.style.fontFamily = this.fontFamily;
109+
}
110+
}
2111

3112

4113
@Page({
@@ -9,11 +118,10 @@ import {App, Page, Popover, NavController} from '../../../../../src';
9118
<button ion-item>Documentation</button>
10119
<button ion-item>Showcase</button>
11120
<button ion-item>GitHub Repo</button>
12-
13121
</ion-list>
14122
`
15123
})
16-
class PopoverPage {
124+
class PopoverListPage {
17125

18126
}
19127

@@ -22,17 +130,29 @@ class PopoverPage {
22130
templateUrl: 'main.html'
23131
})
24132
class E2EPage {
133+
@ViewChild('popoverContent', {read: ElementRef}) content: ElementRef;
134+
@ViewChild('popoverText', {read: ElementRef}) text: ElementRef;
135+
25136
popover: any;
26137

27-
constructor(private nav: NavController) {}
138+
constructor(private nav: NavController) {
28139

29-
createPopover() {
30-
this.popover = Popover.create(PopoverPage);
31140
}
32141

33-
presentPopover(ev) {
34-
this.createPopover();
35-
this.nav.present(this.popover, {
142+
presentListPopover(ev) {
143+
let popover = Popover.create(PopoverListPage);
144+
this.nav.present(popover, {
145+
ev: ev
146+
});
147+
}
148+
149+
presentRadioPopover(ev) {
150+
let popover = Popover.create(PopoverRadioPage, {
151+
contentEle: this.content.nativeElement,
152+
textEle: this.text.nativeElement
153+
});
154+
155+
this.nav.present(popover, {
36156
ev: ev
37157
});
38158
}
@@ -49,3 +169,5 @@ class E2EApp {
49169
this.root = E2EPage;
50170
}
51171
}
172+
173+
document.body.innerHTML += '<link href="style.css" rel="stylesheet">'

src/components/popover/test/basic/main.html

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,46 @@
11
<ion-navbar *navbar primary>
22
<ion-buttons left>
3-
<button (click)="presentPopover($event)">
3+
<button (click)="presentRadioPopover($event)">
44
<ion-icon name="person"></ion-icon>
55
</button>
6-
<button (click)="presentPopover($event)">
6+
<button (click)="presentListPopover($event)">
77
<ion-icon name="search"></ion-icon>
88
</button>
99
</ion-buttons>
1010
<ion-title>Popover</ion-title>
1111
<ion-buttons end>
12-
<button (click)="presentPopover($event)">
12+
<button (click)="presentListPopover($event)">
1313
<ion-icon name="options"></ion-icon>
1414
</button>
15-
<button (click)="presentPopover($event)">
15+
<button (click)="presentRadioPopover($event)">
1616
<ion-icon name="more"></ion-icon>
1717
</button>
1818
</ion-buttons>
1919
</ion-navbar>
2020

21-
<ion-content padding>
21+
<ion-content #popoverContent padding>
2222

23-
<button block (click)="presentPopover($event)">
24-
Present Popover
23+
<button block (click)="presentListPopover($event)" class="e2eOpenListPopover">
24+
Present List Popover
2525
</button>
2626

27+
<div #popoverText class="text-to-change">
28+
<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>
29+
30+
<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>
31+
32+
<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>
33+
34+
<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>
35+
36+
<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>
37+
</div>
2738
</ion-content>
2839

2940
<ion-toolbar position="bottom">
3041
<ion-title>Popover</ion-title>
3142
<ion-buttons start>
32-
<button (click)="presentPopover($event)">
43+
<button (click)="presentListPopover($event)">
3344
<ion-icon name="more"></ion-icon>
3445
</button>
3546
</ion-buttons>

0 commit comments

Comments
 (0)