forked from myke-roly/capsEcommerce
-
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.
- Loading branch information
Showing
11 changed files
with
189 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React, { useContext } from 'react'; | ||
import { WrapperProduct, Images, Detail, Section } from './styled'; | ||
import Button from '../../utils/Button'; | ||
import { ContextMobile } from '../../context/MobileContext'; | ||
import Title from '../../utils/Title'; | ||
|
||
const Product = ({ data }) => { | ||
const contextMobile = useContext(ContextMobile); | ||
const { modeMobile } = contextMobile; | ||
|
||
return ( | ||
<WrapperProduct modeMobile={modeMobile}> | ||
<Images> | ||
<img src={data.images[0]} alt="img" /> | ||
</Images> | ||
<Detail> | ||
<h2>{data.title}</h2> | ||
<Section> | ||
<h4 className="price">${data.price}.00</h4> | ||
</Section> | ||
<hr/> | ||
<Section> | ||
<h4>Colores: </h4> | ||
<p> | ||
{data.colors.map((color, index) => ( | ||
<span key={index} className="color" style={{ background: color }}></span> | ||
))} | ||
</p> | ||
</Section> | ||
<Section> | ||
<h4>Talle: </h4> | ||
<p>{data.talles}</p> | ||
</Section> | ||
<Section> | ||
<h4>Cantidad:</h4> | ||
<input type="number" placeholder="1" /> | ||
</Section> | ||
<Button text="Agregar al carrito" color="default" /> | ||
<Section> | ||
<span> | ||
<h4>Descripcion: </h4> | ||
<p className="description">{data.description}</p> | ||
</span> | ||
</Section> | ||
</Detail> | ||
</WrapperProduct> | ||
); | ||
}; | ||
|
||
export default Product; |
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,84 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const WrapperProduct = styled.main` | ||
display: flex; | ||
flex-direction: ${props => props.modeMobile ? 'column' : 'row' }; | ||
justify-content: space-evenly; | ||
align-items: center; | ||
margin: ${props => props.modeMobile ? '2rem 0' : '2rem' }; | ||
font-size: 18px; | ||
@media (max-width: 920px) { | ||
font-size: 16px; | ||
} | ||
`; | ||
|
||
export const Images = styled.section` | ||
width: 100%; | ||
height: 100%; | ||
img { | ||
border: 2px solid ${({theme}) => theme.color.default}; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
`; | ||
|
||
export const Detail = styled.section` | ||
width: 100%; | ||
height: 100%; | ||
padding: 1.5rem; | ||
h2 { | ||
text-transform: uppercase; | ||
letter-spacing: 1.5px; | ||
font-size: 1.5em; | ||
} | ||
button { | ||
display: block; | ||
width: 80%; | ||
margin: 1.5rem auto; | ||
} | ||
`; | ||
|
||
export const Section = styled.section` | ||
margin: 1rem 0; | ||
display: flex; | ||
justify-content: space-between; | ||
h4 { | ||
color: ${({theme}) => theme.color.tercero}; | ||
font-weight: 400; | ||
font-size: .7em; | ||
} | ||
p { | ||
color: ${({theme}) => theme.color.deafult}; | ||
font-size: .8em; | ||
opacity: .8; | ||
font-weight: 400; | ||
text-transform: uppercase; | ||
line-height: 1.5rem; | ||
} | ||
.price { | ||
font-size: 1.2rem; | ||
color: ${({theme}) => theme.color.default}; | ||
font-weight: 600; | ||
} | ||
.color { | ||
display: inline-block; | ||
width: 1.2em; | ||
height: 1.2em; | ||
background: red; | ||
border-radius: 50%; | ||
margin: 0 .5rem; | ||
} | ||
.description { | ||
text-transform: initial; | ||
float: right; | ||
} | ||
`; |
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 |
---|---|---|
@@ -1,17 +1,25 @@ | ||
import React from 'react'; | ||
import { useRouter } from 'next/router'; | ||
import Layout from '../../containers/layout'; | ||
import { Container } from '../../styled/'; | ||
import { axiosFetch } from '../../API/axios'; | ||
import Product from '../../components/product'; | ||
|
||
export default () => { | ||
const router = useRouter(); | ||
const { id } = router.query; | ||
|
||
const Producto = ({ data }) => { | ||
return ( | ||
<Layout> | ||
<Container> | ||
<h1>producto {id}</h1> | ||
<Product data={data} /> | ||
</Container> | ||
</Layout> | ||
) | ||
} | ||
); | ||
}; | ||
|
||
export async function getServerSideProps(ctx) { | ||
const { id } = ctx.params; | ||
const response = await axiosFetch(`/api/producto/${id}`); | ||
const data = response.data.product; | ||
|
||
return { props: { data } }; | ||
} | ||
|
||
export default Producto; |
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