map/src/components.js

72 lines
1.8 KiB
JavaScript
Raw Normal View History

2024-01-23 22:21:34 +03:00
import { Converter } from "showdown";
import l from "./locales";
let converter = new Converter();
export function countryPopup(country, properties) {
return `<div class="row" style="padding: 5px;">
${img(country.img)}
${title(country.name)}
2024-01-24 15:31:45 +03:00
${tags(properties.tags)}
2024-01-24 15:12:07 +03:00
<div class="col-12 glass p-2">
2024-01-24 15:31:45 +03:00
${l("founded")}: ${new Date(country.date).toLocaleDateString()}<br/>
2024-01-23 22:21:34 +03:00
${
country.description
? `<div>${converter.makeHtml(country.description)}</div>`
: ""
2024-01-24 15:31:45 +03:00
}<br/>
2024-01-24 15:12:07 +03:00
${l("area")}: ${properties.area} ${l("km")}²
2024-01-23 22:21:34 +03:00
</div>
<div class="col-12 text-center mt-2">
${
country.about
? `<a href="${country.about}" class="about">${l("about")}</a>`
: ""
}
</div>
</div>`;
}
2024-01-24 15:31:45 +03:00
function tags(tags) {
let tagstxt = JSON.parse(tags || "[]").join(", ");
return tagstxt
? `<div class="col-12 glass p-2 text-center mb-2"> ${tagstxt}</div>`
: "";
}
2024-01-23 22:21:34 +03:00
function img(url) {
return `<div class="col-12 col-sm-12" style="padding: 0px;"><img class="w-100 about-img" src="${url}"></div>`;
}
function title(name) {
2024-01-24 15:12:07 +03:00
return `<div class="col-12 text-center glass mb-2 pt-2"><h5>${name}</h5></div>`;
2024-01-23 22:21:34 +03:00
}
export function markerPopup(properties) {
return `
${
properties?.amount
? `<div class="row glass" style="color: "white";"><div class="col">${l(
"population"
)} - ${properties.amount} ${l("people")}.</div></div>`
: ""
}
<div class="row" style="padding: 5px;">
${properties?.img ? img(properties.img) : ""}
${title(
`${properties.name} ${
properties.translated_name ? `- ${properties.translated_name}` : ""
}`
)}
${
properties.description
? `<div class="col-md-12 col-sm-12 text-center glass"><div>${converter.makeHtml(
properties.description
)}</div></div>`
: ""
}
</div>
`;
}