From 547e64b317cb0853215a3a7604341b11ed542e24 Mon Sep 17 00:00:00 2001 From: James Lyne Date: Sat, 25 Jun 2022 13:15:22 +0100 Subject: [PATCH] Migrate LogoControl to vue --- src/components/MapUI.vue | 1 + src/components/map/control/LogoControl.vue | 58 +++++++++++---------- src/index.d.ts | 7 ++- src/leaflet/control/LogoControl.ts | 59 ---------------------- src/scss/leaflet/_controls.scss | 12 ----- 5 files changed, 37 insertions(+), 100 deletions(-) delete mode 100644 src/leaflet/control/LogoControl.ts diff --git a/src/components/MapUI.vue b/src/components/MapUI.vue index b8ce75e..c9c21a8 100644 --- a/src/components/MapUI.vue +++ b/src/components/MapUI.vue @@ -22,6 +22,7 @@
+
diff --git a/src/components/map/control/LogoControl.vue b/src/components/map/control/LogoControl.vue index 7c8abc1..9dc087b 100644 --- a/src/components/map/control/LogoControl.vue +++ b/src/components/map/control/LogoControl.vue @@ -14,45 +14,47 @@ - limitations under the License. --> + + - diff --git a/src/index.d.ts b/src/index.d.ts index 95e5b87..b424702 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -26,7 +26,6 @@ import { PointTuple, PolylineOptions } from "leaflet"; -import {LogoControlOptions} from "@/leaflet/control/LogoControl"; import {globalMessages, serverMessages} from "../messages"; import {LiveAtlasMarkerType} from "@/util/markers"; import {LiveAtlasTileLayer, LiveAtlasTileLayerOptions} from "@/leaflet/tileLayer/LiveAtlasTileLayer"; @@ -303,6 +302,12 @@ export interface CoordinatesControlOptions extends ControlOptions { label: string; } +export interface LogoControlOptions extends ControlOptions { + url?: string; + image?: string; + text: string; +} + interface LiveAtlasPartialComponentConfig { markers?: { showLabels: boolean; diff --git a/src/leaflet/control/LogoControl.ts b/src/leaflet/control/LogoControl.ts deleted file mode 100644 index 0c0a05e..0000000 --- a/src/leaflet/control/LogoControl.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2022 James Lyne - * - * Some portions of this file were taken from https://github.com/webbukkit/dynmap. - * These portions are Copyright 2020 Dynmap Contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import {Control, ControlOptions, DomUtil} from 'leaflet'; - -export interface LogoControlOptions extends ControlOptions { - url?: string; - image?: string; - text: string; -} - -/** - * Leaflet map control which displays an arbitrary image or text with an optional link - * Intended for use for dynmap logo components - */ -export class LogoControl extends Control { - declare options: LogoControlOptions; - - constructor(options: LogoControlOptions) { - super(options); - } - - onAdd() { - const container = DomUtil.create('div', 'leaflet-control-logo'); - let link; - - if (this.options.url) { - link = DomUtil.create('a', '', container) as HTMLAnchorElement; - link.href = this.options.url; - link.setAttribute('aria-label', this.options.text); - } - - if (this.options.image) { - const image = DomUtil.create('img', '', link) as HTMLImageElement; - image.src = this.options.image; - image.alt = this.options.text; - } else { - container.textContent = this.options.text; - } - - return container; - } -} diff --git a/src/scss/leaflet/_controls.scss b/src/scss/leaflet/_controls.scss index 1e9e22d..b6374ee 100644 --- a/src/scss/leaflet/_controls.scss +++ b/src/scss/leaflet/_controls.scss @@ -139,18 +139,6 @@ } } -.leaflet-control-logo { - flex-shrink: 0; - - a { - height: 100%; - width: 100%; - display: flex; - align-items: center; - justify-content: center; - } -} - .leaflet-top, .leaflet-bottom, .leaflet-left, .leaflet-right { display: flex;