From e7701f4b7d27b844fd4cf2a2c8e9bcb6e8d85de6 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Thu, 10 Feb 2022 11:27:34 +0400 Subject: [PATCH] language selector, but not quite workinhg yet --- README.md | 6 ++-- components/BookInfoInput.tsx | 44 +++++++++++++++++++--------- components/LanguageSelect.tsx | 54 +++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 17 deletions(-) create mode 100644 components/LanguageSelect.tsx diff --git a/README.md b/README.md index 91b57a5..2e3daf6 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Easily create EPUB e-book files with proper RTL support. This is a web app that uses [pandoc](https://pandoc.org) to create .epub files for e-books in RTL languages. Making RTL e-books can be tricky. This tries app tries to simplify the process as much as possible, so that anyone can make them. -[Try it live - RTL EPUB Maker](https://rtl-epub-maker.lingdocs.com) +### [Try it live - RTL EPUB Maker 📚](https://rtl-epub-maker.lingdocs.com) ## Running @@ -39,7 +39,7 @@ If you are using `linux/amd64` architecture you can just run the [the docker ima docker compose up ``` -If you are using an architecture other than `linux/amd64` you will need to build your own Docker image. +If you are using an architecture other than `linux/amd64` you will need to build your own docker image. ```sh docker build . -t rtl-epub-maker @@ -52,4 +52,4 @@ The app will be served on `http://localhost:3001`. Add a reverse proxy with SSL --- -Code is licensed under a [MIT License](https://github.com/lingdocs/rtl-epub-maker/blob/master/LICENSE). Contributions are welcome. +Code is licensed under an [MIT License](https://github.com/lingdocs/rtl-epub-maker/blob/master/LICENSE). Contributions are welcome. diff --git a/components/BookInfoInput.tsx b/components/BookInfoInput.tsx index 9e29d2f..befb9fe 100644 --- a/components/BookInfoInput.tsx +++ b/components/BookInfoInput.tsx @@ -1,5 +1,6 @@ import { ChangeEvent, useState, useRef } from "react"; import Select from "react-select"; +import LanguageSelect from "./LanguageSelect"; const requiredFields = [ "title", @@ -20,8 +21,7 @@ type Option = { label: string, }; -const baseSettings = { - language: "ps-AF", +const baseSettings = { dir: "rtl", "page-progression-direction": "rtl", }; @@ -55,6 +55,21 @@ function BookInfoInput({ handleSubmit }: { handleSubmit: (info: { frontmatter: F [name]: value, })); } + function handleLanguageChange(lang: string | null) { + setState(s => { + if (!lang) { + delete s.lang; + delete s.language; + return s + } + return { + ...s, + // TODO: using both, but which is proper/necessary? + lang, + language: lang, + }; + }); + } function submit() { const cover = coverRef.current.files[0] as (File | undefined); handleSubmit({ @@ -65,24 +80,24 @@ function BookInfoInput({ handleSubmit }: { handleSubmit: (info: { frontmatter: F cover, }); } + console.log(state); + console.log("will render"); return