From 996f9a20ad329dfc8bb35945b44471bfae315ada Mon Sep 17 00:00:00 2001 From: unwox Date: Fri, 5 Sep 2025 10:24:45 +0600 Subject: small fixes --- pages/index.fnl | 12 +++--- pages/shop/order.fnl | 74 ++++++++++++++++++------------------ pages/shop/success.fnl | 12 +++--- static/style.css | 101 +++++++++++++++++++++++++++++++++++++++++-------- templates.fnl | 14 +++---- 5 files changed, 140 insertions(+), 73 deletions(-) diff --git a/pages/index.fnl b/pages/index.fnl index f0ac111..a7761a2 100644 --- a/pages/index.fnl +++ b/pages/index.fnl @@ -1,4 +1,4 @@ -(import-macros {:compile-html <>} :macros) +(import-macros {:compile-html HTML} :macros) (local lib (require :lib)) (local templates (require :templates)) @@ -23,13 +23,13 @@ (fn pick-gallery-photo [list] (let [chosen (. list (math.random (# list)))] - (<> + (HTML [:div {} - [:a {:href (.. "static/" chosen.name ".webp") :target "_blank"} - [:img {:src (.. "static/" chosen.name "-p.webp") :alt chosen.alt}]]]))) + [:a {:href (.. "static/" chosen.name ".webp") :target "_blank"} ""] + [:img {:src (.. "static/" chosen.name "-p.webp") :alt chosen.alt}]]))) (fn content [authenticated?] - [(<> + [(HTML [:div {:class "side mb-2"} (templates.header "" authenticated?) [:section {:class "mb-2"} @@ -45,7 +45,7 @@ [:div {:class "mb-1"} [:NO-ESCAPE texts.weekly-meetings]] [:div {} [:a {:href "https://t.me/whitetoadtea"} "Подписаться ⟶"]]]]]) - (<> + (HTML [:div {:class "content"} [:div {:class "gallery"} (pick-gallery-photo [{:name "people" :alt "Люди в чайной"} diff --git a/pages/shop/order.fnl b/pages/shop/order.fnl index 6edaf8a..50e12da 100644 --- a/pages/shop/order.fnl +++ b/pages/shop/order.fnl @@ -1,45 +1,47 @@ +(import-macros {:compile-html HTML} :macros) (local lib (require :lib)) (local templates (require :templates)) -(local html (require :vendor.html)) (fn content-template [db basket basket-total] - [[:div {:class "side"} - (templates.header "/shop/order")] - [:div {:class "content"} - (if (< 0 (# basket)) - [:section {} - [:h2 {} "Состав заказа"] - [:div {} - (table.unpack - (icollect [_ item (ipairs basket)] - (templates.basket-item item "/shop/order")))] - [:div {} "~~~"] - [:div {:class "basket-total"} (.. "Итого: " basket-total "₽")]] - "") - [:section {} - [:h2 {} "Данные для связи"] - [:form {:class "form" :method "POST"} - [:div {:class "form-row"} - [:label {:for "name"} "Имя"] - [:input {:type "text" :id "name" :name "name" :required "required"}]] - [:div {:class "form-row"} - [:label {:for "contact"} "Телеграм или Email для связи"] - [:input {:type "text" :id "contact" :name "contact" :required "required"}]] - [:div {:class "form-row"} - [:input {:type "checkbox" :id "everything-is-correct" - :name "everything-is-correct" :required "required"}] - [:label {:for "everything-is-correct"} "Данные заказа верны"]] - [:div {:class "form-row"} - [:input {:type "checkbox" :id "agree-to-conditions" - :name "agree-to-conditions" :required "required"}] - [:label {:for "agree-to-conditions"} "Согласен с условиями"]] - [:button {:type "submit"} "Оформить заказ"]]]]]) + [(HTML + [:div {:class "side"} + (templates.header "/shop/order")]) + (HTML + [:div {:class "content"} + (if (< 0 (# basket)) + [:section {} + [:h2 {} "Состав заказа"] + [:div {} + (table.unpack + (icollect [_ item (ipairs basket)] + (templates.basket-item item "/shop/order")))] + [:div {} "~~~"] + [:div {:class "basket-total"} (.. "Итого: " basket-total "₽")]] + "") + [:section {} + [:h2 {} "Данные для связи"] + [:form {:class "form" :method "POST"} + [:div {:class "form-row"} + [:label {:for "name"} "Имя"] + [:input {:type "text" :id "name" :name "name" :required "required"}]] + [:div {:class "form-row"} + [:label {:for "contact"} "Телеграм или Email для связи"] + [:input {:type "text" :id "contact" :name "contact" :required "required"}]] + [:div {:class "form-row"} + [:input {:type "checkbox" :id "everything-is-correct" + :name "everything-is-correct" :required "required"}] + [:label {:for "everything-is-correct"} "Данные заказа верны"]] + [:div {:class "form-row"} + [:input {:type "checkbox" :id "agree-to-conditions" + :name "agree-to-conditions" :required "required"}] + [:label {:for "agree-to-conditions"} "Согласен с условиями"]] + [:button {:type "submit"} "Оформить заказ"]]]])]) (fn place-order [db order-id form] (_G.must (luna.db.exec db "UPDATE orders SET placement_time = ?, first_name = ?, contact = ?" - [(os.date "%Y-%m-%d %H:%M:%S") form.name form.contact]))) + [(lib.now) form.name form.contact]))) (fn render [request db] (let [order-id (lib.order-id request) @@ -51,11 +53,7 @@ (place-order db order-id (lib.parse-values request.body)) (values 302 {:Location "/shop/success"} "")) (if (< 0 (# basket)) - (values - 200 {} - (html.render - (templates.base (content-template db basket basket-total)) - true)) + (values 200 {} (templates.base (content-template db basket basket-total))) (values 302 {:Location "/shop"} ""))))) {: render} diff --git a/pages/shop/success.fnl b/pages/shop/success.fnl index 2e9abb4..b28f84d 100644 --- a/pages/shop/success.fnl +++ b/pages/shop/success.fnl @@ -1,15 +1,15 @@ +(import-macros {:compile-html HTML} :macros) (local templates (require :templates)) -(local html (require :vendor.html)) (tset _G :package :loaded "pages.shop.success" nil) (fn content [] - [[:div {:class "side"} - (templates.header "/shop/order")] - [:div {:class "content"} - "Спасибо за заказ!"]]) + [(HTML [:div {:class "side"} + (templates.header "/shop/order")]) + (HTML [:div {:class "content"} + "Спасибо за заказ!"])]) (fn render [] - (values 200 {} (html.render (templates.base (content)) true))) + (values 200 {} (templates.base (content)))) {: render} diff --git a/static/style.css b/static/style.css index e31e6d1..adfbe85 100644 --- a/static/style.css +++ b/static/style.css @@ -1,16 +1,68 @@ +@font-face { + font-family: "Open Sans"; + font-weight: 300; + src: url("/static/fonts/OpenSans-Light.ttf") format("truetype"); +} + +@font-face { + font-family: "Open Sans"; + font-weight: regular; + src: url("/static/fonts/OpenSans-Regular.ttf") format("truetype"); +} + +@font-face { + font-family: "Open Sans"; + font-weight: regular; + font-style: italic; + src: url("/static/fonts/OpenSans-RegularItalic.ttf") format("truetype"); +} + +@font-face { + font-family: "Open Sans"; + font-weight: 700; + src: url("/static/fonts/OpenSans-SemiBold.ttf") format("truetype"); +} + +@font-face { + font-family: "Open Sans"; + font-weight: 700; + font-style: italic; + src: url("/static/fonts/OpenSans-SemiBoldItalic.ttf") format("truetype"); +} + +@font-face { + font-family: "Open Sans"; + font-weight: 800; + src: url("/static/fonts/OpenSans-Bold.ttf") format("truetype"); +} + +@font-face { + font-family: "Open Sans"; + font-weight: 800; + font-style: italic; + src: url("/static/fonts/OpenSans-BoldItalic.ttf") format("truetype"); +} + +@font-face { + font-family: "Open Sans"; + font-weight: 900; + src: url("/static/fonts/OpenSans-ExtraBold.ttf") format("truetype"); +} + +@font-face { + font-family: "Open Sans"; + font-weight: 900; + font-style: italic; + src: url("/static/fonts/OpenSans-ExtraBoldItalic.ttf") format("truetype"); +} + body { background: #ffffff; margin: 4rem; - font-family: sans, monospace, sans-serif; + font-family: "Open Sans", sans-serif, sans, monospace; line-height: 1.5; } -@font-face { - font-family: "Bad Script"; - src: local("Bad Script"), - url: ("/static/fonts/BadScript-Regular.ttf") format ("opentype"); -} - * { box-sizing: border-box; } @@ -33,7 +85,7 @@ nav a.active { .container { display: flex; flex-wrap: wrap; - gap: 1rem 2rem; + gap: 0.5rem 2rem; } .logo { @@ -70,6 +122,11 @@ nav a.active { .logo img, .logo a { height: 95px; + width: 108.38px; +} + +.logo h1 { + font-weight: 900; } h1, @@ -80,7 +137,6 @@ h5, h6 { margin-top: 0; margin-bottom: 0.5rem; - font-family: sans; } h1 { @@ -117,7 +173,7 @@ h3 { .content h2 { font-size: 3.5rem; font-weight: 900; - line-height: 1.2; + line-height: 1; } p { @@ -168,6 +224,15 @@ p { grid-row: 13 / span 4; } +.gallery a { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 1; +} + .gallery img, .gallery video { position: absolute; @@ -176,6 +241,7 @@ p { width: 100%; height: 100%; object-fit: cover; + z-index: 0; } .shop-items { @@ -399,7 +465,7 @@ p { @media screen and (max-width: 50rem) { body { - margin: 2rem; + margin: 1rem 1rem 1.5rem; } .side { @@ -410,14 +476,17 @@ p { font-size: 3rem; } - .container { - gap: 1rem; - } - .gallery { display: flex; flex-direction: column; - gap: 1rem; + gap: 1.5rem; + max-width: 100%; + } + + .gallery > div { + display: contents; + position: relative; + display: flex; } .gallery img, diff --git a/templates.fnl b/templates.fnl index f4ff5cc..07680f8 100644 --- a/templates.fnl +++ b/templates.fnl @@ -1,4 +1,4 @@ -(import-macros {:compile-html <>} :macros) +(import-macros {:compile-html HTML} :macros) (local lib (require :lib)) (fn read-file [file] @@ -6,7 +6,7 @@ (f:read :*all))) (fn base [content] - (<> + (HTML [:html {:lang "ru-RU"} [:head {} [:title {} "«Белая жаба» — маленькая уютная чайная в Омске"] @@ -27,19 +27,19 @@ (fn header [current-path authenticated?] (local logo - (<> + (HTML [:img {:src "/static/logo.svg" :alt "Белая жаба в мультяшном стиле с чайником на голове"}])) - (<> + (HTML [:article {:class "article"} [:div {:class "logo"} (if authenticated? - (<> [:img {:class "logo-glasses" :src "/static/glasses.png" + (HTML [:img {:class "logo-glasses" :src "/static/glasses.png" :alt "Солнцезащитные очки"}]) "") (if (~= current-path "") - (<> [:a {:href "/" :class "d-inline-block"} logo]) + (HTML [:a {:href "/" :class "d-inline-block"} logo]) logo) [:h1 {} [:NO-ESCAPE "Чайная
«Белая жаба»"]]] [:nav {} @@ -51,7 +51,7 @@ [:a {:href "https://vk.com/whitetoadtea"} "вконтакте"]]])) (fn basket-item [item redirect-url] - (<> + (HTML [:div {:class "basket-item"} [:div {:class "basket-item-image"} [:img {:src (.. "/static/files/" (. item :images 1)) :alt item.title}]] -- cgit v1.2.3