From ac2dd1f399e3c457fb8cd1dbce8e220c3705818c Mon Sep 17 00:00:00 2001 From: James Lyne Date: Tue, 5 Jan 2021 22:30:55 +0000 Subject: [PATCH] Implement chat balloons --- src/api.ts | 5 + src/components/map/marker/PlayerMarker.vue | 225 ++++++++++++++++----- src/dynmap.d.ts | 1 + src/scss/leaflet/_popups.scss | 33 ++- src/store/state.ts | 6 + 5 files changed, 205 insertions(+), 65 deletions(-) diff --git a/src/api.ts b/src/api.ts index eeb5e0c..64fb776 100644 --- a/src/api.ts +++ b/src/api.ts @@ -127,6 +127,7 @@ function buildComponents(response: any): DynmapComponentConfig { showLabels: false, }, chat: undefined, + chatBalloons: false, playerMarkers: undefined, coordinatesControl: undefined, linkControl: false, @@ -198,6 +199,10 @@ function buildComponents(response: any): DynmapComponentConfig { messageLifetime: component.messagettl || Infinity, messageHistory: component.scrollback || Infinity, } + break; + + case "chatballoon": + components.chatBalloons = true; } }); diff --git a/src/components/map/marker/PlayerMarker.vue b/src/components/map/marker/PlayerMarker.vue index 9f2185c..ac33bf7 100644 --- a/src/components/map/marker/PlayerMarker.vue +++ b/src/components/map/marker/PlayerMarker.vue @@ -15,11 +15,12 @@ --> - - \ No newline at end of file diff --git a/src/dynmap.d.ts b/src/dynmap.d.ts index 10441a7..eb60946 100644 --- a/src/dynmap.d.ts +++ b/src/dynmap.d.ts @@ -81,6 +81,7 @@ interface DynmapComponentConfig { linkControl: boolean; logoControls: Array; chat?: DynmapChatConfig; + chatBalloons: boolean; } interface DynmapMarkersConfig { diff --git a/src/scss/leaflet/_popups.scss b/src/scss/leaflet/_popups.scss index da9d53a..bc55da3 100644 --- a/src/scss/leaflet/_popups.scss +++ b/src/scss/leaflet/_popups.scss @@ -14,16 +14,27 @@ * limitations under the License. */ -.leaflet-popup-content-wrapper, .leaflet-popup-tip { - background-color: $global-background; - color: $global-text-color; +.leaflet-popup { + .leaflet-popup-content-wrapper, .leaflet-popup-tip { + background-color: $global-background; + color: $global-text-color; + } + + .leaflet-popup-content-wrapper { + border-radius: $global-border-radius; + } + + .leaflet-popup-content { + margin: 1.5rem; + word-break: break-word; + } + + &.leaflet-popup--chat { + .leaflet-popup-content { + margin: 0.5rem 1rem; + display: flex; + flex-direction: column; + } + } } -.leaflet-popup-content-wrapper { - border-radius: $global-border-radius; -} - -.leaflet-popup-content { - margin: 1.5rem; - word-break: break-all; -} \ No newline at end of file diff --git a/src/store/state.ts b/src/store/state.ts index 6f402f0..c7674f1 100644 --- a/src/store/state.ts +++ b/src/store/state.ts @@ -134,6 +134,12 @@ export const state: State = { //Optional "logo" controls. logoControls: [], + + //Chat + chat: undefined, + + //Show chat messages above player markers + chatBalloons: false }, followTarget: undefined,