Skip to content

Commit

Permalink
#31 Extracted styling componenets into components folderr and removed…
Browse files Browse the repository at this point in the history
… unnecessary code in pages folder for the Product page
  • Loading branch information
Viviana committed Apr 2, 2021
1 parent 2eb2fb5 commit 2c8aa96
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 149 deletions.
119 changes: 119 additions & 0 deletions src/components/products/products-styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import styled from "styled-components"
import dimensions from "../../style/dimensions"

export const ProductPageHeading = styled.div`
font-size: calc(90px + (90 - 32) * ((100vw - 300px) / (1440 - 300)));
font-weight: bold;
`

export const FeaturedProductSection = styled.div`
width: 100%;
padding-top: 40px;
@media (min-width: ${dimensions.maxwidthTablet}px) {
width: 86vw;
display: flex;
}
`

export const FeaturedProductImage = styled.div`
width: 47vw;
height: 432px;
background-color: #C4C4C4;
@media (max-width: ${dimensions.maxwidthTablet}px) {
width: 100%;
height: 225px;
}
`

export const FeaturedProductText = styled.div`
padding-left: 5vw;
padding-top: 52px;
@media (max-width: ${dimensions.maxwidthTablet}px) {
padding-left: 0vw;
padding-top: 26px;
}
`

export const FeaturedProductHeading = styled.div`
font-size: calc(20px + (20 - 16) * ((100vw - 300px) / (1440 - 300)));
text-transform: uppercase;
`

export const FeaturedProductName = styled.div`
font-size: calc(40px + (40 - 24) * ((100vw - 300px) / (1440 - 300)));
font-weight: bold;
padding-top: 17px;
@media (max-width: ${dimensions.maxwidthTablet}px) {
padding-top: 8px;
}
`

export const FeaturedProductDescription = styled.div`
font-size: calc(18px + (18 - 16) * ((100vw - 300px) / (1440 - 300)));
padding-top: 32px;
@media (max-width: ${dimensions.maxwidthTablet}px) {
padding-top: 15px;
}
`

export const ModelScope = styled.div`
margin-top: 200px;
@media (max-width: ${dimensions.maxwidthTablet}px) {
margin-top: 105px;
}
`

export const ModelScopeHeading = styled.div`
font-size: calc(20px + (20 - 16) * ((100vw - 300px) / (1440 - 300)));
text-transform: uppercase;
`

export const ProductsGroup = styled.div`
@media (min-width: ${dimensions.maxwidthTablet}px) {
display: flex;
justify-content: space-between;
}
`

export const Product = styled.div`
padding-top: 33px;
@media (max-width: ${dimensions.maxwidthTablet}px) {
padding-top: 35px;
}
`

export const ProductImage = styled.div`
background-color: #C4C4C4;
width: 21vw;
height: 245px;
@media (max-width: ${dimensions.maxwidthTablet}px) {
width: 100%;
}
`

export const ProductName = styled.div`
font-size: calc(30px + (30 - 24) * ((100vw - 300px) / (1440 - 300)));
font-weight: bold;
padding-top: 49px;
@media (max-width: ${dimensions.maxwidthTablet}px) {
padding-top: 24px;
}
`

export const ProductDescription = styled.div`
font-size: 15px;
padding-top: 15px;
@media (max-width: ${dimensions.maxwidthTablet}px) {
visibility: hidden;
}
`
54 changes: 54 additions & 0 deletions src/components/products/products.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React from "react"
import {
ProductPageHeading,
FeaturedProductSection,
FeaturedProductImage,
FeaturedProductText,
FeaturedProductHeading,
FeaturedProductName,
FeaturedProductDescription,
ModelScope,
ModelScopeHeading,
ProductsGroup,
Product,
ProductImage,
ProductName,
ProductDescription,
} from "./products-styles"

export default function ProductSection({ data }) {
return (
<div>
<ProductPageHeading>{data.product_page_main_heading}</ProductPageHeading>
<FeaturedProductSection>
<FeaturedProductImage></FeaturedProductImage>
<FeaturedProductText>
<FeaturedProductHeading>{data.featured_product_heading}</FeaturedProductHeading>
<FeaturedProductName>{data.featured_product_name}</FeaturedProductName>
<FeaturedProductDescription>{data.featured_product_description}</FeaturedProductDescription>
</FeaturedProductText>
</FeaturedProductSection>

<div>
{data.model_scope.map(scope => {
return (
<ModelScope>
<ModelScopeHeading>{scope.model_scope_heading}</ModelScopeHeading>
<ProductsGroup>
{data.products.map(product => {
return (
<Product>
<ProductImage></ProductImage>
<ProductName>{product.product_title}</ProductName>
<ProductDescription>{product.product_description}</ProductDescription>
</Product>
)
})}
</ProductsGroup>
</ModelScope>
)
})}
</div>
</div>
)
}
151 changes: 2 additions & 149 deletions src/pages/products.js
Original file line number Diff line number Diff line change
@@ -1,161 +1,14 @@
import React from "react"
import { graphql } from "gatsby"
import Layout from "../components/layout"
import styled from "styled-components"
import dimensions from "../style/dimensions"

const ProductPageHeading = styled.div`
font-size: calc(90px + (90 - 32) * ((100vw - 300px) / (1440 - 300)));
font-weight: bold;
`

const FeaturedProductSection = styled.div`
width: 100%;
padding-top: 40px;
@media (min-width: ${dimensions.maxwidthTablet}px) {
width: 86vw;
display: flex;
}
`

const FeaturedProductImage = styled.div`
width: 47vw;
height: 432px;
background-color: #C4C4C4;
@media (max-width: ${dimensions.maxwidthTablet}px) {
width: 100%;
height: 225px;
}
`

const FeaturedProductText = styled.div`
padding-left: 5vw;
padding-top: 52px;
@media (max-width: ${dimensions.maxwidthTablet}px) {
padding-left: 0vw;
padding-top: 26px;
}
`

const FeaturedProductHeading = styled.div`
font-size: calc(20px + (20 - 16) * ((100vw - 300px) / (1440 - 300)));
text-transform: uppercase;
`

const FeaturedProductName = styled.div`
font-size: calc(40px + (40 - 24) * ((100vw - 300px) / (1440 - 300)));
font-weight: bold;
padding-top: 17px;
@media (max-width: ${dimensions.maxwidthTablet}px) {
padding-top: 8px;
}
`

const FeaturedProductDescription = styled.div`
font-size: calc(18px + (18 - 16) * ((100vw - 300px) / (1440 - 300)));
padding-top: 32px;
@media (max-width: ${dimensions.maxwidthTablet}px) {
padding-top: 15px;
}
`

const ModelScope = styled.div`
margin-top: 200px;
@media (max-width: ${dimensions.maxwidthTablet}px) {
margin-top: 105px;
}
`

const ModelScopeHeading = styled.div`
font-size: calc(20px + (20 - 16) * ((100vw - 300px) / (1440 - 300)));
text-transform: uppercase;
`

const ProductsGroup = styled.div`
@media (min-width: ${dimensions.maxwidthTablet}px) {
display: flex;
justify-content: space-between;
}
`

const Product = styled.div`
padding-top: 33px;
@media (max-width: ${dimensions.maxwidthTablet}px) {
padding-top: 35px;
}
`

const ProductImage = styled.div`
background-color: #C4C4C4;
width: 21vw;
height: 245px;
@media (max-width: ${dimensions.maxwidthTablet}px) {
width: 100%;
}
`

const ProductName = styled.div`
font-size: calc(30px + (30 - 24) * ((100vw - 300px) / (1440 - 300)));
font-weight: bold;
padding-top: 49px;
@media (max-width: ${dimensions.maxwidthTablet}px) {
padding-top: 24px;
}
`

const ProductDescription = styled.div`
font-size: 15px;
padding-top: 15px;
@media (max-width: ${dimensions.maxwidthTablet}px) {
visibility: hidden;
}
`
import ProductPage from "../components/products/products"

export default function ProductSection({ data }) {
const productSectionData = data.prismicProductPage.data

return (
<Layout>
<ProductPageHeading>{productSectionData.product_page_main_heading}</ProductPageHeading>
<FeaturedProductSection>
<FeaturedProductImage></FeaturedProductImage>
<FeaturedProductText>
<FeaturedProductHeading>{productSectionData.featured_product_heading}</FeaturedProductHeading>
<FeaturedProductName>{productSectionData.featured_product_name}</FeaturedProductName>
<FeaturedProductDescription>{productSectionData.featured_product_description}</FeaturedProductDescription>
</FeaturedProductText>
</FeaturedProductSection>

<div>
{productSectionData.model_scope.map(scope => {
return (
<ModelScope>
<ModelScopeHeading>{scope.model_scope_heading}</ModelScopeHeading>
<ProductsGroup>
{productSectionData.products.map(product => {
return (
<Product>
<ProductImage></ProductImage>
<ProductName>{product.product_title}</ProductName>
<ProductDescription>{product.product_description}</ProductDescription>
</Product>
)
})}
</ProductsGroup>
</ModelScope>
)
})}
</div>
<ProductPage data={productSectionData}/>
</Layout>
)
}
Expand Down

0 comments on commit 2c8aa96

Please sign in to comment.