diff --git a/data.js b/data.js index 2985bd0..98a9a10 100644 --- a/data.js +++ b/data.js @@ -13,6 +13,13 @@ let steps = { type: "" } }, + language: { + title: "V jakém jazyce budete práci tvořit?", + layout: language_layout, + result: { + lang: "cs" + } + }, thesis_title: { title: "Jak se bude práce jmenovat?", layout: thesis_title_layout, @@ -118,6 +125,15 @@ const theses = { } } +const languages = { + "cs": { + name: "Čeština" + }, + "en": { + name: "Angličtina" + } +} + const pronounss = { "masculine": { name: "Mužský rod" @@ -135,6 +151,7 @@ const typst_header = `#import "template/template.typ": * #show: tultemplate2.with( faculty: "{faculty.name}", document: "{thesis_type.type}", + lang: "{language.lang}", title: (cs: "{thesis_title.cs}", en: "{thesis_title.en}"), author: "{author_info.name}", author_pronouns: "{author_info.pronouns}", diff --git a/styles.css b/styles.css index d992e1f..c03ad46 100644 --- a/styles.css +++ b/styles.css @@ -134,6 +134,10 @@ button:hover, .button:hover { background-color: white; } +button.wide, .button.wide { + width: 100%; +} + button.narrow, .button.narrow { padding: 4px 16px; font-size: 16px; diff --git a/ui.js b/ui.js index b956e9f..81b722f 100644 --- a/ui.js +++ b/ui.js @@ -43,6 +43,25 @@ async function thesis_layout(content, result) { } } +async function language_layout(content, result) { + if(!Object.keys(languages).includes(result.lang)) { + document.querySelector("#next-button").disabled = true; + } + + let buttons = new ButtonListBuilder(Object.keys(languages)) + .should_be_pressed((key) => result.lang == key) + .modify((b, key) => b.class("wide").text(languages[key].name)) + .on_click((key) => { + result.lang = key; + document.querySelector("#next-button").disabled = false; + }) + .finish(); + + for(const button of buttons) { + content.appendChild(button); + } +} + async function thesis_title_layout(content, result) { content.appendChild(new TextInputBuilder(result, "cs") .placeholder("Název práce (v češtině)")