Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xcorner 21 cart page #114

Merged
merged 6 commits into from
Mar 13, 2024
Merged

Xcorner 21 cart page #114

merged 6 commits into from
Mar 13, 2024

Conversation

mgbelegu
Copy link
Collaborator

@mgbelegu mgbelegu commented Mar 6, 2024

No description provided.

@mgbelegu mgbelegu self-assigned this Mar 6, 2024
@mgbelegu mgbelegu changed the base branch from master to xcorner-v2 March 6, 2024 13:05
Copy link
Collaborator

@aleksandraworhacz aleksandraworhacz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added few comments


ratingLink.innerHTML = `${numberOfReviews} reviews`

const filledStarSVG = `
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fan of this solution as you hardcode the SVG inside js. Can't we set a ratings in element's data and based on this value display correct number of stars?

}
}

.c-cart__item-image {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like c-cart__item-image could be moved to a separate component?

@@ -0,0 +1,5 @@
.p-cart__totals {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it's here? You have components/totals which seems like a perfect place for it

@@ -11,154 +11,12 @@
}

.p-common__title {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case I want you to leave it, because I've already worked on a typography. But in general, instead of creating title class inside pages - which doesn't make much sense, consider creating an object like o-title that could be reused in multiple places. It could have modifiers like o-title--big etc.

Try to think about a given part not through lenses of its location, but more like "what it does and how it could be used in different way". I think in 90% of situations, when you want to put some class into common or pages objects ar your answers, especially if something if highly common :)

<span class="u-hidden-visually">
{{lang 'products.quantity_decrease' name=name}}
</span>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use SVG sprite https://github.com/xfiveco/xcorner?tab=readme-ov-file#icons instead of hardcoding icons

<span class="u-hidden-visually">
{{lang 'products.quantity_increase' name=name}}
</span>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SVG sprite

data-confirm-delete="{{lang 'cart.confirm_delete'}}"
aria-label="{{lang 'cart.remove_item' name=name}}"
>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SVG Sprite

</button>
{{/if}}
</div>
<div class="c-cart__item-total">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could it be a separate component called c-order-total ? The same data is being displayed in order's details on account page so we could make the component more general

@mgbelegu
Copy link
Collaborator Author

@aleksandraworhacz Hi, can you please review again? Regarding p-common__title, I've handled that in XCORNER-20, maybe I will merge that first and rebase this one

Copy link
Collaborator

@aleksandraworhacz aleksandraworhacz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added few small comments, otherwise approved :)

<span class="c-cart__item-rating" role="img" aria-label=""></span>
<div class="c-cart__item-rating" role="img" aria-label="">
<span class="c-cart-item__filled-stars">
<svg class="u-hidden" xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everytime you repeat the same code, the red light should appear above your head saying "there must be a better way to approach this" :D

Please create a separate component for the star, where you could pass the value "filled" or "unfilled" and you could either use SVG sprite (https://github.com/xfiveco/xcorner?tab=readme-ov-file#icons) and toggle visibility similar as you do now. Or even better, you could pass the rating value into the "product rating" component and pass the rating then display star svg + clip path to present the exact rate value.

Example for the single star:

<svg>
  <defs>
    <clipPath id="star">
      <path d="...." />
    </clipPath>
  </defs>

  <rect style="width: var(--width, 100%); fill: var(--color, #dd2424)" clip-path="url(#star)"/>
</svg>

@@ -23,7 +23,7 @@ <h1 class="p-common__title">{{lang 'cart.title'}}</h1>
{{> components/cart/content}}
</div>

<div class="js-cart-totals p-cart__totals">
<div class="js-cart-totals c-totals">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, it would be separated into a component named "totals" based on its name - especially if you are reusing in in multiple places.

Also you already have cart component, so you could use "c-cart__totals" instead if it's more like a "one time" component

@mgbelegu
Copy link
Collaborator Author

@aleksandraworhacz Hi, can you please review again?

@mgbelegu mgbelegu merged commit 2f05744 into xcorner-v2 Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants