From 30e0c3cd17c5ccba2831d4f17ffd996a768fe1f7 Mon Sep 17 00:00:00 2001 From: Eduardo Liron Date: Thu, 13 Jul 2023 17:28:13 -0300 Subject: [PATCH 1/9] fet(HeaderBar): add back button to header bar --- src/App.tsx | 8 ++-- src/components/HeaderBar.tsx | 76 ++++++++++++++++++++---------------- src/routes/FoodPage.tsx | 10 +---- 3 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 21cfe2a..898d750 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -12,23 +12,23 @@ import { useTranslation } from "react-i18next"; export default function App() { const [food, setFood] = useState([] as FoodList); - + const { i18n } = useTranslation(); const lngs = { en: { nativeName: "English" }, it: { nativeName: "Italiano" } } as { [key:string]: any} - + if (food.length === 0) fetchData(setFood, `ITALIA-fruits-and-veggies.csv`) return ( food.length > 0 ? -
+
{Object.keys(lngs).map((lng) => ( ))} - + } /> }> } /> diff --git a/src/components/HeaderBar.tsx b/src/components/HeaderBar.tsx index fd2ed09..f1cc060 100644 --- a/src/components/HeaderBar.tsx +++ b/src/components/HeaderBar.tsx @@ -7,22 +7,23 @@ import { alpha, Toolbar, IconButton, - Typography, - InputBase -} from "@mui/material"; -import MenuIcon from '@mui/icons-material/Menu'; -import SearchIcon from '@mui/icons-material/Search'; -import { useTranslation, } from "react-i18next"; + InputBase, +} from "@mui/material"; +import MenuIcon from "@mui/icons-material/Menu"; +import SearchIcon from "@mui/icons-material/Search"; +import { useTranslation } from "react-i18next"; +import { ArrowBackIosNew } from "@mui/icons-material"; +import { useNavigate, useLocation } from "react-router-dom"; type Props = { - ifSearched: boolean - food: FoodList - onSearch: (query: string, food: FoodList) => void - toggleDrawer: () => void -} + ifSearched: boolean; + food: FoodList; + onSearch: (query: string, food: FoodList) => void; + toggleDrawer: () => void; +}; export default function HeaderBar(props: Props) { - const { t } = useTranslation() + const { t } = useTranslation(); const query = useRef() as React.MutableRefObject; useEffect(() => { @@ -56,7 +57,7 @@ export default function HeaderBar(props: Props) { backgroundColor: alpha(theme.palette.common.white, 0.25), }, marginLeft: 0, - width: "8em", + width: "100%", [theme.breakpoints.up("sm")]: { marginLeft: theme.spacing(1), width: "auto", @@ -95,26 +96,24 @@ export default function HeaderBar(props: Props) { marginTop: "0", })); + const navigate = useNavigate(); + const loaction = useLocation(); + return ( - - - - - - {t("Header_appTitle")} - + + {loaction.pathname.split("/")[1] === "foodpage" && ( + navigate(-1)} + sx={{ mr: "auto" }} + > + + + )} -
handleSubmit(e)}> + handleSubmit(e)}>
+ + +
-
); } diff --git a/src/routes/FoodPage.tsx b/src/routes/FoodPage.tsx index d731b61..0b833fa 100644 --- a/src/routes/FoodPage.tsx +++ b/src/routes/FoodPage.tsx @@ -98,14 +98,7 @@ export default function FoodPage({ food }: { food: FoodList }) { } return ( - - backBtn(-1)}>{t('backButton')} - + {t(seasonStatus)} - {/* BOTTOM GRID WITH MONTHS */} Date: Fri, 14 Jul 2023 11:22:24 +0200 Subject: [PATCH 2/9] Update README.md Add data sources --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 0c255fc..6234b92 100644 --- a/README.md +++ b/README.md @@ -16,4 +16,8 @@ Just go to https://fuzue.github.io/seasonfood/ ans this will redirect you to the 1. npm i 2. npm run build +# Data sources + +Source of data for fruits and vegetables from [Slow Food Italy Guide](https://www.slowfood.it/wp-content/uploads/blu_facebook_uploads/2014/09/ita_guida_consumo_b.pdf) + From 6ed2979b4e95218d8d0b039f372d79479c19ea2f Mon Sep 17 00:00:00 2001 From: Elena Volpato Date: Fri, 14 Jul 2023 11:46:39 +0200 Subject: [PATCH 3/9] Create LICENSE --- LICENSE | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4f4cc80 --- /dev/null +++ b/LICENSE @@ -0,0 +1,28 @@ +BSD 3-Clause License + +Copyright (c) 2023, SeasonalFood + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. From 119fec4a0b584370d56306179d3ec9f2a33f82d2 Mon Sep 17 00:00:00 2001 From: Eduardo Liron Date: Fri, 14 Jul 2023 09:45:57 -0300 Subject: [PATCH 4/9] fix(FoodPage): restore layout and fix break --- src/routes/FoodPage.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/routes/FoodPage.tsx b/src/routes/FoodPage.tsx index 0b833fa..1fb5ac2 100644 --- a/src/routes/FoodPage.tsx +++ b/src/routes/FoodPage.tsx @@ -98,7 +98,10 @@ export default function FoodPage({ food }: { food: FoodList }) { } return ( - + {t(seasonStatus)} + {/* BOTTOM GRID WITH MONTHS */} Date: Fri, 14 Jul 2023 10:24:57 -0300 Subject: [PATCH 5/9] fix(FoodPage): fix searchbar position --- src/components/HeaderBar.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/components/HeaderBar.tsx b/src/components/HeaderBar.tsx index f1cc060..048d0af 100644 --- a/src/components/HeaderBar.tsx +++ b/src/components/HeaderBar.tsx @@ -56,12 +56,8 @@ export default function HeaderBar(props: Props) { "&:hover": { backgroundColor: alpha(theme.palette.common.white, 0.25), }, - marginLeft: 0, - width: "100%", - [theme.breakpoints.up("sm")]: { - marginLeft: theme.spacing(1), - width: "auto", - }, + marginLeft: 'auto', + width: "auto" })); const SearchIconWrapper = styled("div")(({ theme }) => ({ @@ -109,7 +105,6 @@ export default function HeaderBar(props: Props) { color="inherit" aria-label="open drawer" onClick={() => navigate(-1)} - sx={{ mr: "auto" }} > From 2df827a5a04fc261fec94bcb10bf6a63d12c0038 Mon Sep 17 00:00:00 2001 From: Eduardo Liron Date: Fri, 14 Jul 2023 10:31:52 -0300 Subject: [PATCH 6/9] fix(FoodPage): fix transition on searchbar --- src/components/HeaderBar.tsx | 1 + src/main.css | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/HeaderBar.tsx b/src/components/HeaderBar.tsx index 048d0af..c91a8c3 100644 --- a/src/components/HeaderBar.tsx +++ b/src/components/HeaderBar.tsx @@ -76,6 +76,7 @@ export default function HeaderBar(props: Props) { padding: theme.spacing(1, 1, 1, 0), // vertical padding + font size from searchIcon paddingLeft: `calc(1em + ${theme.spacing(4)})`, + transition: theme.transitions.create('width'), width: "100%", [theme.breakpoints.up("sm")]: { width: "12ch", diff --git a/src/main.css b/src/main.css index 99fc942..805fd35 100644 --- a/src/main.css +++ b/src/main.css @@ -43,7 +43,6 @@ img { a { color: inherit; text-decoration: none; - } .button-wrapper { From 74451275ac25e2a0a6c59af14cefaca11438f54f Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Fri, 14 Jul 2023 15:33:45 +0200 Subject: [PATCH 7/9] remove unused components --- src/routes/FoodPage.tsx | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/routes/FoodPage.tsx b/src/routes/FoodPage.tsx index 1fb5ac2..56662e7 100644 --- a/src/routes/FoodPage.tsx +++ b/src/routes/FoodPage.tsx @@ -2,7 +2,7 @@ import type { FoodList } from "../types/food"; import { currentMonth } from "../utils/utils"; import { useParams, useNavigate, Link } from "react-router-dom"; import { useEffect } from "react"; -import { Box, Typography, Button, Grid } from "@mui/material"; +import { Box, Typography, Grid } from "@mui/material"; import { styled } from "@mui/material/styles"; import { useTranslation } from "react-i18next"; @@ -35,7 +35,6 @@ export default function FoodPage({ food }: { food: FoodList }) { } } - const backBtn = useNavigate(); const image = selectedFood ? selectedFood.image.toLowerCase() : ''; const monthColor = (month: string) => { @@ -53,13 +52,6 @@ export default function FoodPage({ food }: { food: FoodList }) { } } }; - const BackButton = styled(Button)(() => ({ - width: "5em", - margin: "0", - position: "absolute", - left: "80%", - top: "14%", - })); const GridBox = styled(Box)(() => ({ width: '6em', From 6d40a97e87fa2f3a0c617feed0a09b233e91271f Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Fri, 14 Jul 2023 16:12:36 +0200 Subject: [PATCH 8/9] Add android build instructions --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 6234b92..b076785 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,13 @@ Just go to https://fuzue.github.io/seasonfood/ ans this will redirect you to the 1. npm i 2. npm run build +## Build Android app + +First you do need to have Android SDK and Anbdroid Studio installed. After that you can open the project in Android Studio with: + +1. npm run build-app +2. ANDROID_SDK=the-path-top-android-sdk CAPACITOR_ANDROID_STUDIO_PATH=the-path-to-android-studio/bin/studio.sh npm run run-app-android + # Data sources Source of data for fruits and vegetables from [Slow Food Italy Guide](https://www.slowfood.it/wp-content/uploads/blu_facebook_uploads/2014/09/ita_guida_consumo_b.pdf) From 0bf10e01f4132cca7bf3ce21650daa7eb0987d17 Mon Sep 17 00:00:00 2001 From: Eduardo Liron Date: Fri, 14 Jul 2023 11:51:15 -0300 Subject: [PATCH 9/9] fix(HeaderBar): fix navigation to new model --- src/components/HeaderBar.tsx | 51 ++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/src/components/HeaderBar.tsx b/src/components/HeaderBar.tsx index c91a8c3..c584d67 100644 --- a/src/components/HeaderBar.tsx +++ b/src/components/HeaderBar.tsx @@ -94,22 +94,39 @@ export default function HeaderBar(props: Props) { })); const navigate = useNavigate(); - const loaction = useLocation(); + const location = useLocation(); + + function leftButton() { + if(location.pathname.split("/")[1] === "foodpage") { + return ( + navigate(-1)} + > + + + ) + } + return ( + + + + ) + } return ( - {loaction.pathname.split("/")[1] === "foodpage" && ( - navigate(-1)} - > - - - )} + {leftButton()} - - - );