This repository has been archived by the owner on Jul 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 674
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #194 from mirumee/cart_quantity_controls
Add ability to change quantity in the cart
- Loading branch information
Showing
46 changed files
with
696 additions
and
435 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import * as React from "react"; | ||
|
||
import { maybe } from "../../core/utils"; | ||
import CachedImage from "./CachedImage"; | ||
|
||
const noPhotoPng = require("../../images/nophoto.png"); | ||
|
||
const CachedThumbnail: React.SFC<{ | ||
source: { | ||
thumbnail: { url: string; alt: string }; | ||
thumbnail2x: { url: string }; | ||
}; | ||
noPhotoDefault?: boolean; | ||
children?: React.ReactNode; | ||
}> = ({ source, noPhotoDefault, children }) => { | ||
const defaultImg = noPhotoDefault ? noPhotoPng : undefined; | ||
return ( | ||
<CachedImage | ||
url={maybe(() => source.thumbnail.url, defaultImg)} | ||
url2x={maybe(() => source.thumbnail2x.url, defaultImg)} | ||
alt={maybe(() => source.thumbnail.alt, "")} | ||
> | ||
{children} | ||
</CachedImage> | ||
); | ||
}; | ||
|
||
CachedThumbnail.defaultProps = { | ||
noPhotoDefault: true | ||
}; | ||
|
||
export default CachedThumbnail; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default as CachedImage } from "./CachedImage"; | ||
export { default as CachedThumbnail } from "./CachedThumbnail"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import * as React from "react"; | ||
|
||
import { Button } from ".."; | ||
|
||
const Empty: React.SFC<{ overlayHide(): void }> = ({ overlayHide }) => ( | ||
<div className="cart__empty"> | ||
<h4>Yor bag is empty</h4> | ||
<p> | ||
You haven’t added anything to your bag. We’re sure you’ll find something | ||
in our store | ||
</p> | ||
<div className="cart__empty__action"> | ||
<Button secondary onClick={overlayHide}> | ||
Continue Shopping | ||
</Button> | ||
</div> | ||
</div> | ||
); | ||
|
||
export default Empty; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import * as React from "react"; | ||
import { Link } from "react-router-dom"; | ||
import ReactSVG from "react-svg"; | ||
|
||
import { CachedThumbnail } from ".."; | ||
import { generateProductUrl } from "../../core/utils"; | ||
import { CartLineInterface } from "../CartProvider/context"; | ||
|
||
const removeSvg = require("../../images/garbage.svg"); | ||
|
||
const ProductList: React.SFC<{ | ||
lines: CartLineInterface[]; | ||
removeFromCart(variantId: string): void; | ||
}> = ({ lines, removeFromCart }) => ( | ||
<ul className="cart__list"> | ||
{lines.map(line => { | ||
const productUrl = generateProductUrl( | ||
line.variant.product.id, | ||
line.variant.product.name | ||
); | ||
return ( | ||
<li key={line.variant.id} className="cart__list__item"> | ||
<Link to={productUrl}> | ||
<CachedThumbnail source={line.variant.product} /> | ||
</Link> | ||
<div className="cart__list__item__details"> | ||
<p>{line.variant.price.localized}</p> | ||
<Link to={productUrl}> | ||
<p>{line.variant.product.name}</p> | ||
</Link> | ||
<span className="cart__list__item__details__variant"> | ||
<span>{line.variant.name}</span> | ||
<span>{`Qty: ${line.quantity}`}</span> | ||
</span> | ||
<ReactSVG | ||
path={removeSvg} | ||
className="cart__list__item__details__delete-icon" | ||
onClick={() => removeFromCart(line.variant.id)} | ||
/> | ||
</div> | ||
</li> | ||
); | ||
})} | ||
</ul> | ||
); | ||
|
||
export default ProductList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as CartOverlay } from "./CartOverlay"; |
Oops, something went wrong.