diff --git a/package-lock.json b/package-lock.json index 639dd6d..3cbb87a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3684,6 +3684,15 @@ "sha.js": "^2.4.8" } }, + "create-react-context": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/create-react-context/-/create-react-context-0.2.3.tgz", + "integrity": "sha512-CQBmD0+QGgTaxDL3OX1IDXYqjkp2It4RIbcb99jS6AEg27Ga+a9G3JtK6SIu0HBwPLZlmwt9F7UwWA4Bn92Rag==", + "requires": { + "fbjs": "^0.8.0", + "gud": "^1.0.0" + } + }, "cross-spawn": { "version": "6.0.5", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", @@ -4604,6 +4613,14 @@ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" }, + "encoding": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", + "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", + "requires": { + "iconv-lite": "~0.4.13" + } + }, "end-of-stream": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", @@ -5603,6 +5620,35 @@ "bser": "^2.0.0" } }, + "fbjs": { + "version": "0.8.17", + "resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.8.17.tgz", + "integrity": "sha1-xNWY6taUkRJlPWWIsBpc3Nn5D90=", + "requires": { + "core-js": "^1.0.0", + "isomorphic-fetch": "^2.1.1", + "loose-envify": "^1.0.0", + "object-assign": "^4.1.0", + "promise": "^7.1.1", + "setimmediate": "^1.0.5", + "ua-parser-js": "^0.7.18" + }, + "dependencies": { + "core-js": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz", + "integrity": "sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY=" + }, + "promise": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", + "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", + "requires": { + "asap": "~2.0.3" + } + } + } + }, "figgy-pudding": { "version": "3.5.1", "resolved": "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.5.1.tgz", @@ -6744,6 +6790,11 @@ "resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz", "integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=" }, + "gud": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/gud/-/gud-1.0.0.tgz", + "integrity": "sha512-zGEOVKFM5sVPPrYs7J5/hYEw2Pof8KCyOwyhG8sAF26mCAeUFAcYPu1mwB7hhpIP29zOIBaDqwuHdLp0jvZXjw==" + }, "gzip-size": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-5.0.0.tgz", @@ -6936,6 +6987,19 @@ "resolved": "https://registry.npmjs.org/hex-color-regex/-/hex-color-regex-1.1.0.tgz", "integrity": "sha512-l9sfDFsuqtOqKDsQdqrMRk0U85RZc0RtOR9yPI7mRVOa4FsR/BVnZ0shmQRM96Ji99kYZP/7hn1cedc1+ApsTQ==" }, + "history": { + "version": "4.9.0", + "resolved": "https://registry.npmjs.org/history/-/history-4.9.0.tgz", + "integrity": "sha512-H2DkjCjXf0Op9OAr6nJ56fcRkTSNrUiv41vNJ6IswJjif6wlpZK0BTfFbi7qK9dXLSYZxkq5lBsj3vUjlYBYZA==", + "requires": { + "@babel/runtime": "^7.1.2", + "loose-envify": "^1.2.0", + "resolve-pathname": "^2.2.0", + "tiny-invariant": "^1.0.2", + "tiny-warning": "^1.0.0", + "value-equal": "^0.4.0" + } + }, "hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", @@ -7899,6 +7963,15 @@ "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" }, + "isomorphic-fetch": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", + "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", + "requires": { + "node-fetch": "^1.0.1", + "whatwg-fetch": ">=0.10.0" + } + }, "isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", @@ -9314,6 +9387,15 @@ "lower-case": "^1.1.1" } }, + "node-fetch": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", + "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", + "requires": { + "encoding": "^0.1.11", + "is-stream": "^1.0.1" + } + }, "node-forge": { "version": "0.7.5", "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.7.5.tgz", @@ -12660,6 +12742,52 @@ "react-is": "^16.8.2" } }, + "react-router": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-5.0.0.tgz", + "integrity": "sha512-6EQDakGdLG/it2x9EaCt9ZpEEPxnd0OCLBHQ1AcITAAx7nCnyvnzf76jKWG1s2/oJ7SSviUgfWHofdYljFexsA==", + "requires": { + "@babel/runtime": "^7.1.2", + "create-react-context": "^0.2.2", + "history": "^4.9.0", + "hoist-non-react-statics": "^3.1.0", + "loose-envify": "^1.3.1", + "path-to-regexp": "^1.7.0", + "prop-types": "^15.6.2", + "react-is": "^16.6.0", + "tiny-invariant": "^1.0.2", + "tiny-warning": "^1.0.0" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" + }, + "path-to-regexp": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz", + "integrity": "sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=", + "requires": { + "isarray": "0.0.1" + } + } + } + }, + "react-router-dom": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-5.0.0.tgz", + "integrity": "sha512-wSpja5g9kh5dIteZT3tUoggjnsa+TPFHSMrpHXMpFsaHhQkm/JNVGh2jiF9Dkh4+duj4MKCkwO6H08u6inZYgQ==", + "requires": { + "@babel/runtime": "^7.1.2", + "history": "^4.9.0", + "loose-envify": "^1.3.1", + "prop-types": "^15.6.2", + "react-router": "5.0.0", + "tiny-invariant": "^1.0.2", + "tiny-warning": "^1.0.0" + } + }, "react-scripts": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-2.1.5.tgz", @@ -13330,6 +13458,11 @@ "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz", "integrity": "sha1-six699nWiBvItuZTM17rywoYh0g=" }, + "resolve-pathname": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/resolve-pathname/-/resolve-pathname-2.2.0.tgz", + "integrity": "sha512-bAFz9ld18RzJfddgrO2e/0S2O81710++chRMUxHjXOYKF6jTAMrUNZrEZ1PvV0zlhfjidm08iRPdTLPno1FuRg==" + }, "resolve-url": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", @@ -14743,6 +14876,16 @@ "resolved": "https://registry.npmjs.org/timsort/-/timsort-0.3.0.tgz", "integrity": "sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=" }, + "tiny-invariant": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.0.4.tgz", + "integrity": "sha512-lMhRd/djQJ3MoaHEBrw8e2/uM4rs9YMNk0iOr8rHQ0QdbM7D4l0gFl3szKdeixrlyfm9Zqi4dxHCM2qVG8ND5g==" + }, + "tiny-warning": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/tiny-warning/-/tiny-warning-1.0.2.tgz", + "integrity": "sha512-rru86D9CpQRLvsFG5XFdy0KdLAvjdQDyZCsRcuu60WtzFylDM3eAWSxEVz5kzL2Gp544XiUvPbVKtOA/txLi9Q==" + }, "tmp": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", @@ -14899,6 +15042,11 @@ "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" }, + "ua-parser-js": { + "version": "0.7.19", + "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.19.tgz", + "integrity": "sha512-T3PVJ6uz8i0HzPxOF9SWzWAlfN/DavlpQqepn22xgve/5QecC+XMCAtmUNnY7C9StehaV6exjUCI801lOI7QlQ==" + }, "uglify-js": { "version": "3.4.9", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.9.tgz", @@ -15182,6 +15330,11 @@ "spdx-expression-parse": "^3.0.0" } }, + "value-equal": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/value-equal/-/value-equal-0.4.0.tgz", + "integrity": "sha512-x+cYdNnaA3CxvMaTX0INdTCN8m8aF2uY9BvEqmxuYp8bL09cs/kWVQPVGcA35fMktdOsP69IgU7wFj/61dJHEw==" + }, "vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", diff --git a/package.json b/package.json index b911bc3..f413bb3 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "react": "^16.8.6", "react-dom": "^16.8.6", "react-redux": "^6.0.1", + "react-router-dom": "^5.0.0", "react-scripts": "2.1.5", "redux": "^4.0.1" }, diff --git a/src/App.js b/src/App.js old mode 100755 new mode 100644 index 55596e4..fd74c74 --- a/src/App.js +++ b/src/App.js @@ -1,13 +1,23 @@ -import React, { Component } from "react"; -import Layout from "./components/Layout/Layout"; -import BurgerBuilder from "./containers/BurgerBuilder/BurgerBuilder"; +import React, { Component } from 'react'; +import { Route, Switch } from 'react-router-dom'; + +import Layout from './hoc/Layout/Layout'; +import BurgerBuilder from './containers/BurgerBuilder/BurgerBuilder'; +import Checkout from './containers/Checkout/Checkout'; +import Orders from './containers/Orders/Orders'; class App extends Component { - render() { + render () { return ( - - - +
+ + + + + + + +
); } } diff --git a/src/App.test.js b/src/App.test.js old mode 100755 new mode 100644 index a754b20..b84af98 --- a/src/App.test.js +++ b/src/App.test.js @@ -5,5 +5,4 @@ import App from './App'; it('renders without crashing', () => { const div = document.createElement('div'); ReactDOM.render(, div); - ReactDOM.unmountComponentAtNode(div); }); diff --git a/src/axios-order.js b/src/axios-orders.js similarity index 100% rename from src/axios-order.js rename to src/axios-orders.js diff --git a/src/components/Burger/BuildControls/BuildControl/BuildControl.js b/src/components/Burger/BuildControls/BuildControl/BuildControl.js new file mode 100644 index 0000000..5fa72fd --- /dev/null +++ b/src/components/Burger/BuildControls/BuildControl/BuildControl.js @@ -0,0 +1,18 @@ +import React from 'react'; +import classes from './BuildControl.module.css'; + + +const buildControl = (props) => ( +
+
{props.label}
+ + +
+); + +export default buildControl; \ No newline at end of file diff --git a/src/components/Burger/BuildControls/BuildControl/BuildControl.jsx b/src/components/Burger/BuildControls/BuildControl/BuildControl.jsx deleted file mode 100644 index 6e60c4c..0000000 --- a/src/components/Burger/BuildControls/BuildControl/BuildControl.jsx +++ /dev/null @@ -1,22 +0,0 @@ -import React from "react"; -import classes from "./BuildControl.module.css"; - -const buildControl = props => { - return ( -
-
{props.label}
- - -
- ); -}; - -export default buildControl; diff --git a/src/components/Burger/BuildControls/BuildControl/BuildControl.module.css b/src/components/Burger/BuildControls/BuildControl/BuildControl.module.css index b657551..f202df9 100644 --- a/src/components/Burger/BuildControls/BuildControl/BuildControl.module.css +++ b/src/components/Burger/BuildControls/BuildControl/BuildControl.module.css @@ -1,58 +1,57 @@ .BuildControl { - display: flex; - justify-content: space-between; - align-items: center; - margin: 5px 0; + display: flex; + justify-content: space-between; + align-items: center; + margin: 5px 0; } .BuildControl button { - display: block; - font: inherit; - padding: 5px; - margin: 0 5px; - width: 80px; - border: 1px solid #aa6817; - cursor: pointer; - outline: none; + display: block; + font: inherit; + padding: 5px; + margin: 0 5px; + width: 80px; + border: 1px solid #AA6817; + cursor: pointer; + outline: none; } + .BuildControl button:disabled { - background-color: #ac9980; - border: 1px solid #7e7365; - color: #ccc; - cursor: default; + background-color: #AC9980; + border: 1px solid #7E7365; + color: #ccc; + cursor: default; } .BuildControl button:hover:disabled { - background-color: #ac9980; - color: #ccc; - cursor: not-allowed; + background-color: #AC9980; + color: #ccc; + cursor: not-allowed; } .Label { - padding: 10px; - font-weight: bold; - width: 80px; + padding: 10px; + font-weight: bold; + width: 80px; } -.BuildControl .Less { - background-color: #d39952; - color: white; +.BuildControl .Less { + background-color: #D39952; + color: white; } .BuildControl .More { - background-color: #8f5e1e; - color: white; + background-color: #8F5E1E; + color: white; } -.BuildControl .Less:hover, -.BuildControl .Less:active { - background-color: #daa972; - color: white; +.BuildControl .Less:hover, .BuildControl .Less:active { + background-color: #DAA972; + color: white; } -.BuildControl .More:hover, -.BuildControl .More:active { - background-color: #99703f; - color: white; -} +.BuildControl .More:hover,.BuildControl .More:active { + background-color: #99703F; + color: white; +} \ No newline at end of file diff --git a/src/components/Burger/BuildControls/BuildControls.js b/src/components/Burger/BuildControls/BuildControls.js new file mode 100644 index 0000000..08f4575 --- /dev/null +++ b/src/components/Burger/BuildControls/BuildControls.js @@ -0,0 +1,31 @@ +import React from 'react'; +import BuildControl from './BuildControl/BuildControl'; +import classes from './BuildControls.module.css'; + + +const controls = [ + { label: 'Salad', type: 'salad' }, + { label: 'Bacon', type: 'bacon' }, + { label: 'Cheese', type: 'cheese' }, + { label: 'Meat', type: 'meat' }, +]; + +const buildControls = (props) => ( +
+

Current Price: {props.price.toFixed(2)}

+ {controls.map(ctrl => ( + props.ingredientAdded(ctrl.type)} + removed={() => props.ingredientRemoved(ctrl.type)} + disabled={props.disabled[ctrl.type]} /> + ))} + +
+); + +export default buildControls; \ No newline at end of file diff --git a/src/components/Burger/BuildControls/BuildControls.jsx b/src/components/Burger/BuildControls/BuildControls.jsx deleted file mode 100644 index b17ddc6..0000000 --- a/src/components/Burger/BuildControls/BuildControls.jsx +++ /dev/null @@ -1,38 +0,0 @@ -import React from "react"; -import BuildControl from "./BuildControl/BuildControl"; -import classes from "./BuildControls.module.css"; - -const buildControls = props => { - const isPurchaseable = Object.values(props.ingredients).reduce( - (sum, el) => sum + el, - 0 - ); - return ( -
-

- Current price: {props.price} -

- {Object.keys(props.ingredients).map(ingredient => { - const ingr = ingredient.charAt(0).toUpperCase() + ingredient.slice(1); - return ( - props.add(ingredient)} - remove={() => props.remove(ingredient)} - value={props.ingredients[ingredient]} - /> - ); - })} - -
- ); -}; - -export default buildControls; diff --git a/src/components/Burger/BuildControls/BuildControls.module.css b/src/components/Burger/BuildControls/BuildControls.module.css index c75f933..89017a5 100644 --- a/src/components/Burger/BuildControls/BuildControls.module.css +++ b/src/components/Burger/BuildControls/BuildControls.module.css @@ -1,52 +1,51 @@ .BuildControls { - width: 100%; - background: #cf8f2e; - display: flex; - flex-flow: column; - align-items: center; - box-shadow: 0 2px 1px #ccc; - margin: auto; - padding: 10px 0; + width: 100%; + background-color: #CF8F2E; + display: flex; + flex-flow: column; + align-items: center; + box-shadow: 0 2px 1px #ccc; + margin: auto; + padding: 10px 0; } .OrderButton { - background-color: #dad735; - outline: none; - cursor: pointer; - border: 1px solid #966909; - color: #966909; - font-family: inherit; - font-size: 1.2em; - padding: 15px 30px; - box-shadow: 2px 2px 2px #966909; + background-color: #DAD735; + outline: none; + cursor: pointer; + border: 1px solid #966909; + color: #966909; + font-family: inherit; + font-size: 1.2em; + padding: 15px 30px; + box-shadow: 2px 2px 2px #966909; } -.OrderButton:hover, -.OrderButton:active { - background-color: #a0db41; - border: 1px solid #966909; - color: #966909; +.OrderButton:hover, .OrderButton:active { + background-color: #A0DB41; + border: 1px solid #966909; + color: #966909; } .OrderButton:disabled { - background-color: #c7c6c6; - cursor: not-allowed; - border: 1px solid #ccc; - color: #888888; + background-color: #C7C6C6; + cursor: not-allowed; + border: 1px solid #ccc; + color: #888888; } .OrderButton:not(:disabled) { - animation: enable 0.3s linear; + animation: enable 0.3s linear; } @keyframes enable { - 0% { - transform: scale(1); - } - 60% { - transform: scale(1.1); - } - 100% { - transform: scale(1); - } -} + 0% { + transform: scale(1); + } + 60% { + transform: scale(1.1); + } + 100% { + transform: scale(1); + } +} \ No newline at end of file diff --git a/src/components/Burger/Burger.js b/src/components/Burger/Burger.js new file mode 100644 index 0000000..ba60441 --- /dev/null +++ b/src/components/Burger/Burger.js @@ -0,0 +1,29 @@ +import React from 'react'; +import classes from './Burger.module.css'; +import BurgerIngredient from './BurgerIngredient/BurgerIngredient'; + + +const burger = ( props ) => { + console.log(props); + let transformedIngredients = Object.keys( props.ingredients ) + .map( igKey => { + return [...Array( props.ingredients[igKey] )].map( ( _, i ) => { + return ; + } ); + } ) + .reduce((arr, el) => { + return arr.concat(el) + }, []); + if (transformedIngredients.length === 0) { + transformedIngredients =

Please start adding ingredients!

; + } + return ( +
+ + {transformedIngredients} + +
+ ); +}; + +export default burger; \ No newline at end of file diff --git a/src/components/Burger/Burger.jsx b/src/components/Burger/Burger.jsx deleted file mode 100644 index 111649d..0000000 --- a/src/components/Burger/Burger.jsx +++ /dev/null @@ -1,27 +0,0 @@ -import React from "react"; -import classes from "./Burger.module.css"; -import BurgerIngredient from "./BurgerIngredient/BurgerIngredient"; - -const burger = props => { - const transformedIngredients = Object.keys(props.ingredients) - .map(igkey => { - return [...Array(props.ingredients[igkey])].map((_, index) => ( - - )); - }) - .reduce((prev, cur) => prev.concat(cur)); - - const messageIfNoIngredients = !transformedIngredients.length && ( -

Please select ingredients

- ); - return ( -
- - {messageIfNoIngredients} - {transformedIngredients} - -
- ); -}; - -export default burger; diff --git a/src/components/Burger/Burger.module.css b/src/components/Burger/Burger.module.css index cd18bf6..67a7b36 100644 --- a/src/components/Burger/Burger.module.css +++ b/src/components/Burger/Burger.module.css @@ -1,30 +1,30 @@ .Burger { - width: 100%; - margin: auto; - height: 250px; - overflow: scroll; - text-align: center; - font-weight: bold; - font-size: 1.2rem; + width: 100%; + margin: auto; + height: 250px; + overflow: scroll; + text-align: center; + font-weight: bold; + font-size: 1.2rem; } @media (min-width: 500px) and (min-height: 400px) { - .Burger { - width: 350px; - height: 300px; - } + .Burger { + width: 350px; + height: 300px; + } } @media (min-width: 500px) and (min-height: 401px) { - .Burger { - width: 450px; - height: 400px; - } + .Burger { + width: 450px; + height: 400px; + } } @media (min-width: 1000px) and (min-height: 700px) { - .Burger { - width: 700px; - height: 600px; - } -} + .Burger { + width: 700px; + height: 600px; + } +} \ No newline at end of file diff --git a/src/components/Burger/BurgerIngredient/BurgerIngredient.js b/src/components/Burger/BurgerIngredient/BurgerIngredient.js new file mode 100644 index 0000000..e001f2a --- /dev/null +++ b/src/components/Burger/BurgerIngredient/BurgerIngredient.js @@ -0,0 +1,46 @@ +import PropTypes from 'prop-types'; +import React, { Component } from 'react'; +import classes from './BurgerIngredient.module.css'; + + +class BurgerIngredient extends Component { + render () { + let ingredient = null; + + switch ( this.props.type ) { + case ( 'bread-bottom' ): + ingredient =
; + break; + case ( 'bread-top' ): + ingredient = ( +
+
+
+
+ ); + break; + case ( 'meat' ): + ingredient =
; + break; + case ( 'cheese' ): + ingredient =
; + break; + case ( 'bacon' ): + ingredient =
; + break; + case ( 'salad' ): + ingredient =
; + break; + default: + ingredient = null; + } + + return ingredient; + } +} + +BurgerIngredient.propTypes = { + type: PropTypes.string.isRequired +}; + +export default BurgerIngredient; \ No newline at end of file diff --git a/src/components/Burger/BurgerIngredient/BurgerIngredient.jsx b/src/components/Burger/BurgerIngredient/BurgerIngredient.jsx deleted file mode 100644 index 030d0d3..0000000 --- a/src/components/Burger/BurgerIngredient/BurgerIngredient.jsx +++ /dev/null @@ -1,40 +0,0 @@ -import PropTypes from "prop-types"; -import React from "react"; -import classes from "./BurgerIngredient.module.css"; - -const burgerIngredient = props => { - let ingredient = null; - switch (props.type) { - case "bread-bottom": - ingredient =
; - break; - case "bread-top": - ingredient = ( -
-
-
-
- ); - break; - case "meat": - ingredient =
; - break; - case "cheese": - ingredient =
; - break; - case "salad": - ingredient =
; - break; - case "bacon": - ingredient =
; - break; - default: - ingredient = null; - } - return ingredient; -}; -burgerIngredient.propTypes = { - type: PropTypes.string.isRequired -}; - -export default burgerIngredient; diff --git a/src/components/Burger/OrderSummary/OrderSummary.js b/src/components/Burger/OrderSummary/OrderSummary.js new file mode 100644 index 0000000..d27a7ac --- /dev/null +++ b/src/components/Burger/OrderSummary/OrderSummary.js @@ -0,0 +1,37 @@ +import React, { Component } from 'react'; + +import Aux from '../../../hoc/Aux/Aux'; +import Button from '../../UI/Button/Button'; + +class OrderSummary extends Component { + // This could be a functional component, doesn't have to be a class + componentWillUpdate() { + console.log('[OrderSummary] WillUpdate'); + } + + render () { + const ingredientSummary = Object.keys( this.props.ingredients ) + .map( igKey => { + return ( +
  • + {igKey}: {this.props.ingredients[igKey]} +
  • ); + } ); + + return ( + +

    Your Order

    +

    A delicious burger with the following ingredients:

    +
      + {ingredientSummary} +
    +

    Total Price: {this.props.price.toFixed( 2 )}

    +

    Continue to Checkout?

    + + +
    + ); + } +} + +export default OrderSummary; \ No newline at end of file diff --git a/src/components/Burger/OrderSummary/OrderSummary.jsx b/src/components/Burger/OrderSummary/OrderSummary.jsx deleted file mode 100644 index 9613dc4..0000000 --- a/src/components/Burger/OrderSummary/OrderSummary.jsx +++ /dev/null @@ -1,29 +0,0 @@ -import React from "react"; -import Button from "../../UI/Button/Button"; - -const orderSummary = props => ( - <> -

    Your order

    -

    A delicious burger with the next ingredients:

    -
      - {Object.keys(props.ingredients).map(key => ( -
    • - {key}: - {props.ingredients[key]} -
    • - ))} -
    -

    - Total price: {props.totalPrice} -

    -

    Continue to checkout?

    - - - -); - -export default orderSummary; diff --git a/src/components/Layout/Layout.jsx b/src/components/Layout/Layout.jsx deleted file mode 100644 index dc7df7b..0000000 --- a/src/components/Layout/Layout.jsx +++ /dev/null @@ -1,30 +0,0 @@ -import React, { Component } from "react"; -import SideDrawer from "../Navigation/SideDrawer/SideDrawer"; -import Toolbar from "../Navigation/Toolbar/Toolbar"; -import classes from "./Layout.module.css"; - -class Layout extends Component { - state = { - showSidedrawer: false - }; - toggleSidedrawerHandler = () => { - this.setState(prevState => { - return { showSidedrawer: !prevState.showSidedrawer }; - }); - }; - render() { - return ( - <> -
    - - -
    -
    {this.props.children}
    - - ); - } -} -export default Layout; diff --git a/src/components/Layout/Layout.module.css b/src/components/Layout/Layout.module.css deleted file mode 100644 index e79fa5c..0000000 --- a/src/components/Layout/Layout.module.css +++ /dev/null @@ -1,3 +0,0 @@ -.Content { - margin-top: 72px; -} diff --git a/src/components/Logo/Logo.js b/src/components/Logo/Logo.js new file mode 100644 index 0000000..9a00013 --- /dev/null +++ b/src/components/Logo/Logo.js @@ -0,0 +1,12 @@ +import React from 'react'; +import burgerLogo from '../../assets/images/burger-logo.png'; +import classes from './Logo.module.css'; + + +const logo = (props) => ( +
    + MyBurger +
    +); + +export default logo; \ No newline at end of file diff --git a/src/components/Logo/Logo.jsx b/src/components/Logo/Logo.jsx deleted file mode 100644 index 0847dd9..0000000 --- a/src/components/Logo/Logo.jsx +++ /dev/null @@ -1,11 +0,0 @@ -import React from "react"; -import burgerLogo from "../../assets/images/burger-logo.png"; -import classes from "./Logo.module.css"; - -const logo = () => ( -
    - logo -
    -); - -export default logo; diff --git a/src/components/Logo/Logo.module.css b/src/components/Logo/Logo.module.css index cdd4909..2f99ba9 100644 --- a/src/components/Logo/Logo.module.css +++ b/src/components/Logo/Logo.module.css @@ -1,10 +1,11 @@ .Logo { - background: #fff; - padding: 8px; - height: 100%; - box-sizing: border-box; - border-radius: 5px; + background-color: white; + padding: 8px; + height: 100%; + box-sizing: border-box; + border-radius: 5px; } + .Logo img { - height: 100%; -} + height: 100%; +} \ No newline at end of file diff --git a/src/components/Navigation/NavigationItems/NavigationItem/NavigationItem.js b/src/components/Navigation/NavigationItems/NavigationItem/NavigationItem.js new file mode 100644 index 0000000..2a776a7 --- /dev/null +++ b/src/components/Navigation/NavigationItems/NavigationItem/NavigationItem.js @@ -0,0 +1,15 @@ +import React from 'react'; +import { NavLink } from 'react-router-dom'; +import classes from './NavigationItem.module.css'; + + +const navigationItem = ( props ) => ( +
  • + {props.children} +
  • +); + +export default navigationItem; \ No newline at end of file diff --git a/src/components/Navigation/NavigationItems/NavigationItem/NavigationItem.jsx b/src/components/Navigation/NavigationItems/NavigationItem/NavigationItem.jsx deleted file mode 100644 index cdbae06..0000000 --- a/src/components/Navigation/NavigationItems/NavigationItem/NavigationItem.jsx +++ /dev/null @@ -1,14 +0,0 @@ -import React from "react"; -import classes from "./NavigationItem.module.css"; - -const navigationItem = props => { - return ( -
  • - - {props.children} - -
  • - ); -}; - -export default navigationItem; diff --git a/src/components/Navigation/NavigationItems/NavigationItem/NavigationItem.module.css b/src/components/Navigation/NavigationItems/NavigationItem/NavigationItem.module.css index a2ec418..96afea3 100644 --- a/src/components/Navigation/NavigationItems/NavigationItem/NavigationItem.module.css +++ b/src/components/Navigation/NavigationItems/NavigationItem/NavigationItem.module.css @@ -1,41 +1,45 @@ .NavigationItem { - margin: 10px 0; - box-sizing: border-box; - display: block; - width: 100%; + margin: 10px 0; + box-sizing: border-box; + display: block; + width: 100%; } + .NavigationItem a { - color: #8f5c2c; - text-decoration: none; - width: 100%; - box-sizing: border-box; - display: block; + color: #8F5C2C; + text-decoration: none; + width: 100%; + box-sizing: border-box; + display: block; } + .NavigationItem a:hover, .NavigationItem a:active, .NavigationItem a.active { - color: #40a4c8; + color: #40A4C8; } @media (min-width: 500px) { - .NavigationItem { - margin: 0; - display: flex; - height: 100%; - width: auto; - align-items: center; - } - .NavigationItem a { - color: #fff; - height: 100%; - padding: 16px 10px; - border-bottom: 4px solid transparent; - } - .NavigationItem a:hover, - .NavigationItem a:active, - .NavigationItem a.active { - background-color: #8f5c2c; - border-bottom: 4px solid #40a4c8; - color: #fff; - } -} + .NavigationItem { + margin: 0; + display: flex; + height: 100%; + width: auto; + align-items: center; + } + + .NavigationItem a { + color: white; + height: 100%; + padding: 16px 10px; + border-bottom: 4px solid transparent; + } + + .NavigationItem a:hover, + .NavigationItem a:active, + .NavigationItem a.active { + background-color: #8F5C2C; + border-bottom: 4px solid #40A4C8; + color: white; + } +} \ No newline at end of file diff --git a/src/components/Navigation/NavigationItems/NavigationItems.js b/src/components/Navigation/NavigationItems/NavigationItems.js new file mode 100644 index 0000000..056fcd0 --- /dev/null +++ b/src/components/Navigation/NavigationItems/NavigationItems.js @@ -0,0 +1,13 @@ +import React from 'react'; +import NavigationItem from './NavigationItem/NavigationItem'; +import classes from './NavigationItems.module.css'; + + +const navigationItems = () => ( +
      + Burger Builder + Orders +
    +); + +export default navigationItems; \ No newline at end of file diff --git a/src/components/Navigation/NavigationItems/NavigationItems.jsx b/src/components/Navigation/NavigationItems/NavigationItems.jsx deleted file mode 100644 index 02acd93..0000000 --- a/src/components/Navigation/NavigationItems/NavigationItems.jsx +++ /dev/null @@ -1,16 +0,0 @@ -import React from "react"; -import NavigationItem from "./NavigationItem/NavigationItem"; -import classes from "./NavigationItems.module.css"; - -const navigationItems = () => { - return ( -
      - - Burger Builder - - Checkout -
    - ); -}; - -export default navigationItems; diff --git a/src/components/Navigation/NavigationItems/NavigationItems.module.css b/src/components/Navigation/NavigationItems/NavigationItems.module.css index f5bac0f..4f810d8 100644 --- a/src/components/Navigation/NavigationItems/NavigationItems.module.css +++ b/src/components/Navigation/NavigationItems/NavigationItems.module.css @@ -1,13 +1,15 @@ .NavigationItems { - margin: 0; - padding: 0; - list-style: none; - display: flex; - flex-flow: column; - height: 100%; + margin: 0; + padding: 0; + list-style: none; + display: flex; + flex-flow: column; + align-items: center; + height: 100%; } + @media (min-width: 500px) { - .NavigationItems { - flex-flow: row; - } -} + .NavigationItems { + flex-flow: row; + } +} \ No newline at end of file diff --git a/src/components/Navigation/SideDrawer/DrawerToggle/DrawerToggle.js b/src/components/Navigation/SideDrawer/DrawerToggle/DrawerToggle.js new file mode 100644 index 0000000..6ffc5ad --- /dev/null +++ b/src/components/Navigation/SideDrawer/DrawerToggle/DrawerToggle.js @@ -0,0 +1,13 @@ +import React from 'react'; +import classes from './DrawerToggle.module.css'; + + +const drawerToggle = (props) => ( +
    +
    +
    +
    +
    +); + +export default drawerToggle; \ No newline at end of file diff --git a/src/components/Navigation/SideDrawer/DrawerToggle/DrawerToggle.jsx b/src/components/Navigation/SideDrawer/DrawerToggle/DrawerToggle.jsx deleted file mode 100644 index 27bef0e..0000000 --- a/src/components/Navigation/SideDrawer/DrawerToggle/DrawerToggle.jsx +++ /dev/null @@ -1,14 +0,0 @@ -import React from "react"; -import classes from "./DrawerToggle.module.css"; - -const DrawerToggle = props => { - return ( -
    -
    -
    -
    -
    - ); -}; - -export default DrawerToggle; diff --git a/src/components/Navigation/SideDrawer/SideDrawer.js b/src/components/Navigation/SideDrawer/SideDrawer.js new file mode 100644 index 0000000..c7b46d2 --- /dev/null +++ b/src/components/Navigation/SideDrawer/SideDrawer.js @@ -0,0 +1,29 @@ +import React from 'react'; +import Aux from '../../../hoc/Aux/Aux'; +import Logo from '../../Logo/Logo'; +import Backdrop from '../../UI/Backdrop/Backdrop'; +import NavigationItems from '../NavigationItems/NavigationItems'; +import classes from './SideDrawer.module.css'; + + +const sideDrawer = ( props ) => { + let attachedClasses = [classes.SideDrawer, classes.Close]; + if (props.open) { + attachedClasses = [classes.SideDrawer, classes.Open]; + } + return ( + + +
    +
    + +
    + +
    +
    + ); +}; + +export default sideDrawer; \ No newline at end of file diff --git a/src/components/Navigation/SideDrawer/SideDrawer.jsx b/src/components/Navigation/SideDrawer/SideDrawer.jsx deleted file mode 100644 index 64a069b..0000000 --- a/src/components/Navigation/SideDrawer/SideDrawer.jsx +++ /dev/null @@ -1,27 +0,0 @@ -import React from "react"; -import Logo from "../../Logo/Logo"; -import Backdrop from "../../UI/Backdrop/Backdrop"; -import NavigationItems from "../NavigationItems/NavigationItems"; -import classes from "./SideDrawer.module.css"; - -const sideDrawer = props => { - let attachedClasses = [classes.SideDrawer, classes.Close]; - if (props.open) { - attachedClasses = [classes.SideDrawer, classes.Open]; - } - return ( - <> - -
    -
    - -
    - -
    - - ); -}; - -export default sideDrawer; diff --git a/src/components/Navigation/SideDrawer/SideDrawer.module.css b/src/components/Navigation/SideDrawer/SideDrawer.module.css index 1b4318f..d042661 100644 --- a/src/components/Navigation/SideDrawer/SideDrawer.module.css +++ b/src/components/Navigation/SideDrawer/SideDrawer.module.css @@ -1,31 +1,32 @@ .SideDrawer { - position: fixed; - width: 280px; - max-width: 70%; - height: 100%; - left: 0; - top: 0; - z-index: 200; - background-color: #fff; - padding: 32px 16px; - box-sizing: border-box; - transition: transform 0.3s ease-out; -} -.Logo { - height: 11%; - margin-bottom: 32px; + position: fixed; + width: 280px; + max-width: 70%; + height: 100%; + left: 0; + top: 0; + z-index: 200; + background-color: white; + padding: 32px 16px; + box-sizing: border-box; + transition: transform 0.3s ease-out; } @media (min-width: 500px) { - .SideDrawer { - display: none; - } + .SideDrawer { + display: none; + } } .Open { - transform: translateX(0); + transform: translateX(0); } .Close { - transform: translateX(-100%); + transform: translateX(-100%); } + +.Logo { + height: 11%; + margin-bottom: 32px; +} \ No newline at end of file diff --git a/src/components/Navigation/Toolbar/Toolbar.js b/src/components/Navigation/Toolbar/Toolbar.js new file mode 100644 index 0000000..16f1c64 --- /dev/null +++ b/src/components/Navigation/Toolbar/Toolbar.js @@ -0,0 +1,20 @@ +import React from 'react'; +import Logo from '../../Logo/Logo'; +import NavigationItems from '../NavigationItems/NavigationItems'; +import DrawerToggle from '../SideDrawer/DrawerToggle/DrawerToggle'; +import classes from './Toolbar.module.css'; + + +const toolbar = ( props ) => ( +
    + +
    + +
    + +
    +); + +export default toolbar; \ No newline at end of file diff --git a/src/components/Navigation/Toolbar/Toolbar.jsx b/src/components/Navigation/Toolbar/Toolbar.jsx deleted file mode 100644 index d446b46..0000000 --- a/src/components/Navigation/Toolbar/Toolbar.jsx +++ /dev/null @@ -1,21 +0,0 @@ -import React from "react"; -import Logo from "../../Logo/Logo"; -import NavigationItems from "../NavigationItems/NavigationItems"; -import DrawerToggle from "../SideDrawer/DrawerToggle/DrawerToggle"; -import classes from "./Toolbar.module.css"; - -const toolbar = props => { - return ( -
    - -
    - -
    - -
    - ); -}; - -export default toolbar; diff --git a/src/components/Navigation/Toolbar/Toolbar.module.css b/src/components/Navigation/Toolbar/Toolbar.module.css index 15a2ee3..de56a35 100644 --- a/src/components/Navigation/Toolbar/Toolbar.module.css +++ b/src/components/Navigation/Toolbar/Toolbar.module.css @@ -1,26 +1,28 @@ .Toolbar { - height: 56px; - width: 100%; - position: fixed; - top: 0; - left: 0; - background-color: #703b09; - display: flex; - justify-content: space-between; - align-items: center; - padding: 0 20px; - box-sizing: border-box; - z-index: 90; + height: 56px; + width: 100%; + position: fixed; + top: 0; + left: 0; + background-color: #703B09; + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 20px; + box-sizing: border-box; + z-index: 90; } + .Toolbar nav { - height: 100%; + height: 100%; } + .Logo { - height: 80%; + height: 80%; } @media (max-width: 499px) { - .DesktopOnly { - display: none; - } -} + .DesktopOnly { + display: none; + } +} \ No newline at end of file diff --git a/src/components/Order/CheckoutSummary/CheckoutSummary.js b/src/components/Order/CheckoutSummary/CheckoutSummary.js new file mode 100644 index 0000000..cc802ec --- /dev/null +++ b/src/components/Order/CheckoutSummary/CheckoutSummary.js @@ -0,0 +1,24 @@ +import React from 'react'; +import Burger from '../../Burger/Burger'; +import Button from '../../UI/Button/Button'; +import classes from './CheckoutSummary.module.css'; + + +const checkoutSummary = (props) => { + return ( +
    +

    We hope it tastes well!

    +
    + +
    + + +
    + ); +} + +export default checkoutSummary; \ No newline at end of file diff --git a/src/components/Order/CheckoutSummary/CheckoutSummary.module.css b/src/components/Order/CheckoutSummary/CheckoutSummary.module.css new file mode 100644 index 0000000..f6df948 --- /dev/null +++ b/src/components/Order/CheckoutSummary/CheckoutSummary.module.css @@ -0,0 +1,11 @@ +.CheckoutSummary { + text-align: center; + width: 80%; + margin: auto; +} + +@media (min-width: 600px) { + .CheckoutSummary { + width: 500px; + } +} \ No newline at end of file diff --git a/src/components/Order/Order.js b/src/components/Order/Order.js new file mode 100644 index 0000000..26635e4 --- /dev/null +++ b/src/components/Order/Order.js @@ -0,0 +1,37 @@ +import React from 'react'; +import classes from './Order.module.css'; + + +const order = ( props ) => { + const ingredients = []; + + for ( let ingredientName in props.ingredients ) { + ingredients.push( + { + name: ingredientName, + amount: props.ingredients[ingredientName] + } + ); + } + + const ingredientOutput = ingredients.map(ig => { + return {ig.name} ({ig.amount}); + }); + + return ( +
    +

    Ingredients: {ingredientOutput}

    +

    Price: USD {Number.parseFloat( props.price ).toFixed( 2 )}

    +
    + ); +}; + +export default order; \ No newline at end of file diff --git a/src/components/Order/Order.module.css b/src/components/Order/Order.module.css new file mode 100644 index 0000000..a2aa212 --- /dev/null +++ b/src/components/Order/Order.module.css @@ -0,0 +1,8 @@ +.Order { + width: 80%; + border: 1px solid #eee; + box-shadow: 0 2px 3px #ccc; + padding: 10px; + margin: 10px auto; + box-sizing: border-box; +} \ No newline at end of file diff --git a/src/components/UI/Backdrop/Backdrop.js b/src/components/UI/Backdrop/Backdrop.js new file mode 100644 index 0000000..28d9739 --- /dev/null +++ b/src/components/UI/Backdrop/Backdrop.js @@ -0,0 +1,9 @@ +import React from 'react'; +import classes from './Backdrop.module.css'; + + +const backdrop = (props) => ( + props.show ?
    : null +); + +export default backdrop; \ No newline at end of file diff --git a/src/components/UI/Backdrop/Backdrop.jsx b/src/components/UI/Backdrop/Backdrop.jsx deleted file mode 100644 index f61bd25..0000000 --- a/src/components/UI/Backdrop/Backdrop.jsx +++ /dev/null @@ -1,9 +0,0 @@ -import React from "react"; -import classes from "./Backdrop.module.css"; - -const backdrop = props => - props.show ? ( -
    - ) : null; - -export default backdrop; diff --git a/src/components/UI/Backdrop/Backdrop.module.css b/src/components/UI/Backdrop/Backdrop.module.css index af1983a..d09bc2d 100644 --- a/src/components/UI/Backdrop/Backdrop.module.css +++ b/src/components/UI/Backdrop/Backdrop.module.css @@ -1,8 +1,9 @@ .Backdrop { - width: 100%; - height: 100%; - position: fixed; - z-index: 100; - background: rgba(0, 0, 0, 0.5); - top: 0; -} + width: 100%; + height: 100%; + position: fixed; + z-index: 100; + left: 0; + top: 0; + background-color: rgba(0, 0, 0, 0.5); +} \ No newline at end of file diff --git a/src/components/UI/Button/Button.js b/src/components/UI/Button/Button.js index 7dbeabf..0b120c5 100644 --- a/src/components/UI/Button/Button.js +++ b/src/components/UI/Button/Button.js @@ -1,13 +1,12 @@ -import React from "react"; -import classes from "./Button.module.css"; +import React from 'react'; +import classes from './Button.module.css'; -const button = props => ( - + +const button = (props) => ( + ); -export default button; +export default button; \ No newline at end of file diff --git a/src/components/UI/Button/Button.module.css b/src/components/UI/Button/Button.module.css index b51461e..53e31da 100644 --- a/src/components/UI/Button/Button.module.css +++ b/src/components/UI/Button/Button.module.css @@ -15,6 +15,11 @@ padding-left: 0; } +.Button:disabled { + color: #ccc; + cursor: not-allowed; +} + .Success { color: #5C9210; } diff --git a/src/components/UI/Input/Input.js b/src/components/UI/Input/Input.js new file mode 100644 index 0000000..35bea28 --- /dev/null +++ b/src/components/UI/Input/Input.js @@ -0,0 +1,59 @@ +import React from 'react'; +import classes from './Input.module.css'; + + +const input = ( props ) => { + let inputElement = null; + const inputClasses = [classes.InputElement]; + + if (props.invalid && props.shouldValidate && props.touched) { + inputClasses.push(classes.Invalid); + } + + switch ( props.elementType ) { + case ( 'input' ): + inputElement = ; + break; + case ( 'textarea' ): + inputElement =