Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from eri/dev-e
Browse files Browse the repository at this point in the history
Merging changes from dev branch to main
  • Loading branch information
Eray C authored Nov 1, 2021
2 parents 964e483 + c219d80 commit f2c0c2d
Show file tree
Hide file tree
Showing 22 changed files with 578 additions and 108 deletions.
72 changes: 2 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,2 @@
# Getting Started with Create React App

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `yarn start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.\
You will also see any lint errors in the console.

### `yarn test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `yarn build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `yarn eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

### Code Splitting

This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)

### Analyzing the Bundle Size

This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)

### Making a Progressive Web App

This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)

### Advanced Configuration

This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)

### Deployment

This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)

### `yarn build` fails to minify

This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
# magic-kebab
Site sous React de restauration avec personnalisation de commande
2 changes: 0 additions & 2 deletions README.old.md

This file was deleted.

4 changes: 2 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="icon" href="%PUBLIC_URL%/logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
Expand All @@ -24,7 +24,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>Magic Kebab</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
10 changes: 10 additions & 0 deletions public/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/public.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
25 changes: 0 additions & 25 deletions src/App.js

This file was deleted.

155 changes: 155 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
import * as React from "react";
import "./index.css";

// Components
// import { Loading } from "./components/Loading";
import { Navbar } from "./components/Navbar";
import { IngredientBox } from "./components/IngredientBox";
import { Button } from "./components/Button";

import { defaultOrder, defaultBreads, defaultMeats, defaultVegetables, defaultSauces } from "./data";

function App() {
const [currentOrder, setCurrentOrder] = React.useState(defaultOrder);
const [isLoading, setIsLoading] = React.useState(true);
const [timerHandle, setTimerHandle] = React.useState(null);
const [orderDisplay, setOrderDisplay] = React.useState({bread: true, meat: false, vegetables: false, sauces: false});
const [orderLimited, setOrderLimited] = React.useState({"vegetables": { limited: false, amount: 3}, "sauces": { limited: false, amount: 2}});

React.useEffect(() => {
setTimerHandle(setTimeout(() => setIsLoading(false), 2500));
return () => {
clearTimeout(timerHandle);
setTimerHandle(null);
};
}, [setTimerHandle]);

if (isLoading) { return ( <div>its loading</div> ); }

const handleOnSelected = (ingredient, value, display) => {
const newOrder = {...currentOrder};
newOrder[ingredient] = value;
setCurrentOrder(newOrder);
if (display) { handleDisplay(display.hide, display.show); }
}

const handleOnAdded = (ingredient, value) => {
if (handleOrderLimited(ingredient)) { return false };
const newOrder = {...currentOrder};
newOrder[ingredient].push(value);
setCurrentOrder(newOrder);
}

const handleOrderLimited = (ingredient) => {
const newLimit = {...orderLimited};
if (currentOrder[ingredient].length === orderLimited[ingredient].amount) {
console.log("limited: ", currentOrder[ingredient].length, orderLimited[ingredient].amount);
newLimit[ingredient].limited = true;
setOrderLimited(newLimit);
return true;
}
// console.log("not limited:", currentOrder[ingredient].length, orderLimited[ingredient].amount);
return false;
}

const handleDisplay = (toHide, toShow) => {
// Used to toggle the display of vegetables & sauces
const canDisplay = {...orderDisplay};
canDisplay[toHide] = false;
canDisplay[toShow] = true;
setOrderDisplay(canDisplay);
}

return (
<div className="min-h-screen bg-yellow-25">
<Navbar />
{console.log(currentOrder)}
{console.log(orderLimited)}

{/* Choose Bread */}
<div id="ChooseBread" className={
`flex flex-col items-center justify-center my-5 ${orderDisplay.bread ? ' block' : ' hidden'}`
}>

<div className="my-3 text-3xl font-bold text-center text-red-1000">
Choisissez le pain
</div>

<div className="flex flex-col items-center justify-center mt-5 space-x-4 sm:flex-row">
{defaultBreads.map((bread) => (
<div key={bread.name} onClick={() => handleOnSelected('bread', bread.name, {hide:'bread', show:'meat'})}>
<IngredientBox name={bread.name} image={bread.image} />
</div>
))}
</div>
</div>

{/* Choose Meat */}
<div id="ChooseMeat" className={
`flex flex-col items-center justify-center my-5 ${orderDisplay.meat && !orderDisplay.bread ? ' block' : ' hidden'}`
}>

<div className="my-3 text-3xl font-bold text-center text-red-1000">
Passons à la viande... ou au tofu ?
</div>

<div className="flex flex-col items-center justify-center mt-5 space-x-4 sm:flex-row">
{defaultMeats.map((meat) => (
<div key={meat.name} onClick={() => handleOnSelected('meat', meat.name, {hide:'meat', show:'vegetables'})}>
<IngredientBox name={meat.name} image={meat.image} />
</div>
))}
</div>
<div onClick={() => handleDisplay('meat', 'bread')}>
<Button text={"Précédent"} />
</div>
</div>

{/* Choose Vegetables */}
<div id="ChooseVegetables" className={
`flex flex-col items-center justify-center my-5 ${orderDisplay.vegetables && !orderDisplay.meat ? ' block' : ' hidden'}`
}>
<div className="my-3 text-3xl font-bold text-center text-red-1000">
Des crudités pour votre merveille ?
</div>

<div className="flex flex-col items-center justify-center mt-5 space-x-4 sm:flex-row">
{defaultVegetables.map((veg) => (
<div key={veg.name} onClick={() => handleOnAdded('vegetables', veg.name)}>
<IngredientBox name={veg.name} image={veg.image} isDisabled={() => handleOrderLimited('vegetables')} />
</div>
))}
</div>
<div onClick={() => handleDisplay('vegetables', 'meat')}>
<Button text={"Précédent"} />
</div>

<div onClick={() => handleDisplay('vegetables', 'sauces')}>
<Button text={"Suivant"} />
</div>
</div>

{/* Choose Sauces */}
<div id="ChooseSauces" className={
`flex flex-col items-center justify-center my-5`
+ `${currentOrder.bread && currentOrder.meat}` ? `hidden` : `hidden`
}>
<div className="my-3 text-3xl font-bold text-center text-red-1000">
Des sauces pour donner de la couleur à cette magie ?
</div>

<div className="flex flex-col items-center justify-center mt-5 space-x-4 sm:flex-row">
{defaultSauces.map((veg) => (
<div key={veg.name}>
<IngredientBox name={veg.name} image={veg.image} />
</div>
))}
</div>
<Button />
</div>

</div>
);
};

export default App;
Loading

0 comments on commit f2c0c2d

Please sign in to comment.