forked from MapComplete/MapComplete
LanguagePicker now has a proper constructor
This commit is contained in:
parent
8047f69fea
commit
51a6756dd4
6 changed files with 29 additions and 30 deletions
|
@ -5,7 +5,7 @@ import MoreScreen from "./BigComponents/MoreScreen";
|
||||||
import Translations from "./i18n/Translations";
|
import Translations from "./i18n/Translations";
|
||||||
import Constants from "../Models/Constants";
|
import Constants from "../Models/Constants";
|
||||||
import {Utils} from "../Utils";
|
import {Utils} from "../Utils";
|
||||||
import LanguagePicker from "./LanguagePicker";
|
import LanguagePicker1 from "./LanguagePicker";
|
||||||
import IndexText from "./BigComponents/IndexText";
|
import IndexText from "./BigComponents/IndexText";
|
||||||
import FeaturedMessage from "./BigComponents/FeaturedMessage";
|
import FeaturedMessage from "./BigComponents/FeaturedMessage";
|
||||||
import Toggle from "./Input/Toggle";
|
import Toggle from "./Input/Toggle";
|
||||||
|
@ -21,7 +21,7 @@ export default class AllThemesGui {
|
||||||
const state = new UserRelatedState(undefined);
|
const state = new UserRelatedState(undefined);
|
||||||
const intro = new Combine([
|
const intro = new Combine([
|
||||||
|
|
||||||
LanguagePicker.CreateLanguagePicker(Translations.t.index.title.SupportedLanguages())
|
new LanguagePicker1(Translations.t.index.title.SupportedLanguages(), "")
|
||||||
|
|
||||||
.SetClass("flex absolute top-2 right-3"),
|
.SetClass("flex absolute top-2 right-3"),
|
||||||
new IndexText()
|
new IndexText()
|
||||||
|
|
|
@ -9,7 +9,6 @@ import Svg from "../../Svg";
|
||||||
import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig";
|
import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig";
|
||||||
import {OsmConnection} from "../../Logic/Osm/OsmConnection";
|
import {OsmConnection} from "../../Logic/Osm/OsmConnection";
|
||||||
import FullWelcomePaneWithTabs from "./FullWelcomePaneWithTabs";
|
import FullWelcomePaneWithTabs from "./FullWelcomePaneWithTabs";
|
||||||
import Title from "../Base/Title";
|
|
||||||
|
|
||||||
export default class ThemeIntroductionPanel extends Combine {
|
export default class ThemeIntroductionPanel extends Combine {
|
||||||
|
|
||||||
|
@ -17,7 +16,7 @@ export default class ThemeIntroductionPanel extends Combine {
|
||||||
const t = Translations.t.general
|
const t = Translations.t.general
|
||||||
const layout = state.layoutToUse
|
const layout = state.layoutToUse
|
||||||
|
|
||||||
const languagePicker = LanguagePicker.CreateLanguagePicker(layout.language, t.pickLanguage.Clone())
|
const languagePicker = new LanguagePicker(layout.language, t.pickLanguage.Clone())
|
||||||
|
|
||||||
const toTheMap = new SubtleButton(
|
const toTheMap = new SubtleButton(
|
||||||
undefined,
|
undefined,
|
||||||
|
|
|
@ -39,7 +39,7 @@ export default class UserBadge extends LoginToggle {
|
||||||
});
|
});
|
||||||
|
|
||||||
const linkStyle = "flex items-baseline"
|
const linkStyle = "flex items-baseline"
|
||||||
const languagePicker = (LanguagePicker.CreateLanguagePicker(state.layoutToUse.language) ?? new FixedUiElement(""))
|
const languagePicker = (new LanguagePicker(state.layoutToUse.language, "") ?? new FixedUiElement(""))
|
||||||
.SetStyle("width:min-content;");
|
.SetStyle("width:min-content;");
|
||||||
|
|
||||||
let messageSpan =
|
let messageSpan =
|
||||||
|
|
|
@ -62,7 +62,7 @@ export default class ImportHelperGui extends LeftIndex {
|
||||||
}),
|
}),
|
||||||
toc,
|
toc,
|
||||||
new Toggle(t.testMode.SetClass("block alert"), undefined, state.featureSwitchIsTesting),
|
new Toggle(t.testMode.SetClass("block alert"), undefined, state.featureSwitchIsTesting),
|
||||||
LanguagePicker.CreateLanguagePicker(Translations.t.importHelper.title.SupportedLanguages())?.SetClass("mt-4 self-end flex-col"),
|
new LanguagePicker(Translations.t.importHelper.title.SupportedLanguages(), "")?.SetClass("mt-4 self-end flex-col"),
|
||||||
].map(el => el?.SetClass("pl-4"))
|
].map(el => el?.SetClass("pl-4"))
|
||||||
|
|
||||||
super(
|
super(
|
||||||
|
|
|
@ -8,12 +8,12 @@ import * as used_languages from "../assets/generated/used_languages.json"
|
||||||
import Lazy from "./Base/Lazy";
|
import Lazy from "./Base/Lazy";
|
||||||
import Toggle from "./Input/Toggle";
|
import Toggle from "./Input/Toggle";
|
||||||
|
|
||||||
export default class LanguagePicker {
|
export default class LanguagePicker extends Toggle {
|
||||||
|
|
||||||
|
|
||||||
public static CreateLanguagePicker(
|
constructor(languages: string[],
|
||||||
languages: string[],
|
label: string | BaseUIElement = "") {
|
||||||
label: string | BaseUIElement = "") : BaseUIElement{
|
|
||||||
|
|
||||||
if (languages === undefined || languages.length <= 1) {
|
if (languages === undefined || languages.length <= 1) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -23,7 +23,7 @@ export default class LanguagePicker {
|
||||||
|
|
||||||
const normalPicker = LanguagePicker.dropdownFor(languages, label);
|
const normalPicker = LanguagePicker.dropdownFor(languages, label);
|
||||||
const fullPicker = new Lazy(() => LanguagePicker.dropdownFor(allLanguages, label))
|
const fullPicker = new Lazy(() => LanguagePicker.dropdownFor(allLanguages, label))
|
||||||
return new Toggle(fullPicker, normalPicker, Locale.showLinkToWeblate)
|
super(fullPicker, normalPicker, Locale.showLinkToWeblate);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static dropdownFor(languages: string[], label: string | BaseUIElement): BaseUIElement {
|
private static dropdownFor(languages: string[], label: string | BaseUIElement): BaseUIElement {
|
||||||
|
|
|
@ -98,7 +98,7 @@ class ProfessionalGui extends LeftIndex {
|
||||||
maxDepth: 2
|
maxDepth: 2
|
||||||
}).SetClass("subtle"),
|
}).SetClass("subtle"),
|
||||||
|
|
||||||
LanguagePicker.CreateLanguagePicker(Translations.t.professional.title.SupportedLanguages())?.SetClass("mt-4 self-end flex-col"),
|
new LanguagePicker(Translations.t.professional.title.SupportedLanguages(), "")?.SetClass("mt-4 self-end flex-col"),
|
||||||
].map(el => el?.SetClass("pl-4"))
|
].map(el => el?.SetClass("pl-4"))
|
||||||
|
|
||||||
super(leftContents, content)
|
super(leftContents, content)
|
||||||
|
|
Loading…
Add table
Reference in a new issue