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 tooltip and popup markers #5

Merged
merged 48 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
eaa0a9b
Added getting information about icons from Figma
matthew44-mappable Mar 19, 2024
b1fa646
Added getting links to icons
matthew44-mappable Mar 19, 2024
65fffaa
restructuring inside the tools folder
matthew44-mappable Mar 19, 2024
2fc239a
Fetching components only with export settings
matthew44-mappable Mar 19, 2024
72848f5
load icon in local folder
matthew44-mappable Mar 29, 2024
b2d08a0
uploading icons from Figma to a local folder
matthew44-mappable Apr 1, 2024
67864b5
export only svg files
matthew44-mappable Apr 1, 2024
60983d8
refactor
matthew44-mappable Apr 1, 2024
4bb1291
optimize svg and filter fallback icons
matthew44-mappable Apr 1, 2024
073ad56
generate types for icons
matthew44-mappable Apr 1, 2024
ea93e84
generate icons list in md file
matthew44-mappable Apr 1, 2024
9a52d37
filter fill-opacity icons
matthew44-mappable Apr 1, 2024
82e2749
default marker
matthew44-mappable Apr 1, 2024
eed3917
add nanospinner in cli tool
matthew44-mappable Apr 1, 2024
1476307
path as common constants, nanospinner error in catch
matthew44-mappable Apr 2, 2024
07c1a4b
show pin with icon
matthew44-mappable Apr 2, 2024
8ff8c5e
fetch colors from Figma
matthew44-mappable Apr 3, 2024
bcc0b34
color props
matthew44-mappable Apr 3, 2024
4454824
optional props
matthew44-mappable Apr 4, 2024
71e6487
custom color
matthew44-mappable Apr 4, 2024
351f302
add fallback icon
matthew44-mappable Apr 4, 2024
d7aadc4
size props in marker
matthew44-mappable Apr 8, 2024
6e92501
Downscale if no small icon
matthew44-mappable Apr 8, 2024
10aef04
upgrade markers
matthew44-mappable Apr 10, 2024
3a9b8b9
download icons
matthew44-mappable Apr 11, 2024
530b4b6
fix
matthew44-mappable Apr 11, 2024
074a182
took chunk function from lodash
matthew44-mappable Apr 18, 2024
c5b89e9
rename generated files
matthew44-mappable Apr 18, 2024
41328c2
add tooltip marker
matthew44-mappable Apr 15, 2024
90d16ca
tooltip combined positions, tooltip offset
matthew44-mappable Apr 15, 2024
5999b7f
support dark theme
matthew44-mappable Apr 15, 2024
8a0d7c4
separated tooltip and balloon
matthew44-mappable Apr 15, 2024
d254b25
add default popup
matthew44-mappable Apr 17, 2024
cd1d6e9
remove close callback from popup content
matthew44-mappable Apr 17, 2024
878dabe
remove mock MMapPopupMarker
matthew44-mappable Apr 17, 2024
60068f4
add overrides
matthew44-mappable Apr 18, 2024
38f69ad
popups examples
matthew44-mappable Apr 18, 2024
055e07e
add unit-tests
matthew44-mappable Apr 18, 2024
e2a9d4c
add prefix in css
matthew44-mappable Apr 22, 2024
4e07036
add open animations
matthew44-mappable Apr 22, 2024
e1a9bed
remove __impl
matthew44-mappable Apr 25, 2024
c96c272
add popup in default marker
matthew44-mappable Apr 26, 2024
4464bb9
fix popup in marker
matthew44-mappable Apr 27, 2024
df1d06a
Rename ballon to popup
matthew44-mappable May 8, 2024
e2ca0f3
Rename tooltip to text-popup
matthew44-mappable May 8, 2024
838ffd0
fix issues
matthew44-mappable May 13, 2024
b342f2a
remove text popup and default popup
matthew44-mappable May 13, 2024
3ed3960
fix
matthew44-mappable May 14, 2024
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
18 changes: 18 additions & 0 deletions example/default-popups/common.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.custom-popup {
display: grid;
max-width: inherit;
grid-template-columns: 120px 64px;
grid-template-rows: repeat(2, 1fr);
gap: 10px;

& .title {
font-weight: bold;
font-size: 18px;
}

& .content {
width: 100%;
font-size: 16px;
grid-column: 1 / 3;
}
}
7 changes: 7 additions & 0 deletions example/default-popups/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type {LngLat, MMapLocationRequest} from '@mappable-world/mappable-types';

const CENTER: LngLat = [55.442795, 25.24107];
export const LOCATION: MMapLocationRequest = {center: CENTER, zoom: 14};

export const CUSTOM_POPUP_COORDS: LngLat = [CENTER[0] - 0.02, CENTER[1]];
export const DEFAULT_POPUP_COORDS: LngLat = [CENTER[0] + 0.02, CENTER[1]];
37 changes: 37 additions & 0 deletions example/default-popups/react/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!doctype html>
<html>
<head>
<title>React example mappable-default-ui-theme</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<script crossorigin src="https://unpkg.com/react@17/umd/react.production.min.js"></script>
matthew44-mappable marked this conversation as resolved.
Show resolved Hide resolved
<script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js"></script>
<script crossorigin src="https://unpkg.com/@babel/standalone@7/babel.min.js"></script>
<script src="https://js.api.mappable.world/3.0/?apikey=%APIKEY%&lang=en_US"></script>

<script
data-plugins="transform-modules-umd"
data-presets="react, typescript"
type="text/babel"
src="../../index.ts"
></script>
<script
data-plugins="transform-modules-umd"
data-presets="react, typescript"
type="text/babel"
src="../common.ts"
></script>
<script
data-plugins="transform-modules-umd"
data-presets="react, typescript"
type="text/babel"
src="./index.tsx"
></script>

<link rel="stylesheet" href="../../index.css" />
<link rel="stylesheet" href="../common.css" />
</head>
<body>
<div id="app"></div>
</body>
</html>
70 changes: 70 additions & 0 deletions example/default-popups/react/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import {CUSTOM_POPUP_COORDS, DEFAULT_POPUP_COORDS, LOCATION} from '../common';

window.map = null;

main();
async function main() {
const [mappableReact] = await Promise.all([mappable.import('@mappable-world/mappable-reactify'), mappable.ready]);
const reactify = mappableReact.reactify.bindTo(React, ReactDOM);

const {MMap, MMapDefaultSchemeLayer, MMapDefaultFeaturesLayer, MMapControls, MMapControlButton} =
reactify.module(mappable);

const {useState, useCallback} = React;

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

ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('app')
);

function App() {
const [location] = useState(LOCATION);
const [showDefaultPopup, setShowDefaultPopup] = useState(true);
const [showCustomPopup, setShowCustomPopup] = useState(true);

const toggleDefaultPopup = useCallback(() => setShowDefaultPopup((prev) => !prev), [showDefaultPopup]);
const toggleCustomPopup = useCallback(() => setShowCustomPopup((prev) => !prev), [showCustomPopup]);
const actionCallback = useCallback(() => alert('Click on action button!'), []);
const contentCallback = useCallback(
() => (
<div className="custom-popup">
<div className="title">Title</div>
<button onClick={onCloseCustomPopup}>close</button>
<div className="content">Custom popup content</div>
</div>
),
[]
);
const onCloseCustomPopup = useCallback(() => setShowCustomPopup(false), [showCustomPopup]);
const onCloseDefaultPopup = useCallback(() => setShowDefaultPopup(false), [showDefaultPopup]);

return (
<MMap location={location} ref={(x) => (map = x)}>
<MMapDefaultSchemeLayer />
<MMapDefaultFeaturesLayer />
<MMapControls position="top right">
<MMapControlButton text="Toggle custom popup" onClick={toggleCustomPopup} />
<MMapControlButton text="Toggle default popup" onClick={toggleDefaultPopup} />
</MMapControls>

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

<MMapDefaultPopupMarker
show={showDefaultPopup}
coordinates={DEFAULT_POPUP_COORDS}
title="Default popup marker"
description="Description for default popup"
action="Make an action"
onAction={actionCallback}
onClose={onCloseDefaultPopup}
/>
</MMap>
);
}
}
35 changes: 35 additions & 0 deletions example/default-popups/vanilla/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!doctype html>
<html>
<head>
<title>Vanilla example mappable-default-ui-theme</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<script crossorigin src="https://unpkg.com/@babel/standalone@7/babel.min.js"></script>
<script src="https://js.api.mappable.world/3.0/?apikey=%APIKEY%&lang=en_US"></script>

<script
data-plugins="transform-modules-umd"
data-presets="react, typescript"
type="text/babel"
src="../../index.ts"
></script>
<script
data-plugins="transform-modules-umd"
data-presets="typescript"
type="text/babel"
src="../common.ts"
></script>
<script
data-plugins="transform-modules-umd"
data-presets="typescript"
type="text/babel"
src="./index.ts"
></script>

<link rel="stylesheet" href="../../index.css" />
<link rel="stylesheet" href="../common.css" />
</head>
<body>
<div id="app"></div>
</body>
</html>
65 changes: 65 additions & 0 deletions example/default-popups/vanilla/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import {CUSTOM_POPUP_COORDS, DEFAULT_POPUP_COORDS, LOCATION} from '../common';
window.map = null;

main();
async function main() {
await mappable.ready;
const {MMap, MMapDefaultSchemeLayer, MMapDefaultFeaturesLayer, MMapControls, MMapControlButton} = mappable;

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

map = new MMap(document.getElementById('app'), {location: LOCATION});

map.addChild(new MMapDefaultSchemeLayer({}));
map.addChild(new MMapDefaultFeaturesLayer({}));

map.addChild(
new MMapControls({position: 'top right'}, [
new MMapControlButton({
text: 'Toggle custom popup',
onClick: () => customPopup.update({show: !customPopup.isOpen})
}),
new MMapControlButton({
text: 'Toggle default popup',
onClick: () => defaultPopup.update({show: !defaultPopup.isOpen})
})
])
);

const customPopup = new MMapPopupMarker({
coordinates: CUSTOM_POPUP_COORDS,
content: () => {
const popupElement = document.createElement('div');
popupElement.classList.add('custom-popup');

const titleElement = document.createElement('div');
titleElement.classList.add('title');
titleElement.textContent = 'Title';
popupElement.appendChild(titleElement);

const closeButton = document.createElement('button');
closeButton.textContent = 'close';
closeButton.addEventListener('click', () => customPopup.update({show: false}));
popupElement.appendChild(closeButton);

const contentElement = document.createElement('div');
contentElement.classList.add('content');
contentElement.textContent = 'Custom popup content';
popupElement.appendChild(contentElement);

return popupElement;
}
});
map.addChild(customPopup);

const defaultPopup = new MMapDefaultPopupMarker({
coordinates: DEFAULT_POPUP_COORDS,
title: 'Default popup marker',
description: 'Description for default popup',
action: 'Make an action',
onAction: () => alert('Click on action button!')
});
map.addChild(defaultPopup);
}
36 changes: 36 additions & 0 deletions example/default-popups/vue/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!doctype html>
<html>
<head>
<title>Vue example mappable-default-ui-theme</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<script crossorigin src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script crossorigin src="https://unpkg.com/@babel/standalone@7/babel.min.js"></script>
<script src="https://js.api.mappable.world/3.0/?apikey=%APIKEY%&lang=en_US"></script>

<script
data-plugins="transform-modules-umd"
data-presets="react, typescript"
type="text/babel"
src="../../index.ts"
></script>
<script
data-plugins="transform-modules-umd"
data-presets="typescript"
type="text/babel"
src="../common.ts"
></script>
<script
data-plugins="transform-modules-umd"
data-presets="typescript"
type="text/babel"
src="./index.ts"
></script>

<link rel="stylesheet" href="../../index.css" />
<link rel="stylesheet" href="../common.css" />
</head>
<body>
<div id="app"></div>
</body>
</html>
84 changes: 84 additions & 0 deletions example/default-popups/vue/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import {CUSTOM_POPUP_COORDS, DEFAULT_POPUP_COORDS, LOCATION} from '../common';

window.map = null;

main();
async function main() {
const [mappableVue] = await Promise.all([mappable.import('@mappable-world/mappable-vuefy'), mappable.ready]);
const vuefy = mappableVue.vuefy.bindTo(Vue);

const {MMap, MMapDefaultSchemeLayer, MMapDefaultFeaturesLayer, MMapControls, MMapControlButton} =
vuefy.module(mappable);

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

const app = Vue.createApp({
components: {
MMap,
MMapDefaultSchemeLayer,
MMapDefaultFeaturesLayer,
MMapControls,
MMapControlButton,
MMapPopupMarker,
MMapDefaultPopupMarker
},
setup() {
const location = Vue.ref(LOCATION);
const showDefaultPopup = Vue.ref(true);
const showCustomPopup = Vue.ref(true);
const refMap = (ref: any) => {
window.map = ref?.entity;
};

const toggleDefaultPopup = () => (showDefaultPopup.value = !showDefaultPopup.value);
const toggleCustomPopup = () => (showCustomPopup.value = !showCustomPopup.value);
const actionCallback = () => alert('Click on action button!');
const onCloseCustomPopup = () => (showCustomPopup.value = false);
const onCloseDefaultPopup = () => (showDefaultPopup.value = false);

return {
location,
refMap,
toggleCustomPopup,
toggleDefaultPopup,
onCloseCustomPopup,
onCloseDefaultPopup,
actionCallback,
showCustomPopup,
showDefaultPopup,
CUSTOM_POPUP_COORDS,
DEFAULT_POPUP_COORDS
};
},
template: `
<MMap :location="location" :ref="refMap">
<MMapDefaultSchemeLayer />
<MMapDefaultFeaturesLayer />
<MMapControls position="top right">
<MMapControlButton text="Toggle custom popup" :onClick="toggleCustomPopup" />
<MMapControlButton text="Toggle default popup" :onClick="toggleDefaultPopup" />
</MMapControls>
<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>
</MMapPopupMarker>
<MMapDefaultPopupMarker
:show="showDefaultPopup"
:coordinates="DEFAULT_POPUP_COORDS"
title="Default popup marker"
description="Description for default popup"
action="Make an action"
:onAction="actionCallback"
:onClose="onCloseDefaultPopup"
/>
</MMap>`
});
app.mount('#app');
}
5 changes: 5 additions & 0 deletions example/default-tooltip/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type {MMapLocationRequest, LngLat} from '@mappable-world/mappable-types';
matthew44-mappable marked this conversation as resolved.
Show resolved Hide resolved

export const CENTER: LngLat = [55.442795, 25.24107];
export const LOCATION: MMapLocationRequest = {center: CENTER, zoom: 14};
export const TOOLTIP_TEXT = 'Default tooltip';
Loading
Loading