mirror of
https://github.com/vercel/commerce.git
synced 2025-07-30 13:41:22 +00:00
Header style improvements
This commit is contained in:
@@ -6,7 +6,11 @@
|
||||
}
|
||||
|
||||
.item {
|
||||
@apply mr-6 cursor-pointer relative;
|
||||
@apply mr-6 cursor-pointer relative transition ease-in-out duration-100;
|
||||
|
||||
&:hover {
|
||||
@apply text-gray-500;
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
@apply mr-0;
|
||||
|
@@ -16,17 +16,20 @@ const countItems = (count: number, items: any[]) =>
|
||||
items.reduce(countItem, count)
|
||||
|
||||
const UserNav: FC<Props> = ({ className }) => {
|
||||
const { openSidebar } = useUI()
|
||||
const { openSidebar, closeSidebar, displaySidebar } = useUI()
|
||||
const { data } = useCart()
|
||||
const itemsCount = Object.values(data?.line_items ?? {}).reduce(countItems, 0)
|
||||
|
||||
return (
|
||||
<nav className={cn(s.root, className)}>
|
||||
<ul className={s.list}>
|
||||
<li className={s.item} onClick={() => openSidebar()}>
|
||||
<li
|
||||
className={s.item}
|
||||
onClick={() => (displaySidebar ? closeSidebar() : openSidebar())}
|
||||
>
|
||||
<Bag />
|
||||
{itemsCount > 0 && (
|
||||
<span className="bg-black h-4 w-4 absolute rounded-full inset-3 text-white flex items-center justify-center font-bold text-xs">
|
||||
<span className="bg-black h-4 w-4 absolute rounded-full right-3 top-3 text-white flex items-center justify-center font-bold text-xs">
|
||||
{itemsCount}
|
||||
</span>
|
||||
)}
|
||||
|
Reference in New Issue
Block a user