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

fix #2811: Cart's Limited Supply status should not hide item title/quantity info #2907

Merged
merged 8 commits into from
Sep 29, 2017
34 changes: 19 additions & 15 deletions imports/plugins/core/checkout/client/components/cartItems.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { Component } from "react";
import PropTypes from "prop-types";
import { i18next } from "/client/api";
import { registerComponent } from "@reactioncommerce/reaction-components";

class CartItems extends Component {
Expand Down Expand Up @@ -30,7 +31,16 @@ class CartItems extends Component {
} = this.props;

return (
<div className="cart-items" key={item._id} style={{ display: "inline-block" }}>
<div
className="cart-items"
key={item._id}
style={{ display: "inline-block" }}
>
{handleLowInventory(item) &&
<div className="badge badge-top badge-low-inv-warning">
{ i18next.t("cartDrawerItems.limitedSupply", { default: "Limited Supply" }) }
Copy link
Member

Choose a reason for hiding this comment

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

Prefer usage of translation component, over importing i18next where possible:

<Components.Translation i18nKey="cartDrawerItems.limitedSupply" defaultValue="Limited Supply" />

</div>
}
<i className="remove-cart-item fa fa-times fa-lg"
id={item._id}
onClick={handleRemoveItem}
Expand All @@ -50,20 +60,14 @@ class CartItems extends Component {
}
</a>
<div className="cart-labels">
{handleLowInventory(item) ?
<div className="badge badge-low-inv-warning"
title={item.variants.inventoryQuantity}
data-i18n="cartDrawerItems.left"
>!</div> :
<div>
<span className="badge" style={{ marginRight: "3px" }}>{item.quantity}</span>
<span className="cart-item-title">
{item.title}
<br />
<small>{item.variants.title}</small>
</span>
</div>
}
<div>
<span className="badge" style={{ marginRight: "3px" }}>{item.quantity}</span>
<span className="cart-item-title">
{item.title}
<br />
<small>{item.variants.title}</small>
</span>
</div>
</div>
</div>
);
Expand Down
3 changes: 3 additions & 0 deletions imports/plugins/core/checkout/server/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"dashboard": {},
"settings": {}
},
"cartDrawerItems": {
"limitedSupply": "Limited Supply"
},
"cartCompleted": {
"yourCart": "Your Cart",
"discountTotal": "Discount Total",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
.label-variant(@label-warning-bg);
}

.badge-top {
position: absolute;
top: -10px;
left: -10px;
}

/* Badge Colors
// Contextual variations of badges
Expand Down