Use canonical rendering in windpowermap

This commit is contained in:
Pieter Vander Vennet 2021-07-13 18:52:02 +02:00
parent f5cc180eea
commit 42d0071b26
5 changed files with 17 additions and 5 deletions

View file

@ -3,6 +3,7 @@ import UnitConfigJson from "./UnitConfigJson";
import Translations from "../../UI/i18n/Translations";
import BaseUIElement from "../../UI/BaseUIElement";
import Combine from "../../UI/Base/Combine";
import {FixedUiElement} from "../../UI/Base/FixedUiElement";
export class Unit {
public readonly appliesToKeys: Set<string>;
@ -81,7 +82,10 @@ export class Unit {
return undefined;
}
const [stripped, denom] = this.findDenomination(value)
const human = denom.human
const human = denom?.human
if(human === undefined){
return new FixedUiElement(stripped ?? value);
}
const elems = denom.prefix ? [human, stripped] : [stripped, human];
return new Combine(elems)

View file

@ -225,6 +225,10 @@ export interface LayoutConfigJson {
*
* Not only do we want to write consistent data to OSM, we also want to present this consistently to the user.
* This is handled by defining units.
*
* # Rendering
*
* To render a value with long (human) denomination, use {canonical(key)}
*
* # Usage
*