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

Redesign menus dishes view for mobile #9

Merged
merged 4 commits into from
Apr 26, 2024
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
2 changes: 1 addition & 1 deletion website/components/FoodCategory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const FoodCategory = () => {
<SectionTitle
title="What's on your mind?"
paragraph="We believe in the power of expression – so go ahead, let your thoughts flow."
customClass="mx-auto text-center mb-28 mt-20"
customClass="mx-auto text-center mb-12 sm:mb-28 mt-20"
/>

<Swiper
Expand Down
3 changes: 2 additions & 1 deletion website/components/ItemCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const ItemCard = () => {
<SectionTitle
title="Most browsed items from the location"
paragraph="Connect Locally: Must-Visit Places in Your Neighborhood. In our vibrant community, explore top-rated local experiences."
customClass="mb-28"
customClass="mb-12 sm:mb-28"
/>
{itemData ? (
<div className="grid grid-cols-1 gap-x-8 gap-y-10 md:grid-cols-2 md:gap-x-6 lg:gap-x-8 xl:grid-cols-3">
Expand All @@ -74,6 +74,7 @@ const ItemCard = () => {
<InView triggerOnce className="animated-fade-y">
{({ inView, ref, entry }) => (
<Link
target="_top"
ref={ref}
href={
"/restaurants/" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Footer from "@/components/Footer";
import Header from "@/components/Header";
import ScrollToTop from "@/components/ScrollToTop";
import Providers from "./providers";
import Providers from "../../pages/providers";
import Head from "next/head";

export default function RootLayout({
Expand Down
25 changes: 25 additions & 0 deletions website/components/Layout/withoutFooter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"use client";

import Footer from "@/components/Footer";
import Header from "@/components/Header";
import ScrollToTop from "@/components/ScrollToTop";
import Providers from "../../pages/providers";
import Head from "next/head";

export default function LayoutWithoutFooter({
children,
}: {
children: React.ReactNode;
}) {
return (
<div className="dark:bg-black">
<Head>
<title>Bite Space</title>
</Head>
<Providers>
<Header />
{children}
</Providers>
</div>
);
}
10 changes: 6 additions & 4 deletions website/components/YouMayLike/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const YouMayLike = () => {
.from("restaurants")
.select("*")
.eq("is_public", true)
.order('id', { ascending: true })
.order("id", { ascending: true })
.limit(4);

if (error) return error;
Expand All @@ -45,13 +45,14 @@ const YouMayLike = () => {
<SectionTitle
title="You May Like This"
paragraph="From trending dishes to hidden gems, this personalized recommendation feature ensures that your next food adventure is always exciting and tailored to your unique taste buds."
customClass="mb-28 mt-20"
customClass="mb-12 sm:mb-28 mt-20"
/>

<div className="animated-fade-y grid grid-cols-1 gap-4 xs:gap-10 lg:grid-cols-2">
{restaurants.map((item: any, key: any) => (
<Link
key={key}
target="_top"
key={"may-like-" + item.id}
href={
"/restaurants/" +
encodeURIComponent(
Expand All @@ -74,7 +75,8 @@ const YouMayLike = () => {
<SwiperSlide key={key}>
<Image
src={data}
fill
height={100}
width={100}
className="h-full w-full object-cover"
alt="item-image"
loading="lazy"
Expand Down
21 changes: 14 additions & 7 deletions website/components/withScrollRestoration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,24 @@ function withScrollRestoration(WrappedComponent: any) {
window.sessionStorage.setItem(
`scrollY:${router.asPath}`,
window.scrollY.toString()
);
}
};

const handleRouteComplete = (url: any) => {
);
}
};
const handleRouteComplete = (url: any) => {
const scrollY = window.sessionStorage.getItem(`scrollY:${url}`);
if (scrollY) {
window.scrollTo(0, parseInt(scrollY));
if (url?.includes("/restaurants")) {
// restaurants data is taking time to load that's why added timout to scroll the page
setTimeout(function () {
window.scroll(0, parseInt(scrollY));
}, 900);
} else {
window.scrollTo(0, parseInt(scrollY));
}
}
};

const handlePopState = () => {
// Retrieve the scroll position for the previous page
const scrollY = window.sessionStorage.getItem(`scrollY:${prevPageUrl}`);
Expand Down
2 changes: 1 addition & 1 deletion website/pages/about/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import RootLayout from "@/components/Layout/root";
import withScrollRestoration from "@/components/withScrollRestoration";
import RootLayout from "@/pages/layout";
import Image from "next/image";
import Link from "next/link";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { useEffect, useState } from "react";
import { CategoryData, RestaurantData } from "@/types/category-by-id";
import { useRouter } from "next/router";
import Restaurant from "./restaurant";
import RootLayout from "../layout";
import RootLayout from "../../components/Layout/root";
import NotFound from "@/components/PageNotFound";

const Category = () => {
const router = useRouter();
const { id } = router.query;
const suffix = id?.toString().substring(id?.lastIndexOf("-") + 1);
const { category } = router.query;
const suffix = category?.toString().substring(category?.lastIndexOf("-") + 1);

const [isRestaurantsLoading, setIsRestaurantsLoading] = useState(true);
const [categoryData, setCategoryData] = useState<CategoryData | null>(null);
Expand Down
2 changes: 1 addition & 1 deletion website/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Hero from "@/components/Hero";
import ItemCard from "@/components/ItemCard";
import YouMayLike from "@/components/YouMayLike";
import { Inter } from "@next/font/google";
import RootLayout from "./layout";
import RootLayout from "../components/Layout/root";
import withScrollRestoration from "@/components/withScrollRestoration";

const inter = Inter({ subsets: ["latin"] });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ import SectionTitle from "@/components/Common/SectionTitle";
import "swiper/css";
import "swiper/css/effect-fade";
import { useRouter } from "next/router";
import RootLayout from "@/pages/layout";
import RootLayout from "@/components/Layout/root";
import NoDataFound from "@/components/NoDataFound";

const CuisineRestaurant = () => {
const router = useRouter();
const { id } = router.query;
const { restaurant } = router.query;

const [isRestaurantsLoading, setIsRestaurantsLoading] = useState(true);
const [restaurants, setRestaurantsData] = useState<any[]>([]);

useEffect(() => {
const fetchData = async () => {
try {
if (id) {
if (restaurant) {
const { data, error } = await supabase
.from("restaurants")
.select("*")
.contains("tags", [(id as string)?.replace(/-/g, " ")]);
.contains("tags", [(restaurant as string)?.replace(/-/g, " ")]);

if (error) throw error;

Expand All @@ -45,15 +45,15 @@ const CuisineRestaurant = () => {
};

fetchData();
}, [id]);
}, [restaurant]);

return (
<>
<RootLayout>
<section className="py-16 md:py-20 lg:py-28">
<div className="container">
<SectionTitle
title={(id as string)?.replace(/-/g, " ")}
title={(restaurant as string)?.replace(/-/g, " ")}
paragraph="From trending dishes to hidden gems, this personalized recommendation feature ensures that your next food adventure is always exciting and tailored to your unique taste buds."
customClass="mb-28 mt-20 capitalize animated-fade-y"
/>
Expand Down
Loading
Loading