Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

Commit

Permalink
DOT-7408: COD-Theme > Integrate the new design of the products listin…
Browse files Browse the repository at this point in the history
…g page (#209)

## JIRA Ticket

[DOT-7408](https://nextmediama.atlassian.net/browse/DOT-7408)

## QA Steps

-  [ ] `pnpm i`
-  [ ] `pnpm dev`

## Note

Leave empty when you have nothing to say


[DOT-7408]:
https://youcanshop.atlassian.net/browse/DOT-7408?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
  • Loading branch information
adildev101 authored Feb 22, 2023
1 parent 887716e commit 61aa3f7
Show file tree
Hide file tree
Showing 14 changed files with 328 additions and 172 deletions.
22 changes: 1 addition & 21 deletions assets/collection-listing.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.yc-collection-listing .collection-list {
display: grid;
margin-top: 60px;
grid-template-columns: 1fr;
gap: 12px;
padding: 54px 20px;
Expand Down Expand Up @@ -63,24 +64,3 @@
padding: 0 250px;
}
}
.yc-collection-listing .breadcrumbs-container .breadcrumbs-listings {
display: flex;
align-items: center;
gap: 12px;
margin: 40px auto;
}
.yc-collection-listing .breadcrumbs-container .breadcrumbs-listings .first-listing {
color: #A8A8A8;
font-weight: 400;
font-size: 14px;
}
.yc-collection-listing .breadcrumbs-container .breadcrumbs-listings .second-listing {
font-weight: 700;
color: #000000;
font-size: 14px;
}
.yc-collection-listing .breadcrumbs-container .breadcrumbs-name {
font-weight: 700;
font-size: 26px;
margin-bottom: 60px;
}
3 changes: 0 additions & 3 deletions assets/dropdown.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/* ----------------------------- */
/* ----- select-box design ----- */
/* ----------------------------- */
select {
display: none;
}

.yc-dropdown {
box-sizing: border-box;
Expand Down
21 changes: 21 additions & 0 deletions assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -479,3 +479,24 @@ input:not([type=radio]),
bottom: 8px;
left: 8px;
}

.breadcrumbs-container .breadcrumbs-listings {
display: flex;
align-items: center;
gap: 12px;
margin: 40px auto;
}
.breadcrumbs-container .breadcrumbs-listings .first-listing {
color: #A8A8A8;
font-weight: 400;
font-size: 14px;
}
.breadcrumbs-container .breadcrumbs-listings .second-listing {
font-weight: 700;
color: #000000;
font-size: 14px;
}
.breadcrumbs-container .breadcrumbs-name {
font-weight: 700;
font-size: 26px;
}
99 changes: 99 additions & 0 deletions assets/product-listing.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
.yc-product-listing-container {
padding: 0 16px;
}
.yc-product-listing-container .product-list {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 12px;
margin-top: 40px;
}
.yc-product-listing-container .product-list .product-block .product-thumbnail {
border: 1px solid #EFEFEF;
border-radius: 4px;
padding: 26px 5px;
}
.yc-product-listing-container .product-list .product-block .product-thumbnail img {
width: 100%;
height: 200px;
object-fit: contain;
}
.yc-product-listing-container .product-list .product-block .product-details {
margin: 14px 0;
text-align: center;
}
.yc-product-listing-container .product-list .product-block .product-details .product-title {
font-weight: 400;
font-size: 16px;
line-height: 22px;
}
.yc-product-listing-container .product-list .product-block .prices {
display: flex;
justify-content: center;
gap: 5px;
}
.yc-product-listing-container .product-list .product-block .prices .product-price {
font-weight: 700;
font-size: 18px;
line-height: 22px;
color: var(--yc-primary-color);
}
@media (min-width: 768px) {
.yc-product-listing-container .product-list {
grid-template-columns: repeat(3, 1fr);
gap: 30px 20px;
}
}
@media (min-width: 992px) {
.yc-product-listing-container .product-list {
grid-template-columns: repeat(4, 1fr);
}
}
.yc-product-listing-container .sort-container {
margin: 40px auto;
}
.yc-product-listing-container .sort-container .sort-select {
padding: 8px 13px;
border: 1px solid #E7E7E7;
border-radius: 4px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23000000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-chevron-down'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
background-position: left 10px top 50%;
background-repeat: no-repeat;
background-size: 15px;
background-color: #fff;
color: #000;
font-size: 14px;
line-height: 22px;
font-weight: 400;
cursor: pointer;
width: 100%;
max-width: 200px;
}
.yc-product-listing-container .sort-container .sort-select option {
color: #000;
font-size: 14px;
line-height: 22px;
font-weight: 400;
}
@media (min-width: 768px) {
.yc-product-listing-container {
padding: 0 50px;
}
}
@media (min-width: 992px) {
.yc-product-listing-container {
padding: 0 80px;
}
}
@media (min-width: 1200px) {
.yc-product-listing-container {
padding: 0 150px;
}
}
@media (min-width: 1400px) {
.yc-product-listing-container {
padding: 0 250px;
}
}
36 changes: 7 additions & 29 deletions assets/queries-handler.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,6 @@
flex-wrap: wrap;
gap: 4px;
}
.top-items .sort-items-holder .field .pawn {
display: flex;
gap: 7px;
align-items: center;
padding: 3px 13px;
border-radius: 50rem;
font-size: 14px;
background-color: rgba(0, 0, 0, 0.1);
color: rgba(0, 0, 0, 0.7);
}
.top-items .sort-items-holder .field .pawn:hover {
background-color: rgba(0, 0, 0, 0.2);
}
.top-items .sort-items-holder .field .pawn.active {
background-color: var(--yc-primary-color);
color: white;
}

/* ---------------------- */
/* ----- pagination ----- */
Expand All @@ -65,7 +48,6 @@
gap: 10px;
margin: 20px auto;
padding: 1rem 2rem;
box-shadow: var(--yc-main-shadow);
border-radius: 8px;
width: fit-content;
}
Expand All @@ -75,21 +57,17 @@
display: flex;
align-items: center;
justify-content: center;
border-radius: 50rem;
border: 1px solid #E4E4E4;
border-radius: 4px;
color: #B1B1B1;
}
.yc-pagination-wrapper .paginate-btn:hover, .yc-pagination-wrapper .paginate-btn.active {
background: var(--yc-neutral-light-color);
border-color: var(--yc-primary-color);
color: var(--yc-primary-color);
}
.yc-pagination-wrapper .paginate-btn-prev, .yc-pagination-wrapper .paginate-btn-next {
width: 2.3rem;
height: 2.3rem;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50rem;
background-color: var(--yc-primary-color);
cursor: pointer;
color: white;
color: #000;
border: 0;
}
.yc-pagination-wrapper .paginate-btn-prev.disabled, .yc-pagination-wrapper .paginate-btn-next.disabled {
background-color: var(--yc-neutral-light-color);
Expand Down
36 changes: 13 additions & 23 deletions assets/queries-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const urlParams = new URLSearchParams(window.location.search);
const query = urlParams.get('q');
const sortField = urlParams.get('sort_field');
const sortOrder = urlParams.get('sort_order');
const sortSelect = document.querySelector('.sort-select');
let page = +urlParams.get('page[cod]');

const updateUrl = (key, value, url) => {
Expand Down Expand Up @@ -52,30 +53,19 @@ if (searchTitle) {
searchTitle.innerHTML = query;
}

const sortBtns = document.querySelectorAll('.sort-items-holder .pawn');
if (sortSelect) {
let sortField = urlParams.get('sort_field');

if (!sortField) {
// Set a default value for sortField if it is null or undefined
sortField = sortSelect.options[0].value;
}

if (sortBtns) {
sortBtns.forEach((btn) => {
sortSelect.value = sortField;

sortSelect.addEventListener('change', () => {
const convertedSortOrder = sortOrder === 'asc' ? 'desc' : 'asc';
btn.setAttribute(
'href',
convertUrlWithMultipleQuery(['sort_field', 'sort_order'], [btn.dataset.value, convertedSortOrder]),
);

const sortBtn = document.querySelector(`.sort-items-holder .pawn[data-value='${sortField}']`);

if (sortBtn) {
sortBtn.classList.add('active');

const sortBtnIcon = sortBtn.querySelector('ion-icon');

if (sortBtnIcon) {
if (sortOrder === 'asc') {
sortBtnIcon.setAttribute('name', 'chevron-up-outline');
} else {
sortBtnIcon.setAttribute('name', 'chevron-down-outline');
}
}
}
const selectedValue = sortSelect.value;
window.location.href = convertUrlWithMultipleQuery(['sort_field', 'sort_order'], [selectedValue, convertedSortOrder]);
});
}
25 changes: 21 additions & 4 deletions sections/main-collection.liquid
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
{{ 'queries-handler.css' | asset_url | stylesheet_tag }}
{{ 'featured-products.css' | asset_url | stylesheet_tag }}
{{ 'product-listing.css' | asset_url | stylesheet_tag }}

{%- assign per_page = section.settings.items_per_page -%}
<div class='yc-featured-products container'>
<div class='top-items'>
<h1 class='yc-section-title'>{{ category.name }}</h1>
<div class='yc-product-listing-container'>
<div class="breadcrumbs-container">
<div class="breadcrumbs-listings">
<div class="listings__item">
<a href="/" class="first-listing">{{ 'snippets.collection-listing.home' | t }}</a>
</div>
<div class="listings__item">
<img src='{{ 'left-arrow.png' | asset_url }}'>
</div>
<div class="listings__item">
<a href="/collections" class="second-listing">{{ 'snippets.collection-listing.collections' | t }}</a>
</div>
</div>

<div class="breadcrumbs-name">
<h1>{{ category.name }}</h1>
</div>
</div>
<div class="sort-container">
{%- render 'main-sort' -%}
</div>

{%- paginate collection.products by per_page cod %}
<div class='product-list'>
{% for product in items %}
Expand Down
32 changes: 6 additions & 26 deletions snippets/main-sort.liquid
Original file line number Diff line number Diff line change
@@ -1,26 +1,6 @@
<div class='sort-items-holder'>
<div class='commander'>{{ 'snippets.main_sort.title' | t }}</div>
<div class='field'>
<a
class='pawn'
data-value='price'
>
<span>{{ 'snippets.main_sort.price' | t }}</span>
<ion-icon name='chevron-down-outline'></ion-icon>
</a>
<a
class='pawn'
data-value='created_at'
>
<span>{{ 'snippets.main_sort.newest' | t }}</span>
<ion-icon name='chevron-down-outline'></ion-icon>
</a>
<a
class='pawn'
data-value='name'
>
<span>{{ 'snippets.main_sort.alphabetically' | t }}</span>
<ion-icon name='chevron-down-outline'></ion-icon>
</a>
</div>
</div>
<select class="sort-select">
<option value="price">{{ 'snippets.main_sort.price' | t }}</option>
<option value="created_at">{{ 'snippets.main_sort.newest' | t }}</option>
<option value="name">{{ 'snippets.main_sort.alphabetically' | t }}</option>
</select>

5 changes: 0 additions & 5 deletions snippets/product-preview.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,4 @@
<span class='compare-at-price'>{{ item.compare_at_price | money }}</span>
{% endif %}
</div>
<div class='flex justify-center'>
<button class='yc-btn {% if settings.featured_products_btn_full_width %} w-full{% endif %}'>
{{ 'snippets.product_preview.cta_button' | t }}
</button>
</div>
</a>
26 changes: 1 addition & 25 deletions styles/collection-listing.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.yc-collection-listing {
.collection-list {
display: grid;
margin-top: 60px;
grid-template-columns: 1fr;
gap: 12px;
padding: 54px 20px;
Expand Down Expand Up @@ -63,30 +64,5 @@
@include breakpoint('xxl') {
padding: 0 250px;
}

.breadcrumbs-listings {
display: flex;
align-items: center;
gap: 12px;
margin: 40px auto;

.first-listing {
color: #A8A8A8;
font-weight: 400;
font-size: 14px;
}

.second-listing {
font-weight: 700;
color: #000000;
font-size: 14px;
}
}

.breadcrumbs-name {
font-weight: 700;
font-size: 26px;
margin-bottom: 60px;
}
}
}
Loading

0 comments on commit 61aa3f7

Please sign in to comment.