Skip to content

Commit

Permalink
Rename ballon to popup
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew44-mappable committed May 8, 2024
1 parent 4464bb9 commit df1d06a
Show file tree
Hide file tree
Showing 18 changed files with 352 additions and 362 deletions.
4 changes: 2 additions & 2 deletions example/default-popups/react/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async function main() {

const {useState, useCallback} = React;

const {MMapBalloonMarker, MMapDefaultPopupMarker} = reactify.module(
const {MMapPopupMarker, MMapDefaultPopupMarker} = reactify.module(
await mappable.import('@mappable-world/mappable-default-ui-theme')
);

Expand Down Expand Up @@ -53,7 +53,7 @@ async function main() {
<MMapControlButton text="Toggle default popup" onClick={toggleDefaultPopup} />
</MMapControls>

<MMapBalloonMarker show={showCustomPopup} coordinates={CUSTOM_POPUP_COORDS} content={contentCallback} />
<MMapPopupMarker show={showCustomPopup} coordinates={CUSTOM_POPUP_COORDS} content={contentCallback} />

<MMapDefaultPopupMarker
show={showDefaultPopup}
Expand Down
4 changes: 2 additions & 2 deletions example/default-popups/vanilla/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ async function main() {
await mappable.ready;
const {MMap, MMapDefaultSchemeLayer, MMapDefaultFeaturesLayer, MMapControls, MMapControlButton} = mappable;

const {MMapBalloonMarker, MMapDefaultPopupMarker} = await mappable.import(
const {MMapPopupMarker, MMapDefaultPopupMarker} = await mappable.import(
'@mappable-world/mappable-default-ui-theme'
);

Expand All @@ -28,7 +28,7 @@ async function main() {
])
);

const customPopup = new MMapBalloonMarker({
const customPopup = new MMapPopupMarker({
coordinates: CUSTOM_POPUP_COORDS,
content: () => {
const popupElement = document.createElement('div');
Expand Down
8 changes: 4 additions & 4 deletions example/default-popups/vue/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ async function main() {
const {MMap, MMapDefaultSchemeLayer, MMapDefaultFeaturesLayer, MMapControls, MMapControlButton} =
vuefy.module(mappable);

const {MMapBalloonMarker, MMapDefaultPopupMarker} = vuefy.module(
const {MMapPopupMarker, MMapDefaultPopupMarker} = vuefy.module(
await mappable.import('@mappable-world/mappable-default-ui-theme')
);

Expand All @@ -21,7 +21,7 @@ async function main() {
MMapDefaultFeaturesLayer,
MMapControls,
MMapControlButton,
MMapBalloonMarker,
MMapPopupMarker,
MMapDefaultPopupMarker
},
setup() {
Expand Down Expand Up @@ -60,15 +60,15 @@ async function main() {
<MMapControlButton text="Toggle custom popup" :onClick="toggleCustomPopup" />
<MMapControlButton text="Toggle default popup" :onClick="toggleDefaultPopup" />
</MMapControls>
<MMapBalloonMarker :show="showCustomPopup" :coordinates="CUSTOM_POPUP_COORDS">
<MMapPopupMarker :show="showCustomPopup" :coordinates="CUSTOM_POPUP_COORDS">
<template #content>
<div class="custom-popup">
<div class="title">Title</div>
<button :onClick="onCloseCustomPopup">close</button>
<div class="content">Custom popup content</div>
</div>
</template>
</MMapBalloonMarker>
</MMapPopupMarker>
<MMapDefaultPopupMarker
:show="showDefaultPopup"
:coordinates="DEFAULT_POPUP_COORDS"
Expand Down
165 changes: 0 additions & 165 deletions src/markers/MMapBalloonMarker/MMapBalloonMarker.test.ts

This file was deleted.

43 changes: 0 additions & 43 deletions src/markers/MMapBalloonMarker/react/index.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {MMap} from '@mappable-world/mappable-types';
import {createContainer, CENTER} from '../../../tests/common';
import {CENTER, createContainer} from '../../../tests/common';
import {MMapDefaultPopupMarker} from './';

describe('MMapDefaultPopupMarker', () => {
Expand Down Expand Up @@ -88,4 +88,4 @@ describe('MMapDefaultPopupMarker', () => {
});
});

const BASE_SELECTOR = '.mappable--balloon-marker .mappable--default-popup';
const BASE_SELECTOR = '.mappable--popup-marker .mappable--default-popup';
22 changes: 11 additions & 11 deletions src/markers/MMapDefaultPopupMarker/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {MMapBalloonContentProps, MMapBalloonMarker, MMapBalloonMarkerProps} from '../MMapBalloonMarker';
import {MMapPopupContentProps, MMapPopupMarker, MMapPopupMarkerProps} from '../MMapPopupMarker';
import {MMapDefaultPopupMarkerVuefyOptions} from './vue';

import closeSVG from './close.svg';
import './index.css';

export type MMapDefaultPopupMarkerProps = Omit<MMapBalloonMarkerProps, 'content'> & {
export type MMapDefaultPopupMarkerProps = Omit<MMapPopupMarkerProps, 'content'> & {
/** Displayed title in popup header */
title?: string;
/** Displayed description */
Expand All @@ -25,19 +25,19 @@ export type MMapDefaultPopupMarkerProps = Omit<MMapBalloonMarkerProps, 'content'
* // support MMapMarker props
* coordinates: POPUP_COORD,
* draggable: true,
* // support MMapBalloonMarker props
* // support MMapPopupMarker props
* position: 'top',
* });
* map.addChild(defaultPopup);
* ```
*/
export class MMapDefaultPopupMarker extends mappable.MMapComplexEntity<MMapDefaultPopupMarkerProps> {
static [mappable.optionsKeyVuefy] = MMapDefaultPopupMarkerVuefyOptions;
private _balloon: MMapBalloonMarker;
private _popup: MMapPopupMarker;
private _element: HTMLElement;

public get isOpen() {
return this._balloon.isOpen;
return this._popup.isOpen;
}

protected _onAttach(): void {
Expand All @@ -49,7 +49,7 @@ export class MMapDefaultPopupMarker extends mappable.MMapComplexEntity<MMapDefau
);
}

this._balloon = new MMapBalloonMarker({
this._popup = new MMapPopupMarker({
...this._props,
content: this.__createDefaultPopup,
onClose: () => {
Expand All @@ -61,7 +61,7 @@ export class MMapDefaultPopupMarker extends mappable.MMapComplexEntity<MMapDefau
this._props.onOpen?.();
}
});
this.addChild(this._balloon);
this.addChild(this._popup);

this._watchContext(mappable.ThemeContext, () => this._updateTheme(), {immediate: true});
}
Expand All @@ -74,18 +74,18 @@ export class MMapDefaultPopupMarker extends mappable.MMapComplexEntity<MMapDefau
const isActionChange = oldProps.action !== action;

if (isTitleChange || isDescriptionChange || isActionChange) {
this._balloon.update({content: () => this.__createDefaultPopup()});
this._popup.update({content: () => this.__createDefaultPopup()});
}

this._balloon.update(this._props);
this._popup.update(this._props);
}

private _updateTheme() {
const themeCtx = this._consumeContext(mappable.ThemeContext);
this._element.classList.toggle('mappable--default-popup__dark', themeCtx.theme === 'dark');
}

private __createDefaultPopup: MMapBalloonContentProps = () => {
private __createDefaultPopup: MMapPopupContentProps = () => {
const {title, description, action} = this._props;
this._element = document.createElement('mappable');
this._element.classList.add('mappable--default-popup');
Expand All @@ -104,7 +104,7 @@ export class MMapDefaultPopupMarker extends mappable.MMapComplexEntity<MMapDefau
const closeButton = document.createElement('button');
closeButton.classList.add('mappable--default-popup_header_close');
closeButton.innerHTML = closeSVG;
closeButton.addEventListener('click', () => this._balloon.update({show: false}));
closeButton.addEventListener('click', () => this._popup.update({show: false}));
popupHeaderElement.appendChild(closeButton);

if (description) {
Expand Down
Loading

0 comments on commit df1d06a

Please sign in to comment.