forked from JessNah/BeeGreen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce itemDialog for stores and segregate cart from checkoutdialog
- Loading branch information
Showing
11 changed files
with
304 additions
and
205 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
54 changes: 54 additions & 0 deletions
54
Extension/src/components/CheckoutDialog/CheckoutCart/CheckoutCart.scss
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,54 @@ | ||
.take2--checkout-cart-item { | ||
display: inline-flex; | ||
justify-content: space-between; | ||
width: 100%; | ||
} | ||
|
||
.take2--checkout-cart-item-text { | ||
max-width: 160px; | ||
word-wrap: break-word; | ||
overflow: hidden; | ||
-webkit-line-clamp: 2; | ||
-webkit-box-orient: vertical; | ||
padding-left: 16px; | ||
text-align: left; | ||
display: -webkit-box; | ||
vertical-align: middle; | ||
line-height: normal; | ||
} | ||
|
||
.take2--checkout-cart-item-text-wrapper { | ||
display: inline-block; | ||
} | ||
|
||
.take2--checkout-cart-item-score { | ||
display: inline; | ||
padding-left: 8px; | ||
padding-right: 16px; | ||
} | ||
|
||
.take2--checkout-cart-item-text-container { | ||
// max-width: 160px; | ||
height: 40px; | ||
// line-height: 40px; | ||
text-align: center; | ||
line-height: 40px; | ||
} | ||
|
||
.take2--checkout-cart-item-img { | ||
max-height: 40px; | ||
} | ||
|
||
.take2--checkout-cart-heading { | ||
padding-left: 20px; | ||
padding-right: 16px; | ||
font-size: var(--cds-productive-heading-04-font-size, 1.45rem); | ||
font-weight: var(--cds-productive-heading-04-font-weight, 400); | ||
line-height: var(--cds-productive-heading-04-line-height, 1.29); | ||
letter-spacing: var(--cds-productive-heading-04-letter-spacing, 0); | ||
} | ||
|
||
.take2--checkout-cart-heading-wrapper { | ||
display: inline-flex; | ||
padding: 16px; | ||
} |
106 changes: 106 additions & 0 deletions
106
Extension/src/components/CheckoutDialog/CheckoutCart/CheckoutCart.tsx
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,106 @@ | ||
import React, { Component } from 'react' | ||
import "./CheckoutCart.scss" | ||
import { Accordion, AccordionItem, Tag, TagTypeName } from "carbon-components-react" | ||
import { productItem } from "../../../utils/types" | ||
import { ShoppingCart32 } from "@carbon/icons-react" | ||
|
||
interface CheckoutCartProps { | ||
cart: productItem[], | ||
cartRank: string, | ||
selectItem: (item: productItem) => void; | ||
} | ||
|
||
class CheckoutCart extends Component<CheckoutCartProps> { | ||
getStyledTagScore = (score) => { | ||
let style = "red"; | ||
if(score >= 8){ | ||
style = "green"; | ||
} else if (score >= 6){ | ||
style = "teal"; | ||
} else if (score >= 4) { | ||
style = "purple"; | ||
} else if (score >= 2) { | ||
style = "magenta"; | ||
} else { | ||
style = "red"; | ||
} | ||
return style as TagTypeName; | ||
} | ||
|
||
getScoreText = (score) => { | ||
let text = "Excellent"; | ||
if(score >= 8){ | ||
text = "Excellent"; | ||
} else if (score >= 6){ | ||
text = "Very good"; | ||
} else if (score >= 4) { | ||
text = "Good"; | ||
} else if (score >= 2) { | ||
text = "Fair"; | ||
} else { | ||
text = "Low"; | ||
} | ||
return text; | ||
} | ||
|
||
render() { | ||
return ( | ||
<> | ||
<div className={"take2--checkout-cart-heading-wrapper"}> | ||
<ShoppingCart32 /> | ||
<div className={"take2--checkout-cart-heading"}> | ||
Shopping cart | ||
</div> | ||
{this.props.cartRank && | ||
<Tag | ||
type={this.getStyledTagScore(this.props.cartRank)}> | ||
{this.getScoreText(this.props.cartRank)} | ||
</Tag>} | ||
</div> | ||
<Accordion> | ||
{this.props.cart.map((item: productItem, index) => { | ||
return ( | ||
<AccordionItem | ||
title={ | ||
<div key={index + "_cart_item"} className={"take2--checkout-cart-item"}> | ||
<div | ||
style={{display:"inline-flex", cursor:"pointer"}} | ||
onClick={() => {this.props.selectItem(item)}}> | ||
<div> | ||
<img className={"take2--checkout-cart-item-img"} src={item.image}/> | ||
</div> | ||
<div className={"take2--checkout-cart-item-text-container"}> | ||
<div className={"take2--checkout-cart-item-text-wrapper"}> | ||
<span className={"take2--checkout-cart-item-text"}>{item.name}</span> | ||
</div> | ||
</div> | ||
</div> | ||
<div className={"take2--checkout-cart-item-text-container"}> | ||
<div className={"take2--checkout-cart-item-text-wrapper"}> | ||
<span className={"take2--checkout-cart-item-score"}> | ||
<Tag | ||
type={this.getStyledTagScore(item.score)} > | ||
{this.getScoreText(item.score)} | ||
</Tag> | ||
</span> | ||
</div> | ||
</div> | ||
</div> | ||
}> | ||
<div>{"This item scored " + item.score + "/10" }</div> | ||
<div></div> | ||
<div>{"185 kg carbon emissions3"}</div> | ||
<div>{"73% Production"}</div> | ||
<div>{"7% Transport"}</div> | ||
<div>{"19% Use"}</div> | ||
<div>{"<1% End-of-life processing"}</div> | ||
</AccordionItem> | ||
)}) | ||
} | ||
</Accordion> | ||
</> | ||
) | ||
} | ||
} | ||
|
||
export default CheckoutCart |
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
Oops, something went wrong.