Small fixes to the Slideshow

This commit is contained in:
Pieter Vander Vennet 2021-06-17 13:17:16 +02:00
parent d443c7ecb0
commit 7b52dee320
6 changed files with 36 additions and 22 deletions

View file

@ -6,6 +6,7 @@ import Combine from "../Base/Combine";
import Attribution from "./Attribution";
import BaseUIElement from "../BaseUIElement";
import Img from "../Base/Img";
import {VariableUiElement} from "../Base/VariableUIElement";
export class ImgurImage extends UIElement {
@ -19,7 +20,7 @@ export class ImgurImage extends UIElement {
private readonly _imageLocation: string;
constructor(source: string) {
super(undefined)
super()
this._imageLocation = source;
if (ImgurImage.allLicenseInfos[source] !== undefined) {
this._imageMeta = ImgurImage.allLicenseInfos[source];
@ -31,25 +32,15 @@ export class ImgurImage extends UIElement {
self._imageMeta.setData(license)
})
}
this.ListenTo(this._imageMeta);
}
InnerRender(): BaseUIElement {
const image = new Img( this._imageLocation);
if(this._imageMeta.data === null){
return image;
}
const meta = this._imageMeta.data;
return new Combine([
image,
new Attribution(meta.artist, meta.license, undefined),
]).SetClass('block relative')
;
new VariableUiElement(this._imageMeta.map(meta => (meta === undefined || meta === null) ? undefined : new Attribution(meta.artist, meta.license, undefined)))
]).SetClass('block relative h-full');
}

View file

@ -53,7 +53,7 @@ export class MapillaryImage extends UIElement {
return new Combine([
image,
new Attribution(meta.artist, meta.license, Svg.mapillary_svg())
]).SetClass("relative block");
]).SetClass("relative block h-full");
}

View file

@ -1,5 +1,7 @@
import {UIEventSource} from "../../Logic/UIEventSource";
import BaseUIElement from "../BaseUIElement";
import {Utils} from "../../Utils";
import Combine from "../Base/Combine";
export class SlideShow extends BaseUIElement {
@ -8,7 +10,7 @@ export class SlideShow extends BaseUIElement {
constructor(embeddedElements: UIEventSource<BaseUIElement[]>) {
super()
this.embeddedElements = embeddedElements;
this.embeddedElements =embeddedElements;
}
protected InnerConstructElement(): HTMLElement {
@ -23,11 +25,12 @@ export class SlideShow extends BaseUIElement {
el.removeChild(el.lastChild)
}
elements = Utils.NoNull(elements).map(el => new Combine([el])
.SetClass("block relative ml-1 bg-gray-200 m-1 rounded slideshow-item")
.SetStyle("min-width: 150px; width: max-content; height: var(--image-carousel-height);max-height: var(--image-carousel-height);")
)
for (const element of elements ?? []) {
element
.SetClass("block ml-1; bg-gray-200")
.SetStyle("min-width: 150; max-height: var(--image-carousel-height); min-height: var(--image-carousel-height)")
el.appendChild(element.ConstructElement())
}
});

View file

@ -51,7 +51,7 @@ export class WikimediaImage extends UIElement {
return new Combine([
image,
new Attribution(meta.artist, meta.license, Svg.wikimedia_commons_white_svg())
]).SetClass("relative block")
]).SetClass("relative block h-full")
}