Skip to content

Commit

Permalink
fixed merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
liwoo committed Oct 24, 2024
2 parents 24e6feb + 9f583fb commit 913c5f7
Show file tree
Hide file tree
Showing 8 changed files with 492 additions and 287 deletions.
4 changes: 2 additions & 2 deletions app/components/atoms/collapsible-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ export const CollapsibleChild: React.FC<CollapsibleChildProps> = ({
to={href}
className={({ isActive }) =>
isActive
? "rounded-lg px-3 py-2 text-muted-foreground transition-all hover:text-black bg-slate-100"
: "rounded-lg px-3 py-2 text-muted-foreground transition-all hover:text-black"
? "rounded-lg px-3 py-2 text-muted-foreground transition-all hover:text-primary bg-slate-100"
: "rounded-lg px-3 py-2 text-muted-foreground transition-all hover:text-primary"
}
>
{childLabel}
Expand Down
56 changes: 48 additions & 8 deletions app/components/blocks/layout-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ import {
} from 'lucide-react';
import { Button } from '../ui/button';

import {
Sheet,
SheetTrigger,
SheetClose,
SheetDescription,
SheetTitle,
SheetContent,
SheetHeader,
SheetFooter,
} from '../ui/sheet';
import {
DropdownMenu,
DropdownMenuContent,
Expand All @@ -26,6 +36,10 @@ import {
} from '@/components/theme-switcher';
import { LanguageItem } from '../atoms/language-item';
import { cn } from '@/lib/utils';
import { Label } from '../ui/label';
import { Input } from '../ui/input';
import Sidebar from './sidebar';
import MdtoSmSidebar from './md-sm-sidebar';

interface LayoutHeaderProps {
title?: string;
Expand Down Expand Up @@ -56,7 +70,7 @@ const LayoutHeader = ({
//TODO: Render a submenu modal
console.log('show submenu');
}, []);

const shouldShowSidebar = isTablet || isMobile;
const langaugeArray = [
'🇺🇸 English',
'🇫🇷 French',
Expand All @@ -72,12 +86,26 @@ const LayoutHeader = ({
`lg:fixed bg-card border rounded-lg flex items-center justify-between p-4 lg:p-6 mx-auto`
)}
>
<p className="flex gap-x-2 items-center">
{isTablet && (
<MenuIcon onClick={onToggleTabletMenu} className="size-6" />
<div className="flex gap-x-2 items-center">
{shouldShowSidebar && (
<Sheet>
<SheetTrigger asChild>
<MenuIcon className="size-6" />
</SheetTrigger>
<SheetContent
side="left"
className="rounded-r-3xl h-full w-[90%] lg:w-[300px] px-1"
>
<MdtoSmSidebar
toggleSidebar={showSubmenu}
className="rounded-none border-none cursor-pointer"
/>
</SheetContent>
<SheetClose />
</Sheet>
)}
<h1 className="text-xl">{title}</h1>
</p>
</div>
{isMobile && (
<EllipsisIcon onClick={showSubmenu} className="size-6" />
)}
Expand Down Expand Up @@ -132,33 +160,45 @@ const LayoutHeader = ({
<DropdownMenuContent className="mt-2">
<DropdownMenuLabel>Theme</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuItem asChild>
<DropdownMenuItem
asChild
className="flex items-center gap-2"
>
<button
type="button"
className="w-full"
onClick={() => setTheme('light')}
aria-selected={theme === 'light'}
>
<SunIcon className="size-6" />
Light
</button>
</DropdownMenuItem>
<DropdownMenuItem asChild>
<DropdownMenuItem
asChild
className="flex items-center gap-2"
>
<button
type="button"
className="w-full"
onClick={() => setTheme('dark')}
aria-selected={theme === 'dark'}
>
<MoonIcon className="size-6" />
Dark
</button>
</DropdownMenuItem>
<DropdownMenuItem asChild>
<DropdownMenuItem
asChild
className="flex items-center gap-2"
>
<button
type="button"
className="w-full"
onClick={() => setTheme('system')}
aria-selected={theme === 'system'}
>
<LaptopIcon className="size-6" />
System
</button>
</DropdownMenuItem>
Expand Down
141 changes: 141 additions & 0 deletions app/components/blocks/md-sm-sidebar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import { Link } from '@remix-run/react';
import {
ArrowLeft,
Bell,
ChevronLeft,
ChevronRight,
Search,
} from 'lucide-react';
import { Button } from '../ui/button';
import { Input } from '../ui/input';

import { ProfileDropdown } from './profile-dropdown';
import { NavItem } from '../atoms/nav-item';
import { CollapsibleChild, CollapsibleItem } from '../atoms/collapsible-item';
import { FC, Key, useState } from 'react';
import { cn } from '@/lib/styles';
import { navItems, secondaryNavItems } from '@/config/nav';

interface SidebarProps {
minimalSidebar?: boolean;
toggleSidebar: () => void;
className?: string;
}

const MdtoSmSidebar: FC<SidebarProps> = ({
minimalSidebar = false,
toggleSidebar,
className,
}) => {
return (
<div className={cn('bg-muted/40 h-screen w-full', className)}>
<div className="flex m-4 mt-0 rounded-md h-[97%] lg:fixed flex-col gap-2">
<div className="flex h-14 items-center border-b px-4 lg:h-[60px] lg:px-6">
{!minimalSidebar ? (
<Link
to="/"
className="flex items-center gap-2 font-semibold"
>
<img
src="./famcon-logo.png"
className="size-10"
alt="logo"
/>
<span className="">FamCon</span>
</Link>
) : null}
</div>
<div className="flex-1">
{minimalSidebar ? (
<div
className="relative items-center flex justify-center cursor-pointer"
onClick={toggleSidebar}
>
<Search className="absolute left-4 ml-3 top-2.5 s-6 text-muted-foreground hover:text-black" />
{/* TODO: automatically set focus to the search inpu field */}
</div>
) : (
<form className="mx-4 my-4">
<div className="relative">
<Search className="absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground" />
<Input
type="search"
placeholder="Search products..."
className="w-full appearance-none bg-background pl-8 shadow-none"
/>
</div>
</form>
)}
<nav
className={cn(
'grid items-center px-2 text-sm lg:px-4 gap-3',
minimalSidebar ? 'mt-12' : ''
)}
>
{navItems.map((item) => {
if (item.children) {
return (
<div className="lg:text-lg mt-2">
<CollapsibleItem
key={item.label}
label={item.label}
icon={item.icon}
withMinimalSidebar={minimalSidebar}
>
{item.children.map(
(child: {
label:
| Key
| null
| string
| undefined;
href: string;
}) => (
<CollapsibleChild
key={child.label}
childLabel={child.label}
href={child.href}
/>
)
)}
</CollapsibleItem>
</div>
);
}

return (
<NavItem
key={item.label}
label={item.label}
href={item.href}
icon={item.icon}
minimal={minimalSidebar}
/>
);
})}

{/* seperator line */}
<hr className="my-2 border-t border-gray-300/30 w-full" />

<div className="my-4">
{secondaryNavItems.map((item) => (
<NavItem
label={item.label}
href={item.href}
icon={item.icon}
key={item.label}
minimal={minimalSidebar}
/>
))}
</div>
</nav>
</div>
<div className="mt-auto p-4 w-full sm:w-[300px] overflow-hidden">
<ProfileDropdown withMinimal={minimalSidebar} />
</div>
</div>
</div>
);
};

export default MdtoSmSidebar;
5 changes: 4 additions & 1 deletion app/components/blocks/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@ import { navItems, secondaryNavItems } from '@/config/nav';
interface SidebarProps {
minimalSidebar?: boolean;
toggleSidebar: () => void;
className?: string;
}

const Sidebar: FC<SidebarProps> = ({
minimalSidebar = false,
toggleSidebar,
className,
}) => {
// TODO(glen): Move this to a separate file
//

return (
<div className="hidden bg-muted/40 md:block">
<div className={cn('hidden bg-muted/40 md:block', className)}>
<div className="flex m-4 mt-0 border bg-card rounded-md h-[97%] lg:fixed flex-col gap-2">
<div className="flex h-14 items-center border-b px-4 lg:h-[60px] lg:px-6">
{!minimalSidebar ? (
Expand Down
Loading

0 comments on commit 913c5f7

Please sign in to comment.