summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dicts.fnl7
-rw-r--r--pages/shop/_product/index.fnl53
-rw-r--r--pages/shop/add.fnl2
-rw-r--r--pages/shop/index.fnl2
-rw-r--r--static/style.css2
5 files changed, 41 insertions, 25 deletions
diff --git a/dicts.fnl b/dicts.fnl
index 4f42526..b884b45 100644
--- a/dicts.fnl
+++ b/dicts.fnl
@@ -1,4 +1,4 @@
-(local tea-type
+(local product-type
[{:value "white" :label "Белый"}
{:value "dark-oolong" :label "Темный улун"}
{:value "light-oolong" :label "Светлый улун"}
@@ -7,7 +7,8 @@
{:value "shu-puerh" :label "Шу пуэр"}
{:value "sheng-puerh" :label "Шэн пуэр"}
{:value "yellow" :label "Желтый"}
- {:value "liu-bao" :label "Лю бао"}])
+ {:value "liu-bao" :label "Лю бао"}
+ {:value "teapot" :label "Чайник"}])
(local tea-season
[{:value "spring" :label "Весна"}
@@ -27,4 +28,4 @@
(set result item.label)))
result)
-{: tea-type : tea-packaging : tea-season : label}
+{: product-type : tea-packaging : tea-season : label}
diff --git a/pages/shop/_product/index.fnl b/pages/shop/_product/index.fnl
index c3c2968..a9b7904 100644
--- a/pages/shop/_product/index.fnl
+++ b/pages/shop/_product/index.fnl
@@ -21,12 +21,15 @@
db
"SELECT products.name,
products.title,
+ products.short_description AS \"short-description\",
products.description,
products.price_per AS \"price-per\",
products.type,
+ products.region,
products.stock,
products.packaging,
products.published,
+ products.year,
products.image1,
products.image2,
products.image3,
@@ -50,28 +53,40 @@
[:div {:class "mb-1"} [:a {:href "/shop"} "⟵ Обратно к списку"]]
[:div {:class "product-page-layout"}
- [:div {}
- [:h2 {:class "product-page-title"}
- product.title
- (if authenticated?
- (HTML [:a {:style "font-size: 1rem; margin-left: 0.75rem;"
- :href (.. "/shop/" product.name "/edit")}
- "% Редактировать"])
- "")]
- [:section {:class "mb-2"}
- [:div {:class "mb-0-5" :style "font-style: italic;"}
- (or (dicts.label dicts.tea-type product.type) product.type) ", "
- (if (= product.packaging "piece")
- (HTML [:strong {} product.price-per "₽ за 1 шт. "])
- (HTML [:span {}
- [:strong {} (* 50 product.price-per) "₽ за 50 грамм "]
- "(" product.price-per "₽ за 1 грамм)"]))]]
+ [:article {}
+ [:h2 {:class "product-page-title"} product.title]
+ (if authenticated?
+ (HTML
+ [:div {:class "mb-1" :style "margin-top: -0.5rem;"}
+ [:a {:href (.. "/shop/" product.name "/edit")}
+ "% Редактировать"]])
+ "")
+ [:div {:class "mb-0-5" :style "font-style: italic;"}
+ (or (dicts.label dicts.product-type product.type) product.type) ", "
+ (if (not (lib.empty? product.year))
+ (HTML [:span {} [:NO-ESCAPE (.. product.year " год, ")]])
+ "")
+ (if (not (lib.empty? product.region)) (.. product.region ", ") "")
+ (if (= product.packaging "piece")
+ (HTML [:strong {} product.price-per "₽ за 1 шт. "])
+ (HTML [:span {}
+ [:strong {} [:NO-ESCAPE
+ (* 50 product.price-per)
+ "₽ за 50 грамм "]]
+ [:NO-ESCAPE "(" product.price-per
+ "₽ за 1 грамм)"]]))]
+ [:div {:class "mb-1" :style "font-style: italic;"}
+ product.short-description]
(let [link (.. "/static/files/" product.image1)]
(HTML [:a {:href link :target "_blank"}
- [:img {:class "product-page-img-mobile mb-2"
+ [:img {:class "product-page-img-mobile mb-1"
:src (.. link "-thumbnail.jpg")}]]))
- [:div {:class "mb-2"} "~~~"]
- [:NO-ESCAPE (text->html product.description)]]
+ (if (not (lib.empty? product.description))
+ (HTML [:div {:class "mb-1"} "***"])
+ "")
+ (if (not (lib.empty? product.description))
+ (HTML [:div {} [:NO-ESCAPE (text->html product.description)]])
+ "")]
[:div {:class "product-page-imgs"}
(table.concat
(icollect [idx image (ipairs images)]
diff --git a/pages/shop/add.fnl b/pages/shop/add.fnl
index 5b5bfc5..99cfee3 100644
--- a/pages/shop/add.fnl
+++ b/pages/shop/add.fnl
@@ -15,7 +15,7 @@
(.. "Уникальное название чая на латинице, без пробелов, "
"в нижнем регистре."))
(forms.text-input "title" "Полное название" true 0 200)
- (forms.select-input "type" "Вид чая" true dicts.tea-type)
+ (forms.select-input "type" "Вид чая" true dicts.product-type)
(forms.select-input "packaging" "Упаковка" true dicts.tea-packaging)
(forms.number-input "year" "Год изготовления" false 1950
(tonumber (os.date "%Y")))
diff --git a/pages/shop/index.fnl b/pages/shop/index.fnl
index 08770d0..0b9336e 100644
--- a/pages/shop/index.fnl
+++ b/pages/shop/index.fnl
@@ -70,7 +70,7 @@
"left: calc(100% / " (# images) " * " (- idx 1) ")")}])))]]
[:a {:href item-url} [:h3 {:class "shop-item-title"} product.title]]
[:div {:style "font-style: italic; margin-bottom: 0.25rem;"}
- (or (dicts.label dicts.tea-type product.type) product.type) ", "
+ (or (dicts.label dicts.product-type product.type) product.type) ", "
(if (= product.packaging "piece")
(HTML [:strong {} product.price-per "₽ за 1 шт."])
(HTML [:strong {} (* 50 product.price-per) "₽ за 50 гр. "]))]
diff --git a/static/style.css b/static/style.css
index 6066e97..0494d87 100644
--- a/static/style.css
+++ b/static/style.css
@@ -370,7 +370,7 @@ p {
gap: 2rem;
}
-.product-page-layout > div {
+.product-page-layout > * {
flex: 50%;
}