From 5a94e9d239ca7d87f1fe1650a35ebe2edfad3e49 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Wed, 6 Apr 2022 19:16:55 +0200 Subject: [PATCH] Improvements to the climbing theme --- Models/Denomination.ts | 19 +++++-- UI/Popup/FeatureInfoBox.ts | 6 ++- UI/SubstitutedTranslation.ts | 2 +- UI/i18n/Translation.ts | 1 - assets/themes/climbing/climbing.json | 76 +++++++++++++++------------- css/index-tailwind-output.css | 8 +-- 6 files changed, 65 insertions(+), 47 deletions(-) diff --git a/Models/Denomination.ts b/Models/Denomination.ts index f3722b661..45b17f2a7 100644 --- a/Models/Denomination.ts +++ b/Models/Denomination.ts @@ -73,12 +73,25 @@ export class Denomination { * en: "meter" * } * }, "test") - * unit.canonicalValue("42m") // =>"42 m" + * unit.canonicalValue("42m") // =>"42 m" * unit.canonicalValue("42") // =>"42 m" * unit.canonicalValue("42 m") // =>"42 m" * unit.canonicalValue("42 meter") // =>"42 m" * * + * // Should be trimmed if canonical is empty + * const unit = new Denomination({ + * canonicalDenomination: "", + * alternativeDenomination: ["meter","m], + * 'default': true, + * human: { + * en: "meter" + * } + * }, "test") + * unit.canonicalValue("42m") // =>"42" + * unit.canonicalValue("42") // =>"42" + * unit.canonicalValue("42 m") // =>"42" + * unit.canonicalValue("42 meter") // =>"42" */ public canonicalValue(value: string, actAsDefault?: boolean) : string { if (value === undefined) { @@ -89,9 +102,9 @@ export class Denomination { return null; } if (stripped === "1" && this._canonicalSingular !== undefined) { - return "1 " + this._canonicalSingular + return ("1 " + this._canonicalSingular).trim() } - return stripped + " " + this.canonical; + return (stripped + " " + this.canonical).trim(); } /** diff --git a/UI/Popup/FeatureInfoBox.ts b/UI/Popup/FeatureInfoBox.ts index 55f1a0b67..43c56778a 100644 --- a/UI/Popup/FeatureInfoBox.ts +++ b/UI/Popup/FeatureInfoBox.ts @@ -64,8 +64,10 @@ export default class FeatureInfoBox extends ScrollableFullScreen { const title = new TagRenderingAnswer(tags, layerConfig.title ?? new TagRenderingConfig("POI"), state) .SetClass("break-words font-bold sm:p-0.5 md:p-1 sm:p-1.5 md:p-2 text-2xl"); const titleIcons = new Combine( - layerConfig.titleIcons.map(icon => new TagRenderingAnswer(tags, icon, state, - "block w-8 h-8 max-h-8 align-baseline box-content sm:p-0.5 w-10",) + layerConfig.titleIcons.map(icon => { + return new TagRenderingAnswer(tags, icon, state, + "block h-8 max-h-8 align-baseline box-content sm:p-0.5").SetClass("flex"); + } )) .SetClass("flex flex-row flex-wrap pt-0.5 sm:pt-1 items-center mr-2") diff --git a/UI/SubstitutedTranslation.ts b/UI/SubstitutedTranslation.ts index bccb6e4e2..856ff2482 100644 --- a/UI/SubstitutedTranslation.ts +++ b/UI/SubstitutedTranslation.ts @@ -35,7 +35,7 @@ export class SubstitutedTranslation extends VariableUiElement { ) }) - const linkToWeblate = new LinkToWeblate(translation.context, translation.translations) + const linkToWeblate = translation !== undefined ? new LinkToWeblate(translation.context, translation.translations) : undefined; super( Locale.language.map(language => { diff --git a/UI/i18n/Translation.ts b/UI/i18n/Translation.ts index f0504ada6..e9c815708 100644 --- a/UI/i18n/Translation.ts +++ b/UI/i18n/Translation.ts @@ -131,7 +131,6 @@ export class Translation extends BaseUIElement { const wrapper = document.createElement("span") wrapper.appendChild(el) - wrapper.classList.add("flex") Locale.showLinkToWeblate.addCallbackAndRun(doShow => { if (!doShow) { diff --git a/assets/themes/climbing/climbing.json b/assets/themes/climbing/climbing.json index f48ce9bfa..cc5af9e78 100644 --- a/assets/themes/climbing/climbing.json +++ b/assets/themes/climbing/climbing.json @@ -143,10 +143,6 @@ }, "id": "climbing_club-name" }, - { - "id": "minimap", - "render": "{minimap(18): height: 5rem; overflow: hidden; border-radius:3rem; }" - }, "website", "email", "phone", @@ -287,11 +283,6 @@ }, "tagRenderings": [ "images", - "questions", - { - "id": "minimap", - "render": "{minimap(18): height: 5rem; overflow: hidden; border-radius:3rem; }" - }, { "render": { "en": "{name}", @@ -320,8 +311,7 @@ "website", "phone", "email", - "opening_hours", - "reviews" + "opening_hours" ], "mapRendering": [ { @@ -397,11 +387,6 @@ }, "tagRenderings": [ "images", - "questions", - { - "id": "minimap", - "render": "{minimap(18): height: 5rem; overflow: hidden; border-radius:3rem; }" - }, { "render": { "en": "{name}", @@ -555,8 +540,7 @@ "key": "_embedding_features_with_rock:rock" }, "id": "Rock type" - }, - "reviews" + } ], "presets": [ { @@ -704,7 +688,6 @@ }, "tagRenderings": [ "images", - "questions", { "id": "minimap", "render": "{minimap(18, id, _contained_climbing_route_ids): height: 9rem; overflow: hidden; border-radius:3rem; }" @@ -846,8 +829,7 @@ ] }, "id": "Rock type (crag/rock/cliff only)" - }, - "reviews" + } ], "presets": [ { @@ -955,10 +937,6 @@ "it": "Un’opportunità di arrampicata?" }, "tagRenderings": [ - { - "id": "minimap", - "render": "{minimap(18): height: 5rem; overflow: hidden; border-radius:3rem; }" - }, { "id": "climbing-opportunity-name", "render": { @@ -1053,26 +1031,50 @@ } ], "overrideAll": { - "titleIcons": [ + "+titleIcons": [ { - "render": "
{climbing:length}m
", - "freeform": { - "key": "climbing:length" - } + "render": "
{climbing:length}m
", + "condition": "climbing:length~*" }, { - "render": "
{climbing:bolted}
", - "freeform": { - "key": "climbing:bolted" - }, "mappings": [ + { + "if": "climbing:bolts~*", + "then": "
{climbing:bolts}
" + }, { "if": "climbing:bolted=yes", "then": "" } ] }, - "defaults" + { + "mappings": [ + { + "if": "climbing:grade:french~3.*", + "then": "
{climbing:grade:french}
" + }, + { + "if": "climbing:grade:french~4.*", + "then": "
{climbing:grade:french}
" + },{ + "if": "climbing:grade:french~5.*", + "then": "
{climbing:grade:french}
" + }, + { + "if": "climbing:grade:french~6.*", + "then": "
{climbing:grade:french}
" + }, + { + "if": "climbing:grade:french~7.*", + "then": "
{climbing:grade:french}
" + }, + { + "if": "climbing:grade:french~*", + "then": "
{climbing:grade:french}
" + } + ] + } ], "+calculatedTags": [ "_embedding_feature_properties=feat.overlapWith('climbing').map(f => f.feat.properties).filter(p => p !== undefined).map(p => {return{access: p.access, id: p.id, name: p.name, climbing: p.climbing, 'access:description': p['access:description']}})", @@ -1690,7 +1692,9 @@ "hideInAnswer": true } ] - } + }, + "questions", + "reviews" ] } } \ No newline at end of file diff --git a/css/index-tailwind-output.css b/css/index-tailwind-output.css index b0527f323..a41659488 100644 --- a/css/index-tailwind-output.css +++ b/css/index-tailwind-output.css @@ -1523,10 +1523,6 @@ video { padding-left: 1rem; } -.pl-1 { - padding-left: 0.25rem; -} - .pl-2 { padding-left: 0.5rem; } @@ -1543,6 +1539,10 @@ video { padding-bottom: 0.25rem; } +.pl-1 { + padding-left: 0.25rem; +} + .pr-1 { padding-right: 0.25rem; }