add PageLayout; updated pages

This commit is contained in:
Ruidy Nemausat 2020-04-15 10:32:49 +02:00
parent 2a6f843d36
commit b5706c3a2e
7 changed files with 26 additions and 15 deletions

View file

@ -10,5 +10,6 @@
- [ ] Close Sidebar at outside click - [ ] Close Sidebar at outside click
- [ ] Take a look at some components [here](http://react-materialize.github.io/react-materialize/?path=/story/css-grid--default) - [ ] Take a look at some components [here](http://react-materialize.github.io/react-materialize/?path=/story/css-grid--default)
- [ ] Decoupled application and data layers. Abstract such that the front end does not know where the data comes from. - [ ] Decoupled application and data layers. Abstract such that the front end does not know where the data comes from.
- [ ] Create PageLayout component - [x] Create PageLayout component
- [ ] Use Css-in-Js - [ ] Use Css-in-Js
- [ ] Redirect to 404

View file

@ -18,7 +18,6 @@ const MainLayout = ({
const [showNav, setShowNav] = useState(false); const [showNav, setShowNav] = useState(false);
const links = ["categories", "contact"]; const links = ["categories", "contact"];
const footerLinks = [...links, "random"];
const openNavClick = (ev) => { const openNavClick = (ev) => {
ev.preventDefault(); ev.preventDefault();

View file

@ -0,0 +1,12 @@
import React from "react";
const PageLayout = ({ title, children }) => {
return (
<div className="container">
<h1 className="logo">{title}</h1>
{children}
</div>
);
};
export default PageLayout;

View file

@ -1,15 +1,15 @@
import React from "react"; import React from "react";
import PageLayout from "../layouts/PageLayout";
import CategoryEntry from "../components/CategoryEntry"; import CategoryEntry from "../components/CategoryEntry";
export const CategoryListPage = ({ categories }) => { export const CategoryListPage = ({ categories }) => {
return ( return (
<div className="container"> <PageLayout title="Chef's Categories">
<h1 className="logo">Chef's Categories</h1>
<ul> <ul>
{categories.map((category, i) => ( {categories.map((category, i) => (
<CategoryEntry key={i} category={category} /> <CategoryEntry key={i} category={category} />
))} ))}
</ul> </ul>
</div> </PageLayout>
); );
}; };

View file

@ -1,10 +1,10 @@
import React from "react"; import React from "react";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import PageLayout from "../layouts/PageLayout";
export const CategoryPage = ({ meals, strCategory }) => { export const CategoryPage = ({ meals, strCategory }) => {
return ( return (
<div className="container"> <PageLayout title={`Chef's ${strCategory} Recipes`}>
<h1 className="logo">Chef's {strCategory} Recipes</h1>
<ul> <ul>
<div className="row"> <div className="row">
{meals.meals.map((meal, i) => ( {meals.meals.map((meal, i) => (
@ -26,6 +26,6 @@ export const CategoryPage = ({ meals, strCategory }) => {
))} ))}
</div> </div>
</ul> </ul>
</div> </PageLayout>
); );
}; };

View file

@ -1,4 +1,5 @@
import React, { useState } from "react"; import React, { useState } from "react";
import PageLayout from "../layouts/PageLayout";
import { ContactForm } from "../components/ContactForm"; import { ContactForm } from "../components/ContactForm";
export const ContactPage = () => { export const ContactPage = () => {
@ -15,9 +16,8 @@ export const ContactPage = () => {
<h4>Thank you for your message</h4> <h4>Thank you for your message</h4>
</div> </div>
) : ( ) : (
<div className="container"> <PageLayout title="Contact Us">
<h2 className="logo">Contact Us</h2>
<ContactForm setIsSubmitted={setIsSubmitted} /> <ContactForm setIsSubmitted={setIsSubmitted} />
</div> </PageLayout>
); );
}; };

View file

@ -1,11 +1,11 @@
import React from "react"; import React from "react";
import { SearchResult } from "../components/SearchResult"; import { SearchResult } from "../components/SearchResult";
import PageLayout from "../layouts/PageLayout";
export const SearchPage = ({ searchString, searchResults }) => { export const SearchPage = ({ searchString, searchResults }) => {
const { meals } = searchResults; const { meals } = searchResults;
return ( return (
<div className="container"> <PageLayout title={`Results for: ${searchString}`}>
<h1 className="logo">Results for: {searchString}</h1>
{meals === null ? ( {meals === null ? (
<div className="center-align"> <div className="center-align">
<p> <p>
@ -16,7 +16,6 @@ export const SearchPage = ({ searchString, searchResults }) => {
alt="Nothing here!" alt="Nothing here!"
width="70%" width="70%"
/> />
<p></p>
</div> </div>
) : ( ) : (
<div className="row"> <div className="row">
@ -27,6 +26,6 @@ export const SearchPage = ({ searchString, searchResults }) => {
</ul> </ul>
</div> </div>
)} )}
</div> </PageLayout>
); );
}; };