diff options
Diffstat (limited to 'book/book.js')
-rw-r--r-- | book/book.js | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/book/book.js b/book/book.js new file mode 100644 index 00000000..84c0e9dc --- /dev/null +++ b/book/book.js @@ -0,0 +1,90 @@ + +const tr = t => ({ translated: t }) +const plain = t => ({ text: t }) +const par_raw = (s, th, bold) => ({ + t: "par", es: [{ + t: "text", + s, + color: th ? "#ffffff" : "#000000", + size: 15, + bold, + font: "FreeSans" + }] +}) +const par = (t, th, bold) => par_raw(tr(t), th, bold) +const h2 = (t, th) => ({ + t: "text", + s: tr(t), + color: th ? "#ffffff" : "#000000", + size: 40, + font: "Great Vibes" +}) +const emph = (t, th) => ({ + t: "text", + s: tr(t), + color: th ? "#95bd51" : "#2e4900", + size: 20, + font: "Gluten" +}) +const title = () => ({ + t: "page", background: "cover", es: [ + { t: "text", s: tr("b.title"), size: 70, color: "#000000", font: "Great Vibes" } + ] +}) +const toc = () => ({ + t: "page", background: "toc", es: [ + { t: "text", s: plain("TODO: Table of contents"), size: 20, font: "FreeSans", color: "#000000" } + ] +}) +const about = () => ({ + t: "page", es: [ + { t: "text", s: tr("b.about"), color: "#000000", size: 30, font: "FreeSans" }, + par("b.about.name"), + { t: "text", s: tr("b.about.image_attrib"), color: "#000000", size: 20, font: "FreeSans" }, + { + t: "table", cols: 2, es: [ + [par("b.about.image_attrib.name", false, true), par("b.about.image_attrib.author", false, true)], + [par("b.nigiri"), par_raw(plain("Ahtziri Lagarde(unsplash)"))], + [par("b.icecream"), par_raw(plain("Markus Spiske(unsplash), adapted"))], + [par("b.curry"), par_raw(plain("Andy Hay(unsplash), adapted"))], + [par("b.mochi"), par_raw(plain("blackieshoot(unsplash)"))], + [par("b.burger"), par_raw(plain("Pablo Merchán Montes(unsplash), adapted"))], + [par("b.tomato_soup"), par_raw(plain("Julia Kicova(unsplash), adapted"))], + ] + } + ] +}) +const recipe = (n, i, th = false, extra = []) => ({ + t: "page", background: n, es: [ + h2(`b.${n}`, th), + par(`b.${n}.desc`, th), + { + t: "list", es: i.map(e => emph(`b.ingred.${e}`, th)) + }, + par(`b.${n}.steps`, th), + ...extra + ] +}) + +console.log(JSON.stringify({ + t: "document", es: [ + title(), + toc(), + recipe("tomato_soup", ["leek", "tomato"]), + recipe("bun", ["flour"], true), + recipe("burger", ["lettuce", "tomato", "cheese", "steak", "bun"], true, [par("b.burger.variation", true)]), + recipe("mochi", ["rice", "strawberry"], true), + recipe("curry", ["coconut", "tomato", "leek", "rice"], true), + recipe("icecream", ["strawberry", "coconut"]), + recipe("nigiri", ["fish", "rice"]), + { + t: "page", background: "drinks", es: [ + { t: "text", s: tr(`b.water`), color: "#ffffff", size: 30, font: "Great Vibes" }, + par("b.water.steps", true), + { t: "text", s: tr(`b.strawberry_shake`), color: "#ffffff", size: 30, font: "Great Vibes" }, + par("b.strawberry_shake.steps", true), + ] + }, + about() + ] +})) |