From fb099948fb5ab0878462f7135ca635e22b4229a3 Mon Sep 17 00:00:00 2001 From: Sayat Date: Wed, 15 May 2024 13:24:27 +0800 Subject: [PATCH] added product grid and product card, updated rendering of error pages, updated header overlay functionality --- assets/application.css | 23 ++++++++--- assets/collection.css | 2 +- assets/header.css | 13 ------ assets/queries.css | 8 ++-- locales/en.default.json | 8 +++- sections/404.liquid | 66 +++++++------------------------ sections/collection.liquid | 54 +++++++++---------------- snippets/error-no-products.liquid | 7 ++++ snippets/product-card.liquid | 27 +++++++++++++ 9 files changed, 96 insertions(+), 112 deletions(-) create mode 100644 snippets/error-no-products.liquid create mode 100644 snippets/product-card.liquid diff --git a/assets/application.css b/assets/application.css index f0858ee..8b029ff 100644 --- a/assets/application.css +++ b/assets/application.css @@ -62,6 +62,19 @@ ul { position: relative; } +.overlay { + background-color: var(--white); + width: 100%; + height: calc(100vh - 7rem); + position: absolute; + top: 7rem; + left: 0; + transition: all 0.3s ease-out; + opacity: 0; + visibility: hidden; + z-index: 998; +} + /* CSSGRID */ .grid { display: grid; @@ -85,7 +98,7 @@ ul { .tmp-link__header:link, .tmp-link__header:visited { color: var(--black); - letter-spacing: 0.1rem; + letter-spacing: 0.12rem; transition: all 0.3s ease-out; } @@ -138,12 +151,12 @@ ul { background-color: var(--main-dark); } -.tmp-btn_404 { +.tmp-btn_error { padding: 1.6rem 6.4rem; } -/* SECTION - 404 */ -.section-404 { +/* SECTION - ERROR */ +.section-error { height: calc(100vh - 12rem); text-align: center; display: flex; @@ -152,6 +165,6 @@ ul { gap: 1.2rem; } -.img-container-404 { +.error-img-container { margin-bottom: 2rem; } diff --git a/assets/collection.css b/assets/collection.css index 1cfc049..29fd2f5 100644 --- a/assets/collection.css +++ b/assets/collection.css @@ -40,7 +40,7 @@ .product-price { font-size: 1.4rem; - letter-spacing: 0.1rem; + letter-spacing: 0.12rem; } .product-link { diff --git a/assets/header.css b/assets/header.css index ba91c32..8616e29 100644 --- a/assets/header.css +++ b/assets/header.css @@ -83,19 +83,6 @@ display: block; } - .overlay { - background-color: var(--white); - width: 100%; - height: calc(100vh - 7rem); - position: absolute; - top: 7rem; - left: 0; - transition: all 0.3s ease-out; - opacity: 0; - visibility: hidden; - z-index: 998; - } - .overlay.active { opacity: 0.5; visibility: visible; diff --git a/assets/queries.css b/assets/queries.css index 7a6aba7..2336a1f 100644 --- a/assets/queries.css +++ b/assets/queries.css @@ -13,8 +13,8 @@ padding: 0 4rem; } - /* SECTION 404 */ - .section-404 { + /* SECTION ERROR */ + .section-error { height: calc(100vh - 7rem); } } @@ -59,8 +59,8 @@ width: 100%; } - /* SECTION 404 */ - .section-404 { + /* SECTION ERROR */ + .section-error { padding: 0 3.2rem; } } diff --git a/locales/en.default.json b/locales/en.default.json index eec5d2a..b346395 100644 --- a/locales/en.default.json +++ b/locales/en.default.json @@ -1,8 +1,12 @@ { - "general": { + "error": { "404": { "title": "Not found", - "subtext_html": "The page you were looking for does not exist" + "description": "The page you were looking for does not exist", + "btn_text": "Return home" + }, + "no_products" : { + "title": "No products available" } } } diff --git a/sections/404.liquid b/sections/404.liquid index ad21e61..9b6010b 100644 --- a/sections/404.liquid +++ b/sections/404.liquid @@ -1,54 +1,16 @@ - -{% if section.settings.btn_url == blank %} - {% assign store_url = routes.root_url %} -{% else %} - {% assign store_url = section.settings.btn_url %} -{% endif %} - - -
-
{{ section.settings.render_icon }}
-

{{ section.settings.title }}

-

{{ section.settings.description }}

-
- {{ section.settings.btn_text }} + +
+
+ {% render 'icon-error', size: '24rem' %} +
+

{{ 'error.404.title' | t }}

+

{{ 'error.404.description' | t }}

+
- - -{% schema %} -{ - "name": "404", - "settings": [ - { - "type": "text", - "id": "title", - "label": "Error title", - "default": "Not found" - }, - { - "type": "text", - "id": "description", - "label": "Error description", - "default": "The page you were looking for does not exist" - }, - { - "type": "text", - "id": "btn_text", - "label": "Button text content", - "default": "Return home" - }, - { - "type": "url", - "id": "btn_url", - "label": "Button URL" - }, - { - "type": "liquid", - "id": "render_icon", - "label": "Icon", - "default": "{% render 'icon-error', size: '24rem' %}" - } - ] -} -{% endschema %} diff --git a/sections/collection.liquid b/sections/collection.liquid index e4ba84a..a419b92 100644 --- a/sections/collection.liquid +++ b/sections/collection.liquid @@ -1,38 +1,22 @@ {{ 'collection.css' | asset_url | stylesheet_tag }} -
-
- {% paginate collection.products by 6 %} -
    - {% for product in collection.products %} -
  • - {% if product.images[1] %} -
    - Back side of a shirt -
    - {{ product.featured_image.alt}} - {% endif %} -

    {{ product.title }}

    -

    {{ product.price | money }}

    - -
  • - {% endfor %} -
- {% endpaginate %} -
-
+ +{% assign products_size = collection.products | size %} + +{% if products_size > 0 %} + +
+
+ {% paginate collection.products by 6 %} +
    + {% for product in collection.products %} + {% render 'product-card', product: product %} + {% endfor %} +
+ {% endpaginate %} +
+
+{% else %} + {% render 'error-no-products' %} +{% endif %} diff --git a/snippets/error-no-products.liquid b/snippets/error-no-products.liquid new file mode 100644 index 0000000..9382393 --- /dev/null +++ b/snippets/error-no-products.liquid @@ -0,0 +1,7 @@ + +
+
+ {% render 'icon-error', size: '24rem' %} +
+

{{ 'error.no_products.title' | t }}

+
\ No newline at end of file diff --git a/snippets/product-card.liquid b/snippets/product-card.liquid new file mode 100644 index 0000000..8cbe150 --- /dev/null +++ b/snippets/product-card.liquid @@ -0,0 +1,27 @@ +
  • + {% if product.images[1] %} +
    + Back side of a shirt +
    + {{ product.featured_image.alt}} + {% else %} + {{ 'image' | placeholder_svg_tag }} + {% endif %} +

    {{ product.title }}

    +

    {{ product.price | money }}

    + +
  • \ No newline at end of file