Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added homepage and not found components, shop page added #2

Merged
merged 1 commit into from
Jul 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import Header from './components/header/header'
import Hero from './components/hero/hero'
import MainSection from './components/main-section/main-section'
import FeaturedCollection from './components/featured-collection/featured-collection'
import Footer from './components/footer/footer'
import { Switch, Route } from 'react-router-dom'

import './App.scss';
import HomePage from './components/home-page'
import NotFound from './components/not-found'
import Shop from './components/pages/shop/shop'

import './App.scss'

function App() {
return (
<div className="App">
<Header />
<Hero />
<MainSection />
<FeaturedCollection />
<Footer />
<Switch>
<Route exact path='/' component={HomePage} />
<Route path='/shop' component={Shop} />
<Route path='*' component={NotFound} />
</Switch>
</div>
);
)
}

export default App;
18 changes: 18 additions & 0 deletions src/components/home-page.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Layout from './shared/layout';
import Hero from './hero/hero';
import MainSection from './main-section/main-section';
import FeaturedCollection from './featured-collection/featured-collection';

const HomePage = () => {
return (
<>
<Layout>
<Hero />
<MainSection />
<FeaturedCollection />
</Layout>
</>
);
}

export default HomePage;
16 changes: 16 additions & 0 deletions src/components/not-found.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Layout from './shared/layout';

const NotFound = () => {
const style = {
fontWeight: 'bold',
textAlign: 'center',
}

return (
<Layout>
<p style={style}>Unfortunately we can't find that page</p>
</Layout>
);
}

export default NotFound;
29 changes: 29 additions & 0 deletions src/components/pages/shop/shop.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { useContext } from 'react'
import Layout from '../../shared/layout';
import FeaturedProduct from '../../shared/featured-product';
import { ProductsContext } from '../../../context/products-context';

import './shop.styles.scss';

const Shop = () => {
const { products } = useContext(ProductsContext);

const allProducts = products.map(product => (
<FeaturedProduct { ...product } key={product.id} />
));

return (
<Layout>
<div className='product-list-container'>
<h2 className='product-list-title'>Shop</h2>
<div className='product-list'>
{
allProducts
}
</div>
</div>
</Layout>
);
}

export default Shop;
29 changes: 29 additions & 0 deletions src/components/pages/shop/shop.styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.product-list-container {
margin: 3rem 0;
.product-list-title {
margin-top: 5rem;
text-align: center;
}

.product-list {
div {
margin: 1rem;
cursor: pointer;
}
}
}

@media(min-width: 800px) {
.product-list-container {
.product-list {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
margin: 0 5rem;
div {
flex: 0 0 190px;
}
}
}
}
18 changes: 18 additions & 0 deletions src/components/shared/layout.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Header from '../header/header';
import Footer from '../footer/footer';

const Layout = ({ children }) => {
return (
<>
<Header />
<main>
{
children
}
</main>
<Footer />
</>
);
}

export default Layout;