diff --git a/src/markers/MMapDefaultMarker/index.ts b/src/markers/MMapDefaultMarker/index.ts index 57de00c..698a9fd 100644 --- a/src/markers/MMapDefaultMarker/index.ts +++ b/src/markers/MMapDefaultMarker/index.ts @@ -1,6 +1,6 @@ import {LngLat, MMapMarker, MMapMarkerProps} from '@mappable-world/mappable-types'; import {IconColor, IconName, iconColors, icons} from '../../icons'; -import {MMapPopupContentProps, MMapPopupMarker} from '../MMapPopupMarker'; +import {MMapPopupMarkerProps, MMapPopupMarker} from '../MMapPopupMarker'; import {MMapDefaultMarkerReactifyOverride} from './react'; import {MMapDefaultMarkerVuefyOptions, MMapDefaultMarkerVuefyOverride} from './vue'; @@ -32,15 +32,19 @@ const HINT_SUBTITLE_CLASS = 'mappable--hint-subtitle'; const HINT_STABLE = 'mappable--hint__stable'; const HINT_HOVERED = 'mappable--hint__hovered'; +const NORMAL_SIZE_MARKER_HEIGHT = 59; +const NORMAL_SIZE_MARKER_WIDTH = 44; + +const SMALL_SIZE_MARKER_WIDTH = 24; + +const MICRO_SIZE_MARKER_WIDTH = 14; + const DISTANCE_BETWEEN_POPUP_AND_MARKER = 8; export type ThemesColor = {day: string; night: string}; export type MarkerColorProps = IconColor | ThemesColor; export type MarkerSizeProps = 'normal' | 'small' | 'micro'; -export type MarkerPopupProps = { - /** The function of creating popup content */ - content: MMapPopupContentProps; -}; +export type MarkerPopupProps = Omit; export type MMapDefaultMarkerProps = MMapMarkerProps & { iconName?: IconName; @@ -212,8 +216,8 @@ export class MMapDefaultMarker extends mappable.MMapComplexEntity & { /** The function of creating popup content */ content: string | (() => TReact.ReactElement); }; @@ -29,7 +29,7 @@ export const MMapDefaultMarkerReactifyOverride: CustomReactify(); - const popupContent = React.useMemo(() => { + const popup = React.useMemo(() => { if (props.popup === undefined) { return undefined; } @@ -40,12 +40,12 @@ export const MMapDefaultMarkerReactifyOverride: CustomReactify popupElement}; + return {...props.popup, content: () => popupElement}; }, [props.popup, popupElement]); return ( <> - + {ReactDOM.createPortal(content, popupElement)} ); diff --git a/src/markers/MMapDefaultMarker/vue/index.ts b/src/markers/MMapDefaultMarker/vue/index.ts index 9a7b547..91e2171 100644 --- a/src/markers/MMapDefaultMarker/vue/index.ts +++ b/src/markers/MMapDefaultMarker/vue/index.ts @@ -4,7 +4,12 @@ import type TVue from '@vue/runtime-core'; import {MMapDefaultMarker, MMapDefaultMarkerProps, MarkerColorProps, MarkerPopupProps, MarkerSizeProps} from '../'; import {IconName} from '../../../icons'; -export const MMapDefaultMarkerVuefyOptions: CustomVuefyOptions = { +type VuefyMarkerPopup = Omit; + +export const MMapDefaultMarkerVuefyOptions: CustomVuefyOptions< + MMapDefaultMarker, + Omit & {popup: VuefyMarkerPopup} +> = { props: { coordinates: {type: Object, required: true}, source: String, @@ -29,7 +34,7 @@ export const MMapDefaultMarkerVuefyOptions: CustomVuefyOptions} + popup: {type: Object as TVue.PropType} } }; @@ -43,11 +48,10 @@ export const MMapDefaultMarkerVuefyOverride: CustomVuefyFn = {vuefy, Vue} ) => { const MMapDefaultMarkerV = vuefy.entity(MMapDefaultMarkerI); - const {popup, ...overridedProps} = props; return Vue.defineComponent({ name: 'MMapDefaultMarker', - props: overridedProps, + props, slots: Object as TVue.SlotsType, setup(props, {slots, expose}) { const content: TVue.Ref = Vue.ref(null); @@ -61,7 +65,7 @@ export const MMapDefaultMarkerVuefyOverride: CustomVuefyFn = return undefined; } content.value = slots.popupContent(); - return {content: () => popupHTMLElement}; + return {...props.popup, content: () => popupHTMLElement}; }); expose({entity: markerEntity}); return () =>