Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for className in popups (#111) #161

Merged
merged 1 commit into from
Jul 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion projects/ngx-mapbox-gl/src/lib/popup/popup.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class PopupComponent implements OnChanges, OnDestroy, AfterViewInit, OnIn
@Input() closeOnClick?: boolean;
@Input() anchor?: 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left';
@Input() offset?: number | PointLike | { [anchor: string]: [number, number] };
@Input() className?: string;

/* Dynamic input */
@Input() feature?: GeoJSON.Feature<GeoJSON.Point>;
Expand Down Expand Up @@ -94,7 +95,8 @@ export class PopupComponent implements OnChanges, OnDestroy, AfterViewInit, OnIn
closeButton: this.closeButton,
closeOnClick: this.closeOnClick,
anchor: this.anchor,
offset: this.offset
offset: this.offset,
className: this.className
},
popupEvents: {
open: this.open,
Expand Down
6 changes: 6 additions & 0 deletions projects/showcase-e2e/src/popup.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ describe('Popup', () => {
await browser.get('/demo/popup');
const canvas = element(by.tagName('canvas'));
await browser.wait(EC.presenceOf(canvas), 2000);

const popup = element(by.className('mapboxgl-popup'));
await browser.wait(EC.presenceOf(popup), 1000);
expect(popup).toHaveClass('custom-popup-class1');
expect(popup).toHaveClass('custom-popup-class2');

const popupContent = element(by.className('mapboxgl-popup-content'));
await browser.wait(EC.presenceOf(popupContent), 1000);
expect(popupContent.element(by.tagName('div')).getText()).toBe('Hello world !');
Expand Down
8 changes: 8 additions & 0 deletions projects/showcase/src/app/demo/examples/popup.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
::ng-deep .custom-popup-class1 {
color: purple;
text-align:center;
}

::ng-deep .custom-popup-class2 {
width: 300px;
}
3 changes: 2 additions & 1 deletion projects/showcase/src/app/demo/examples/popup.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import { Component } from '@angular/core';
<mgl-popup
[lngLat]="[-96, 37.8]"
[closeOnClick]="false"
[className]="'custom-popup-class1 custom-popup-class2'"
>
<h1>Hello world !</h1>
</mgl-popup>
</mgl-map>
`,
styleUrls: ['./examples.css']
styleUrls: ['./examples.css', './popup.component.css']
})
export class PopupComponent { }