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
{fields.map((field) => ( -
-
- - -
+
+ +
))}
add fields:
@@ -97,6 +112,7 @@ function BookInfoInput({ handleSubmit }: { handleSubmit: (info: { frontmatter: F // @ts-ignore options={availableFieldsOptions} /> +
} diff --git a/components/LanguageSelect.tsx b/components/LanguageSelect.tsx new file mode 100644 index 0000000..56146da --- /dev/null +++ b/components/LanguageSelect.tsx @@ -0,0 +1,54 @@ +import Select from "react-select"; +import { useState } from "react"; + +const languageOptions = [ + { value: "ar", label: "Arabic" }, + { value: "fa", label: "Farsi" }, + { value: "prs", label: "Dari" }, + { value: "ps", label: "Pashto" }, + { value: "ps-AF", label: "Pashto (Afghanistan) "}, + { value: "ps-PK", label: "Pashto (Pakistan) "}, + { value: "ur", label: "Urdu" }, + { value: "other", label: "Other..." }, +]; + +function LanguageSelect({ value, onChange }: { + value: string | null, + onChange: (language: string | null) => void, +}) { + const [showingOther, setShowingOther] = useState(false); + function handleChange(o: { value: string, label: string }) { + if (!o) { + onChange(null); + } else if (o.value === "other") { + setShowingOther(true); + onChange(null); + } else { + if (showingOther) setShowingOther(false); + onChange(o.value); + } + } + return
+
language:
+ onChange(e.target.value)} type="text" className="form-control" id="otherLang" /> +
} +
; +} + +export default LanguageSelect; \ No newline at end of file