mapcomplete/UI/BigComponents/ThemeIntroductionPanel.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

90 lines
3.3 KiB
TypeScript
Raw Normal View History

import Combine from "../Base/Combine"
import LanguagePicker from "../LanguagePicker"
import Translations from "../i18n/Translations"
2021-06-12 02:58:32 +02:00
import Toggle from "../Input/Toggle"
2021-06-16 21:23:03 +02:00
import { SubtleButton } from "../Base/SubtleButton"
import { Store, UIEventSource } from "../../Logic/UIEventSource"
2022-01-12 02:31:51 +01:00
import { LoginToggle } from "../Popup/LoginButton"
import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig"
import { OsmConnection } from "../../Logic/Osm/OsmConnection"
import LoggedInUserIndicator from "../LoggedInUserIndicator"
import { ActionButtons } from "./ActionButtons"
import { BBox } from "../../Logic/BBox"
import Loc from "../../Models/Loc"
export default class ThemeIntroductionPanel extends Combine {
constructor(
isShown: UIEventSource<boolean>,
currentTab: UIEventSource<number>,
state: {
featureSwitchMoreQuests: UIEventSource<boolean>
featureSwitchAddNew: UIEventSource<boolean>
featureSwitchUserbadge: UIEventSource<boolean>
layoutToUse: LayoutConfig
osmConnection: OsmConnection
currentBounds: Store<BBox>
locationControl: UIEventSource<Loc>
isTranslator: Store<boolean>
},
guistate?: { userInfoIsOpened: UIEventSource<boolean> }
) {
2022-01-12 02:31:51 +01:00
const t = Translations.t.general
const layout = state.layoutToUse
2021-06-12 02:58:32 +02:00
const languagePicker = new LanguagePicker(layout.language, t.pickLanguage.Clone())
2021-06-16 21:23:03 +02:00
const toTheMap = new SubtleButton(
undefined,
2022-01-12 02:31:51 +01:00
t.openTheMap.Clone().SetClass("text-xl font-bold w-full text-center")
)
.onClick(() => {
2021-06-16 21:23:03 +02:00
isShown.setData(false)
})
.SetClass("only-on-mobile")
2021-06-12 02:58:32 +02:00
const loggedInUserInfo = new LoggedInUserIndicator(state.osmConnection, {
firstLine: Translations.t.general.welcomeBack.Clone(),
})
if (guistate?.userInfoIsOpened) {
loggedInUserInfo.onClick(() => {
guistate.userInfoIsOpened.setData(true)
})
}
2021-06-12 02:58:32 +02:00
const loginStatus = new Toggle(
2022-01-12 02:31:51 +01:00
new LoginToggle(
loggedInUserInfo,
new Combine([
2022-01-12 02:31:51 +01:00
Translations.t.general.loginWithOpenStreetMap.SetClass("text-xl font-bold"),
Translations.t.general.loginOnlyNeededToEdit.Clone().SetClass("font-bold"),
]).SetClass("flex flex-col"),
2022-09-08 21:40:48 +02:00
state
),
undefined,
state.featureSwitchUserbadge
2021-01-07 04:50:12 +01:00
)
const hasPresets = layout.layers.some((l) => l.presets?.length > 0)
super([
layout.description.Clone().SetClass("block mb-4"),
new Combine([
t.welcomeExplanation.general,
hasPresets
? Toggle.If(state.featureSwitchAddNew, () => t.welcomeExplanation.addNew)
: undefined,
]).SetClass("flex flex-col mt-2"),
2022-09-08 21:40:48 +02:00
2021-06-16 21:23:03 +02:00
toTheMap,
loginStatus.SetClass("block mt-6 pt-2 md:border-t-2 border-dotted border-gray-400"),
layout.descriptionTail?.Clone().SetClass("block mt-4"),
2022-09-08 21:40:48 +02:00
languagePicker?.SetClass("block mt-4 pb-8 border-b-2 border-dotted border-gray-400"),
new ActionButtons(state),
2022-09-08 21:40:48 +02:00
...layout.CustomCodeSnippets(),
])
2021-06-12 02:58:32 +02:00
this.SetClass("link-underline")
}
2020-11-24 14:36:43 +01:00
}