Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(standalone/setup): start working on language selection page
Elian Doran680ac8052689
diff --git a/apps/client/src/setup.css b/apps/client/src/setup.cssindex 920dc2f254..d373ff19c7 100644--- a/apps/client/src/setup.css+++ b/apps/client/src/setup.css@@ -30,8 +30,8 @@ body.setup {display: flex;flex-direction: column;gap: 2rem;- height: 650px;- width: 800px;+ height: 600px;+ width: 700px;box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);overflow: hidden;position: relative;@@ -107,6 +107,7 @@ body.setup {display: flex;flex-direction: column;padding-top: 1em;+ min-height: 0;}&.contentless {@@ -312,6 +313,23 @@ body.setup {animation-name: slide-in-left;}+.page.select-language {+ .dropdownWrapper {+ padding-bottom: 1.5em;+ }++ .dropdownWrapper,+ .dropdown,+ .dropdown-menu {+ height: 100%;+ }++ .dropdown-menu {+ box-sizing: border-box;+ overflow: auto;+ }+}+.page.sync-in-progress {.sync-progress {margin-top: 0.5rem;diff --git a/apps/client/src/setup.tsx b/apps/client/src/setup.tsxindex eae8b42317..dcd4f877e3 100644--- a/apps/client/src/setup.tsx+++ b/apps/client/src/setup.tsx@@ -1,9 +1,10 @@import "./setup.css";-import { SetupSyncFromServerResponse } from "@triliumnext/commons";+import { LOCALES, SetupSyncFromServerResponse } from "@triliumnext/commons";import clsx from "clsx";import { ComponentChildren, render } from "preact";-import { useEffect, useRef, useState } from "preact/hooks";+import { useEffect, useMemo, useRef, useState } from "preact/hooks";+import { useTranslation } from "react-i18next";import logo from "./assets/icon-color.svg?url";import { initLocale, t } from "./services/i18n";@@ -14,6 +15,7 @@ import Admonition from "./widgets/react/Admonition";import Button from "./widgets/react/Button";import { Card, CardFrame, CardSection } from "./widgets/react/Card";import FormGroup from "./widgets/react/FormGroup";+import FormList, { FormListItem } from "./widgets/react/FormList";import FormTextBox from "./widgets/react/FormTextBox";import Icon from "./widgets/react/Icon";@@ -27,12 +29,13 @@ async function main() {document.body.replaceChildren(bodyWrapper);}-type State = "firstOptions" | "createNewDocumentOptions" | "createNewDocumentWithDemo" | "createNewDocumentEmpty" | "syncFromDesktop" | "syncFromServer" | "syncInProgress" | "syncFailed";+type State = "selectLanguage" | "firstOptions" | "createNewDocumentOptions" | "createNewDocumentWithDemo" | "createNewDocumentEmpty" | "syncFromDesktop" | "syncFromServer" | "syncInProgress" | "syncFailed";-const STATE_ORDER: State[] = ["firstOptions", "createNewDocumentOptions", "createNewDocumentWithDemo", "createNewDocumentEmpty", "syncFromDesktop", "syncFromServer", "syncInProgress", "syncFailed"];+const STATE_ORDER: State[] = ["selectLanguage", "firstOptions", "createNewDocumentOptions", "createNewDocumentWithDemo", "createNewDocumentEmpty", "syncFromDesktop", "syncFromServer", "syncInProgress", "syncFailed"];function renderState(state: State, setState: (state: State) => void) {switch (state) {+ case "selectLanguage": return <SelectLanguage />;case "firstOptions": return <SetupOptions setState={setState} />;case "createNewDocumentOptions": return <CreateNewDocumentOptions setState={setState} />;case "createNewDocumentWithDemo": return <CreateNewDocumentInProgress withDemo />;@@ -45,7 +48,7 @@ function renderState(state: State, setState: (state: State) => void) {}function App() {- const [state, setState] = useState<State>("firstOptions");+ const [state, setState] = useState<State>("selectLanguage");const [prevState, setPrevState] = useState<State | null>(null);const [transitioning, setTransitioning] = useState(false);const prevStateRef = useRef<State>(state);@@ -81,6 +84,31 @@ function App() {);}+function SelectLanguage() {+ const [ currentLocale, setCurrentLocale ] = useState("en");+ const filteredLocales = useMemo(() => LOCALES.filter(l => !l.contentOnly), []);+ const { t, i18n } = useTranslation();+ console.log("Rendering with ", currentLocale, t("setup.language"));++ return (+ <SetupPage+ title={t("setup.language")}+ className="select-language"+ illustration={<Icon icon="bx bx-globe" className="illustration-icon" />}+ footer={<Button text={t("setup.continue")} kind="primary" />}+ >+ <FormList onSelect={async (id) => {+ await i18n.changeLanguage(id);+ setCurrentLocale(id);+ }}>+ {filteredLocales.map(locale => (+ <FormListItem key={locale.id} value={locale.id} active={locale.id === currentLocale}>{locale.name}</FormListItem>+ ))}+ </FormList>+ </SetupPage>+ );+}+function SetupOptions({ setState }: { setState: (state: State) => void }) {return (<SetupPagediff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 03d11a313e..95d4c9a867 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -2277,6 +2277,8 @@"proxy-server-placeholder": "https://<hostname>:<port>","proxy-instruction": "If you leave proxy setting blank, system proxy will be used.","dismiss-error": "Dismiss error",- "wrong-password": "Incorrect password. Please try again."+ "wrong-password": "Incorrect password. Please try again.",+ "language": "Language",+ "continue": "Continue"}}