Skip to content

Commit

Permalink
Merge pull request #48 from 4lysson-a/dev
Browse files Browse the repository at this point in the history
Merge develop into main
  • Loading branch information
4lysson-a authored Aug 28, 2024
2 parents 89a678c + 879724f commit 7f0c1ba
Show file tree
Hide file tree
Showing 9 changed files with 267 additions and 178 deletions.
6 changes: 4 additions & 2 deletions frontend/src/components/shared/Product/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function AddToCart({ product }) {
);
}

export default function Product({ product }) {
export default function Product({ product, ...rest }) {
const [expanded, setExpanded] = React.useState(false);

const handleClick = () => {
Expand All @@ -69,7 +69,9 @@ export default function Product({ product }) {
return (
<div
className="relative w-full p-3 flex flex-col gap-4"
onClick={handleClick}>
onClick={handleClick}
{...rest}
>
<div className={sty("flex w-full flex-row gap-2 justify-between")}>
<div className="flex flex-col gap-2">
<p className="text-texts font-bold text-md capitalize max-w-32">
Expand Down
40 changes: 29 additions & 11 deletions frontend/src/components/shared/ScrollShadow/index.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,41 @@
import React from "react";

export default function ScrollShadow({ color, ...rest }) {
export default function ScrollShadow({ color, variant = "vertical", ...rest }) {
const _color = color || "var(--background)";

const verticalStyle = {
background: `
linear-gradient(${_color} 30%, rgba(255, 255, 255, 0)) center top,
linear-gradient(rgba(255, 255, 255, 0), ${_color} 70%) center bottom,
radial-gradient(farthest-side at 50% 0, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0)) center top,
radial-gradient(farthest-side at 50% 100%, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0)) center bottom
`,
backgroundRepeat: "no-repeat",
backgroundSize: "100% 40px, 100% 40px, 100% 14px, 100% 14px",
backgroundAttachment: "local, local, scroll, scroll",
};

const horizontalStyle = {
background: `
linear-gradient(90deg, ${_color} 30%, rgba(255, 255, 255, 0)) left center,
linear-gradient(90deg, rgba(255, 255, 255, 0), ${_color} 70%) right center,
radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0)) left center,
radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0)) right center
`,
backgroundRepeat: "no-repeat",
backgroundSize: "40px 100%, 40px 100%, 14px 100%, 14px 100%",
backgroundAttachment: "local, local, scroll, scroll",
};

const style = variant === "horizontal" ? horizontalStyle : verticalStyle;

return (
<div
{...rest}
style={{
overflow: "auto",
background: `
linear-gradient(${_color} 30%, rgba(255, 255, 255, 0)) center top,
linear-gradient(rgba(255, 255, 255, 0), ${_color} 70%) center bottom,
radial-gradient(farthest-side at 50% 0, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0)) center top,
radial-gradient(farthest-side at 50% 100%, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0)) center bottom
`,
backgroundRepeat: "no-repeat",
backgroundSize: "100% 40px, 100% 40px, 100% 14px, 100% 14px",
backgroundAttachment: "local, local, scroll, scroll",
...style,
}}
/>
);
}
}
29 changes: 15 additions & 14 deletions frontend/src/hooks/zustand/(public)/useMenu.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import { create } from "zustand";

const useMenu = create((set, get) => ({
menu: {
company: null,
products: null,
categories: null,
},
menu: {
company: null,
products: null,
categories: null
},

filter: {
category: null,
},
filter: {
category: null,
ignoreScroll: false
},

getFilter: () => {
const category = get()?.menu?.categories?.items[0]?.get("name");
set({ filter: { category } });
},
getFilter: () => {
const category = get()?.menu?.categories?.items[0]?.get("name");
set({ filter: { category } });
},

setFilter: (filter) => set({ filter }),
setFilter: filter => set({ filter }),

setMenu: (menu) => set({ menu }),
setMenu: menu => set({ menu })
}));

export default useMenu;
106 changes: 61 additions & 45 deletions frontend/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,71 +3,87 @@
@tailwind utilities;

@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(10px);
}
from {
opacity: 0;
transform: translateY(10px);
}

to {
opacity: 1;
transform: translateY(0);
}
to {
opacity: 1;
transform: translateY(0);
}
}

:root {
--full: #FFF;
--background-invert: #1b1c1c;
--texts: #0e0e0e;
--card: #e4e4e4;
--primary: #763C28;
--background: #f5f5f5;
--color-border: #575757;
--color-border-contrast: #e4e4e4;
--floating-button-background: #C6A484;
--menu-dashboard-bg: rgba(255, 255, 255, 0.79);
--full: #fff;
--background-invert: #1b1c1c;
--texts: #0e0e0e;
--smooth-contrast: rgba(14, 14, 14, 0.2);
--card: #e4e4e4;
--primary: #763c28;
--background: #f5f5f5;
--color-border: #575757;
--color-border-contrast: #e4e4e4;
--floating-button-background: #c6a484;
--menu-dashboard-bg: rgba(255, 255, 255, 0.79);
}

@media (prefers-color-scheme: dark) {
:root {
--full: #000;
--texts: #fff;
--background-invert: #f5f5f5;
--card: #343434;
--primary: #eaa134;
--background: #1b1c1c;
--color-border: #cecece;
--color-border-contrast: #343434;
--floating-button-background: #674628;
--menu-dashboard-bg: rgba(26, 25, 25, 0.79);

}
:root {
--full: #000;
--texts: #fff;
--smooth-contrast: rgba(255, 255, 255, 0.2);
--background-invert: #f5f5f5;
--card: #343434;
--primary: #eaa134;
--background: #1b1c1c;
--color-border: #cecece;
--color-border-contrast: #343434;
--floating-button-background: #674628;
--menu-dashboard-bg: rgba(26, 25, 25, 0.79);
}
}

.fadein {
animation: fadeIn 0.3s ease-in-out;
animation: fadeIn 0.3s ease-in-out;
}

.fadeGradient {
background: linear-gradient(270deg, var(--background) 0%, rgba(186, 186, 186, 0) 100%)
background: linear-gradient(270deg, var(--background) 0%, rgba(186, 186, 186, 0) 100%);
}

.hide-scroll::-webkit-scrollbar {
display: none;
width: 0;
height: 0;
}

.hide-scroll::-webkit-scrollbar-thumb {
display: none;
}

.hide-scroll {
-ms-overflow-style: none;
scrollbar-width: none;
}

body,
html,
#root {
width: 100%;
height: 100%;
transition: 0s;
color: var(--texts);
box-sizing: border-box;
background-color: var(--background);
width: 100%;
height: 100%;
transition: 0s;
color: var(--texts);
box-sizing: border-box;
background-color: var(--background);

-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
scroll-behavior: smooth;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
scroll-behavior: smooth;
}

* {
margin: 0;
padding: 0;
transition: 0.2s ease all;
margin: 0;
padding: 0;
transition: 0.2s ease all;
}
46 changes: 46 additions & 0 deletions frontend/src/pages/Menu/Category/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import ScrollShadow from "@/components/shared/ScrollShadow";
import useMenu from "@/hooks/zustand/(public)/useMenu";
import { sty } from "@/utils";
import React from "react";

const Item = ({ name }) => {
const [filter, setFilter] = useMenu(s => [s.filter, s.setFilter]);

const link = `#${name}`;

const handleClick = () => {
setFilter({ ...filter, category: name?.trim() });
};

return (
<a
href={link}
onClick={handleClick}
className={sty("text-lg font-bold text-nowrap", filter.category === name && "text-primary font-bold")}
>
{name}
</a>
);
};

export default function Categories() {
const menu = useMenu(s => s.menu);

if (menu?.categories) {
return (
<ScrollShadow
variant="horizontal"
color="var(--background)"
className=" border-b border-smooth-contrast sticky top-0 z-40 items-center flex-row flex w-full "
>
<div className="overflow-auto bg-background hide-scroll flex flex-row gap-5 pr-5 p-2 pl-5">
{menu?.categories?.items?.map(category => (
<Item key={category.id} name={category?.get("name")} />
))}
</div>
</ScrollShadow>
);
}

return null;
}
40 changes: 0 additions & 40 deletions frontend/src/pages/Menu/CategoryItems/index.jsx

This file was deleted.

Loading

0 comments on commit 7f0c1ba

Please sign in to comment.