Add attribution for plantnet, styling tweaks

This commit is contained in:
Pieter Vander Vennet 2022-08-23 16:15:53 +02:00
parent b1ea986515
commit d713e00671
6 changed files with 91 additions and 32 deletions

View file

@ -9,6 +9,8 @@ import Combine from "../Base/Combine";
import Title from "../Base/Title";
import WikipediaBox from "../Wikipedia/WikipediaBox";
import Translations from "../i18n/Translations";
import List from "../Base/List";
import Svg from "../../Svg";
export default class PlantNetSpeciesSearch extends VariableUiElement {
@ -28,8 +30,15 @@ export default class PlantNetSpeciesSearch extends VariableUiElement {
return UIEventSource.FromPromiseWithErr(PlantNet.query(images.slice(0,5)));
})
.map(result => {
if (result === null) {
return t.takeImages
if (images.data.length === 0) {
return new Combine([t.takeImages, t.howTo.intro, new List(
[
t.howTo.li0,
t.howTo.li1,
t.howTo.li2,
t.howTo.li3
]
)]).SetClass("flex flex-col")
}
if (result === undefined) {
return new Loading(t.querying.Subs(images.data))
@ -79,13 +88,21 @@ export default class PlantNetSpeciesSearch extends VariableUiElement {
return plantOverview
}
const buttons = new Combine([
new Button("Confirm", () => {
new Button(
new Combine([
Svg.back_svg().SetClass("w-4"),
t.back]).SetClass("flex"),
() => {
selectedSpecies.setData(undefined)
}).SetClass("btn btn-secondary"),
new Button(
new Combine([Svg.confirm_svg().SetClass("w-4"), t.confirm]).SetClass("flex")
, () => {
onConfirm(wikidataSpecies)
}).SetClass("btn"),
new Button("Back to plant overview", () => {
selectedSpecies.setData(undefined)
}).SetClass("btn btn-secondary")
]).SetClass("flex self-end");
]).SetClass("flex justify-between");
return new Combine([
new WikipediaBox([wikidataSpecies], {

View file

@ -1318,7 +1318,7 @@ export default class SpecialVisualizations {
}
const detect = new UIEventSource(false)
return new Toggle(
const toggle = new Toggle(
new Lazy(() => {
const allProvidedImages: Store<ProvidedImage[]> = AllImageProviders.LoadImagesFor(tags, imagePrefixes)
const allImages: Store<string[]> = allProvidedImages.map(pi => pi.map(pi => pi.url))
@ -1340,6 +1340,13 @@ export default class SpecialVisualizations {
new SubtleButton(undefined, "Detect plant species with plantnet.org").onClick(() => detect.setData(true)),
detect
)
return new Combine([
toggle,
new Combine([Svg.plantnet_logo_svg().SetClass("w-8"),
Translations.t.plantDetection.poweredByPlantnet])
.SetClass("flex p-2 bg-gray-200 rounded-xl self-end")
]).SetClass("flex flex-col")
}
}
]