From 457338f10a90aafd118d236ecf7786d50d38b959 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Thu, 3 Oct 2024 09:47:18 +0200 Subject: [PATCH] feat: allow to define tooltip size --- umap/static/umap/js/modules/data/features.js | 1 + umap/static/umap/js/modules/data/layer.js | 1 + umap/static/umap/js/modules/rendering/ui.js | 2 ++ umap/static/umap/js/modules/schema.js | 12 ++++++++++++ umap/static/umap/js/umap.js | 1 + umap/static/umap/map.css | 7 +++++++ 6 files changed, 24 insertions(+) diff --git a/umap/static/umap/js/modules/data/features.js b/umap/static/umap/js/modules/data/features.js index 4f213342..f9026398 100644 --- a/umap/static/umap/js/modules/data/features.js +++ b/umap/static/umap/js/modules/data/features.js @@ -312,6 +312,7 @@ class Feature { 'properties._umap_options.showLabel', 'properties._umap_options.labelDirection', 'properties._umap_options.labelInteractive', + 'properties._umap_options.labelSize', 'properties._umap_options.outlink', 'properties._umap_options.outlinkTarget', ] diff --git a/umap/static/umap/js/modules/data/layer.js b/umap/static/umap/js/modules/data/layer.js index 5668b2f5..21b016d2 100644 --- a/umap/static/umap/js/modules/data/layer.js +++ b/umap/static/umap/js/modules/data/layer.js @@ -697,6 +697,7 @@ export class DataLayer { 'options.showLabel', 'options.labelDirection', 'options.labelInteractive', + 'options.labelSize', 'options.outlinkTarget', 'options.interactive', ] diff --git a/umap/static/umap/js/modules/rendering/ui.js b/umap/static/umap/js/modules/rendering/ui.js index 72a3354a..306f1577 100644 --- a/umap/static/umap/js/modules/rendering/ui.js +++ b/umap/static/umap/js/modules/rendering/ui.js @@ -69,10 +69,12 @@ const FeatureMixin = { const displayName = this.feature.getDisplayName(null) let showLabel = this.feature.getOption('showLabel') const oldLabelHover = this.feature.getOption('labelHover') + const size = this.feature.getOption('labelSize') const options = { direction: this.feature.getOption('labelDirection'), interactive: this.feature.getOption('labelInteractive'), + className: `leaflet-tooltip-${size}`, } if (oldLabelHover && showLabel) showLabel = null // Retrocompat. diff --git a/umap/static/umap/js/modules/schema.js b/umap/static/umap/js/modules/schema.js index f2dab903..9cd3b325 100644 --- a/umap/static/umap/js/modules/schema.js +++ b/umap/static/umap/js/modules/schema.js @@ -264,6 +264,18 @@ export const SCHEMA = { label: translate('Label key'), inheritable: true, }, + labelSize: { + type: String, + impacts: ['data'], + label: translate('Label font size'), + inheritable: true, + choices: [ + ['default', translate('Default')], + ['medium', translate('Medium')], + ['big', translate('Big')], + ], + default: 'default', + }, licence: { type: String, impacts: ['ui'], diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index 1f974830..83105656 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -1260,6 +1260,7 @@ U.Map = L.Map.extend({ 'options.showLabel', 'options.labelDirection', 'options.labelInteractive', + 'options.labelSize', 'options.outlinkTarget', ] builder = new U.FormBuilder(this, popupFields) diff --git a/umap/static/umap/map.css b/umap/static/umap/map.css index c330e00b..0977a16b 100644 --- a/umap/static/umap/map.css +++ b/umap/static/umap/map.css @@ -1185,6 +1185,13 @@ span.popup-icon { .umap-edit-enabled .readonly { cursor: not-allowed; } +.leaflet-tooltip-medium { + font-weight: bold; +} +.leaflet-tooltip-big { + font-weight: bold; + font-size: 1.2rem; +} /* ********************************* */