forked from MapComplete/MapComplete
Update to the import viewers
This commit is contained in:
parent
fa179af601
commit
f09134c3be
26 changed files with 303 additions and 413 deletions
|
@ -8,7 +8,9 @@ export default class Loading extends Combine {
|
|||
const t = Translations.W(msg) ?? Translations.t.general.loading;
|
||||
t.SetClass("pl-2")
|
||||
super([
|
||||
Svg.loading_svg().SetClass("animate-spin").SetStyle("width: 1.5rem; height: 1.5rem;"),
|
||||
Svg.loading_svg()
|
||||
.SetClass("animate-spin self-center")
|
||||
.SetStyle("width: 1.5rem; height: 1.5rem; min-width: 1.5rem;"),
|
||||
t
|
||||
])
|
||||
this.SetClass("flex p-1")
|
||||
|
|
|
@ -55,8 +55,8 @@ export default class MinimapImplementation extends BaseUIElement implements Mini
|
|||
this.leafletMap.addCallbackD(leaflet => {
|
||||
let bounds;
|
||||
if (typeof factor === "number") {
|
||||
bounds = leaflet.getBounds()
|
||||
leaflet.setMaxBounds(bounds.pad(factor))
|
||||
bounds = leaflet.getBounds().pad(factor)
|
||||
leaflet.setMaxBounds(bounds)
|
||||
} else {
|
||||
// @ts-ignore
|
||||
leaflet.setMaxBounds(factor.toLeaflet())
|
||||
|
@ -99,9 +99,9 @@ export default class MinimapImplementation extends BaseUIElement implements Mini
|
|||
// @ts-ignore
|
||||
L.geoJSON(data, {
|
||||
style: {
|
||||
color: "#f00",
|
||||
weight: 2,
|
||||
opacity: 0.4
|
||||
color: "#f44",
|
||||
weight: 4,
|
||||
opacity: 0.7
|
||||
}
|
||||
}).addTo(leaflet)
|
||||
}
|
||||
|
|
|
@ -18,22 +18,26 @@ export default class TableOfContents extends Combine {
|
|||
}) {
|
||||
let titles: Title[]
|
||||
if (elements instanceof Combine) {
|
||||
titles = TableOfContents.getTitles(elements.getElements())
|
||||
titles = TableOfContents.getTitles(elements.getElements()) ?? []
|
||||
} else {
|
||||
titles = elements
|
||||
titles = elements ?? []
|
||||
}
|
||||
|
||||
|
||||
let els: { level: number, content: BaseUIElement }[] = []
|
||||
for (const title of titles) {
|
||||
let content: BaseUIElement
|
||||
console.log("Constructing content for ", title)
|
||||
if (title.title instanceof Translation) {
|
||||
content = title.title.Clone()
|
||||
} else if (title.title instanceof FixedUiElement) {
|
||||
content = title.title
|
||||
content = new FixedUiElement(title.title.content)
|
||||
} else if (Utils.runningFromConsole) {
|
||||
content = new FixedUiElement(title.AsMarkdown())
|
||||
} else {
|
||||
} else if(title["title"] !== undefined) {
|
||||
content = new FixedUiElement(title.title.ConstructElement().innerText)
|
||||
}else{
|
||||
console.log("Not generating a title for ", title)
|
||||
continue
|
||||
}
|
||||
|
||||
const vis = new Link(content, "#" + title.id)
|
||||
|
|
|
@ -25,17 +25,36 @@ export class Accordeon extends Combine {
|
|||
export default class Toggleable extends Combine {
|
||||
public readonly isVisible = new UIEventSource(false)
|
||||
|
||||
constructor(title: Title | BaseUIElement, content: BaseUIElement) {
|
||||
constructor(title: Title | Combine | BaseUIElement, content: BaseUIElement, options?: {
|
||||
closeOnClick: true | boolean
|
||||
}) {
|
||||
super([title, content])
|
||||
content.SetClass("animate-height border-l-4 pl-2 block")
|
||||
title.SetClass("background-subtle rounded-lg")
|
||||
const self = this
|
||||
this.onClick(() => self.isVisible.setData(!self.isVisible.data))
|
||||
this.onClick(() => {
|
||||
if(self.isVisible.data){
|
||||
if(options?.closeOnClick ?? true){
|
||||
self.isVisible.setData(false)
|
||||
}
|
||||
}else{
|
||||
self.isVisible.setData(true)
|
||||
}
|
||||
})
|
||||
const contentElement = content.ConstructElement()
|
||||
|
||||
if(title instanceof Combine){
|
||||
for(const el of title.getElements()){
|
||||
if(el instanceof Title){
|
||||
title = el;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (title instanceof Title) {
|
||||
Hash.hash.addCallbackAndRun(h => {
|
||||
if (h === title.id) {
|
||||
if (h === (<Title> title).id) {
|
||||
self.isVisible.setData(true)
|
||||
content.RemoveClass("border-gray-300")
|
||||
content.SetClass("border-red-300")
|
||||
|
@ -46,14 +65,14 @@ export default class Toggleable extends Combine {
|
|||
})
|
||||
this.isVisible.addCallbackAndRun(isVis => {
|
||||
if (isVis) {
|
||||
Hash.hash.setData(title.id)
|
||||
Hash.hash.setData((<Title>title).id)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
this.isVisible.addCallbackAndRun(isVisible => {
|
||||
if (isVisible) {
|
||||
contentElement.style.maxHeight = "50vh"
|
||||
contentElement.style.maxHeight = "100vh"
|
||||
contentElement.style.overflowY = "auto"
|
||||
contentElement.style["-webkit-mask-image"] = "unset"
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue