forked from MapComplete/MapComplete
Graciously handle multiple entries in wikidata for fetching images and showing articles, verious bug fixes
This commit is contained in:
parent
8d52ef1106
commit
a996ba2a7c
14 changed files with 231 additions and 90 deletions
|
@ -6,11 +6,16 @@ import {VariableUiElement} from "./VariableUIElement";
|
|||
|
||||
export class TabbedComponent extends Combine {
|
||||
|
||||
constructor(elements: { header: BaseUIElement | string, content: BaseUIElement | string }[], openedTab: (UIEventSource<number> | number) = 0) {
|
||||
constructor(elements: { header: BaseUIElement | string, content: BaseUIElement | string }[],
|
||||
openedTab: (UIEventSource<number> | number) = 0,
|
||||
options?: {
|
||||
leftOfHeader?: BaseUIElement
|
||||
styleHeader?: (header: BaseUIElement) => void
|
||||
}) {
|
||||
|
||||
const openedTabSrc = typeof (openedTab) === "number" ? new UIEventSource(openedTab) : (openedTab ?? new UIEventSource<number>(0))
|
||||
|
||||
const tabs: BaseUIElement[] = []
|
||||
const tabs: BaseUIElement[] = [options?.leftOfHeader ]
|
||||
const contentElements: BaseUIElement[] = [];
|
||||
for (let i = 0; i < elements.length; i++) {
|
||||
let element = elements[i];
|
||||
|
@ -25,16 +30,19 @@ export class TabbedComponent extends Combine {
|
|||
}
|
||||
})
|
||||
const content = Translations.W(element.content)
|
||||
content.SetClass("relative p-4 w-full inline-block")
|
||||
content.SetClass("relative w-full inline-block")
|
||||
contentElements.push(content);
|
||||
const tab = header.SetClass("block tab-single-header")
|
||||
tabs.push(tab)
|
||||
}
|
||||
|
||||
const header = new Combine(tabs).SetClass("tabs-header-bar")
|
||||
if(options?.styleHeader){
|
||||
options.styleHeader(header)
|
||||
}
|
||||
const actualContent = new VariableUiElement(
|
||||
openedTabSrc.map(i => contentElements[i])
|
||||
)
|
||||
).SetStyle("max-height: inherit; height: inherit")
|
||||
super([header, actualContent])
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue