-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from 4lysson-a/dev
Merge develop into main
- Loading branch information
Showing
9 changed files
with
267 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}} | ||
/> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.