Skip to content

Commit

Permalink
Merge pull request #40 from good-idea/add-to-cart
Browse files Browse the repository at this point in the history
Add to cart
  • Loading branch information
misteroh10302 authored Aug 10, 2019
2 parents c46c40b + 0465812 commit 382b704
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ node_modules
yarn-error.log
dist
built
package-lock.json
package-lock.json
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
},
"[typescriptreact]": {
"editor.formatOnSave": false
}
},
"git.ignoreLimitWarning": true
}
17 changes: 12 additions & 5 deletions app/src/components/Cart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ interface CartSidebarProps {
export const CartSidebar = styled.div`
${(props: CartSidebarProps) => css`
position: fixed;
right: ${props.open ? '0px' : '-360px'};
top: 1;
max-width: 340px;
right: ${props.open ? '0px' : '-500px'};
top: 0;
max-width: 500px;
max-height: 100vh;
min-height: 100vh;
overflow: scroll;
background-color: ${props.theme.color.white};
box-shadow: -5px 0 5px rgba(0, 0, 0, 0.1);
transition: 250ms linear;
width: 500px;
::-webkit-scrollbar {
width: 0px;
background: transparent;
Expand All @@ -32,14 +33,19 @@ export const CartSidebar = styled.div`
margin: ${props.theme.layout.spacing.small};
margin-top: ${props.theme.layout.spacing.small} !important;
}
${props.theme.mediaQueries.mobile} {
max-width: 340px;
}
`}
`

export const CloseButton = styled.button`
color: blue;
color: white;
position: absolute;
right: 10px;
top: 10px;
bottom: 0;
background-color: black;
padding: 2rem;
padding: ${(props) => props.theme.layout.spacing.small};
`

Expand All @@ -54,6 +60,7 @@ export const CartBottom = styled.div`
justify-content: space-between;
flex-direction: column;
height: 15vh;
> div,
> h6 {
margin: ${(props) => props.theme.layout.spacing.small};
Expand Down
4 changes: 3 additions & 1 deletion app/src/components/Layout/Flex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ export const FlexThree = styled.div`

export const FlexFour = styled.div`
flex: 5;
margin: 10px;
`

export const FlexSix = styled.div`
flex: 6;
margin: 10px;
${({ theme, marginVertical }: WrapperProps) => `
margin-top: ${theme.layout.spacing[marginVertical] || 'initial'} ;
`}
`
4 changes: 3 additions & 1 deletion app/src/components/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface TextStyleProps {
family?: string
transform?: string
children: any
margin?: string
}

const commonHeaderStyles = ({
Expand All @@ -17,6 +18,7 @@ const commonHeaderStyles = ({
weight,
color,
family,
margin,
children,
}: TextStyleProps) => css`
font-weight: ${theme.font.weight[weight]
Expand All @@ -28,7 +30,7 @@ const commonHeaderStyles = ({
color: ${theme.color[color] || 'inherit'};
text-align: ${align || 'inherit'};
text-transform: ${transform || 'auto'};
margin: 0.3em 0;
margin: ${margin || '0.3em 0'};
letter-spacing: 0.03em;
&:first-child {
Expand Down
38 changes: 22 additions & 16 deletions app/src/views/Cart/Checkout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@ import { CartBottom } from 'Components/Cart'
export const Checkout = () => {
const { checkout } = useCheckout()
if (!checkout || checkout.lineItems.length < 1) {
return <NormalizeDiv>Your cart is empty</NormalizeDiv>
return <NormalizeDiv top="0">Your cart is empty</NormalizeDiv>
}
return (
<NormalizeDiv>
<Header3 color="dark">Your cart</Header3>
<NormalizeDiv top="0">
<Header3 color="dark" align="center">
Your cart
</Header3>
{checkout.lineItems.edges.map((element) => {
let { title, variant } = element.node
return (
<FlexContainer key={variant.id} margin="small">
<FlexThree>
<img src={variant.image.originalSrc} />
</FlexThree>
<FlexSix>
<FlexSix marginVertical="0">
<Header5 weight="light" color="dark">
{title}
</Header5>
Expand Down Expand Up @@ -79,18 +81,22 @@ export const Checkout = () => {
</Header5>
</FlexHalf>
</FlexContainer>
<Header6 align="center">
Shipping and discount codes are added at checkout.
</Header6>
<Button
as="a"
href={checkout.webUrl}
background="dark"
color="light"
weight="semi"
>
Checkout
</Button>
<NormalizeDiv align="center">
<Button
as="a"
href={checkout.webUrl}
background="dark"
color="light"
weight="semi"
width="100%"
>
Checkout
</Button>

<Header6 align="center">
Shipping and discount codes are added at checkout.
</Header6>
</NormalizeDiv>
</CartBottom>
</NormalizeDiv>
)
Expand Down
5 changes: 3 additions & 2 deletions app/src/views/Navigation/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
SubmenuPane,
Logo,
} from './styled'
import { IoIosCart } from 'react-icons/io'

interface MenuProps {
activeMenu: null | string
Expand Down Expand Up @@ -130,7 +131,7 @@ export const Navigation = () => {
<NavSection ready={ready} align="right">
<NavHeaderWrapper>
<NavHeader as="button" onClick={openCart}>
Cart {cartCount}
<IoIosCart /> {cartCount}
</NavHeader>
</NavHeaderWrapper>
</NavSection>
Expand All @@ -147,8 +148,8 @@ export const Navigation = () => {
</SubmenuPane>
</Inner>
<CartSidebar open={cartOpen}>
<CloseButton onClick={closeCart}>close</CloseButton>
<Checkout />
<CloseButton onClick={closeCart}>close</CloseButton>
</CartSidebar>
</Wrapper>
)
Expand Down
6 changes: 6 additions & 0 deletions app/src/views/ProductDetail/styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,15 @@ export const ProductRelatedInner = styled.div`
interface NormalizeDivProps {
theme: DefaultTheme
width?: string
top?: string
align?: string
}

export const NormalizeDiv = styled.div`
max-width: ${(props: NormalizeDivProps) =>
props.width === 'half' ? '50%' : '100%'};
text-align: ${(props: NormalizeDivProps) => props.align || 'inherit'};
${(props) => `
margin: ${props.theme.layout.spacing.small};
`}
Expand Down Expand Up @@ -172,6 +176,7 @@ interface ButtonProps {
family?: string
transform?: string
href?: string
width?: string
}

export const Button = styled.button`
Expand All @@ -194,6 +199,7 @@ export const Button = styled.button`
pointer-events: ${props.disabled ? 'none' : 'auto'};
max-width: 200px;
border-radius: 2px;
width: ${props.width || 'initial'};
`}
`

Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"setup": "yarn install",
"test": "yarn workspace jemmawynne-app test",
"build": "yarn workspace jemmawynne-app build && yarn workspace jemmawynne-proxy build",
"start:app": "yarn workspace jemmawynne-app start",
"start:proxy": "yarn workspace jemmawynne-proxy start"
"start:app": "yarn workspace jemmawynne-app start",
"start:proxy": "yarn workspace jemmawynne-proxy start"
},
"devDependencies": {
"@commitlint/cli": "^8.1.0",
Expand All @@ -33,5 +33,8 @@
"post-merge": "yarnhook",
"post-rewrite": "yarnhook"
}
},
"dependencies": {
"react-icons": "^3.7.0"
}
}

0 comments on commit 382b704

Please sign in to comment.