uup
This commit is contained in:
41
app/components/layout/Container.tsx
Normal file
41
app/components/layout/Container.tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
import { ReactNode } from 'react';
|
||||
import { getResponsiveClasses, defaultLayoutConfig, type LayoutConfig } from '~/lib/layout-utils';
|
||||
|
||||
interface ContainerProps {
|
||||
children: ReactNode;
|
||||
className?: string;
|
||||
config?: Partial<LayoutConfig>;
|
||||
maxWidth?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full';
|
||||
padding?: boolean;
|
||||
}
|
||||
|
||||
export function Container({
|
||||
children,
|
||||
className = '',
|
||||
config = {},
|
||||
maxWidth = 'full',
|
||||
padding = true
|
||||
}: ContainerProps) {
|
||||
const layoutConfig = { ...defaultLayoutConfig, ...config };
|
||||
const classes = getResponsiveClasses(layoutConfig);
|
||||
|
||||
const maxWidthClasses = {
|
||||
sm: 'max-w-sm',
|
||||
md: 'max-w-md',
|
||||
lg: 'max-w-lg',
|
||||
xl: 'max-w-xl',
|
||||
'2xl': 'max-w-2xl',
|
||||
full: 'max-w-full',
|
||||
};
|
||||
|
||||
const paddingClass = padding ? 'px-4 sm:px-6 lg:px-8' : '';
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`${classes.container} ${maxWidthClasses[maxWidth]} ${paddingClass} ${className}`}
|
||||
dir={layoutConfig.direction}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
170
app/components/layout/DashboardLayout.tsx
Normal file
170
app/components/layout/DashboardLayout.tsx
Normal file
@@ -0,0 +1,170 @@
|
||||
import { ReactNode, useState, useEffect } from 'react';
|
||||
import { Form } from '@remix-run/react';
|
||||
import { Sidebar } from './Sidebar';
|
||||
import { Container } from './Container';
|
||||
import { Flex } from './Flex';
|
||||
import { Text, Button } from '../ui';
|
||||
|
||||
interface DashboardLayoutProps {
|
||||
children: ReactNode;
|
||||
user: {
|
||||
id: number;
|
||||
name: string;
|
||||
authLevel: number;
|
||||
};
|
||||
}
|
||||
|
||||
export function DashboardLayout({ children, user }: DashboardLayoutProps) {
|
||||
const [sidebarCollapsed, setSidebarCollapsed] = useState(false);
|
||||
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
|
||||
const [isMobile, setIsMobile] = useState(false);
|
||||
|
||||
// Handle responsive behavior
|
||||
useEffect(() => {
|
||||
const checkMobile = () => {
|
||||
const mobile = window.innerWidth < 768;
|
||||
setIsMobile(mobile);
|
||||
|
||||
// Auto-collapse sidebar on mobile
|
||||
if (mobile) {
|
||||
setSidebarCollapsed(true);
|
||||
}
|
||||
};
|
||||
|
||||
checkMobile();
|
||||
window.addEventListener('resize', checkMobile);
|
||||
|
||||
return () => window.removeEventListener('resize', checkMobile);
|
||||
}, []);
|
||||
|
||||
// Load sidebar state from localStorage
|
||||
useEffect(() => {
|
||||
const savedState = localStorage.getItem('sidebarCollapsed');
|
||||
if (savedState !== null && !isMobile) {
|
||||
setSidebarCollapsed(JSON.parse(savedState));
|
||||
}
|
||||
}, [isMobile]);
|
||||
|
||||
// Save sidebar state to localStorage
|
||||
const handleSidebarToggle = () => {
|
||||
const newState = !sidebarCollapsed;
|
||||
setSidebarCollapsed(newState);
|
||||
if (!isMobile) {
|
||||
localStorage.setItem('sidebarCollapsed', JSON.stringify(newState));
|
||||
}
|
||||
};
|
||||
|
||||
const handleMobileMenuClose = () => {
|
||||
setMobileMenuOpen(false);
|
||||
};
|
||||
|
||||
const getAuthLevelText = (authLevel: number) => {
|
||||
switch (authLevel) {
|
||||
case 1:
|
||||
return "مدير عام";
|
||||
case 2:
|
||||
return "مدير";
|
||||
case 3:
|
||||
return "مستخدم";
|
||||
default:
|
||||
return "غير محدد";
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gray-50 flex" dir="rtl">
|
||||
{/* Sidebar */}
|
||||
<Sidebar
|
||||
isCollapsed={sidebarCollapsed}
|
||||
onToggle={handleSidebarToggle}
|
||||
isMobile={isMobile}
|
||||
isOpen={mobileMenuOpen}
|
||||
onClose={handleMobileMenuClose}
|
||||
userAuthLevel={user.authLevel}
|
||||
/>
|
||||
|
||||
{/* Main Content */}
|
||||
<div className={`
|
||||
flex-1 min-h-screen transition-all duration-300 ease-in-out
|
||||
${!isMobile ? (sidebarCollapsed ? 'mr-16' : 'mr-64') : 'mr-0'}
|
||||
`}>
|
||||
{/* Header */}
|
||||
<div className="bg-white shadow-sm border-b border-gray-200 sticky top-0 z-10">
|
||||
<div className="max-w-full mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div className="flex justify-between items-center py-4">
|
||||
{/* Mobile menu button and title */}
|
||||
<div className="flex items-center gap-4">
|
||||
{isMobile && (
|
||||
<button
|
||||
onClick={() => setMobileMenuOpen(true)}
|
||||
className="p-2 rounded-md text-gray-400 hover:text-gray-600 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||
>
|
||||
<svg
|
||||
className="h-6 w-6"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth={2}
|
||||
d="M4 6h16M4 12h16M4 18h16"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
)}
|
||||
|
||||
{/* Page title - only show on mobile when sidebar is closed */}
|
||||
{isMobile && (
|
||||
<h1 className="text-lg font-semibold text-gray-900">
|
||||
لوحة التحكم
|
||||
</h1>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* User info and actions */}
|
||||
<div className="flex items-center gap-4">
|
||||
<div className="text-right">
|
||||
<div className="text-sm text-gray-600">
|
||||
مرحباً، <span className="font-medium text-gray-900">{user.name}</span>
|
||||
</div>
|
||||
<div className="text-xs text-gray-500">
|
||||
{getAuthLevelText(user.authLevel)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Form action="/logout" method="post">
|
||||
<button
|
||||
type="submit"
|
||||
className="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-white bg-red-600 hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 transition-colors duration-150"
|
||||
>
|
||||
<svg
|
||||
className="h-4 w-4 mr-1"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth={2}
|
||||
d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"
|
||||
/>
|
||||
</svg>
|
||||
خروج
|
||||
</button>
|
||||
</Form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Page Content */}
|
||||
<main className="flex-1 p-6">
|
||||
{children}
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
102
app/components/layout/Flex.tsx
Normal file
102
app/components/layout/Flex.tsx
Normal file
@@ -0,0 +1,102 @@
|
||||
import { ReactNode } from 'react';
|
||||
import { getResponsiveClasses, defaultLayoutConfig, type LayoutConfig } from '~/lib/layout-utils';
|
||||
|
||||
interface FlexProps {
|
||||
children: ReactNode;
|
||||
className?: string;
|
||||
config?: Partial<LayoutConfig>;
|
||||
direction?: 'row' | 'col' | 'row-reverse' | 'col-reverse';
|
||||
align?: 'start' | 'center' | 'end' | 'stretch' | 'baseline';
|
||||
justify?: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly';
|
||||
wrap?: boolean;
|
||||
gap?: 'sm' | 'md' | 'lg' | 'xl';
|
||||
responsive?: {
|
||||
sm?: Partial<Pick<FlexProps, 'direction' | 'align' | 'justify'>>;
|
||||
md?: Partial<Pick<FlexProps, 'direction' | 'align' | 'justify'>>;
|
||||
lg?: Partial<Pick<FlexProps, 'direction' | 'align' | 'justify'>>;
|
||||
xl?: Partial<Pick<FlexProps, 'direction' | 'align' | 'justify'>>;
|
||||
};
|
||||
}
|
||||
|
||||
export function Flex({
|
||||
children,
|
||||
className = '',
|
||||
config = {},
|
||||
direction = 'row',
|
||||
align = 'start',
|
||||
justify = 'start',
|
||||
wrap = false,
|
||||
gap = 'md',
|
||||
responsive = {}
|
||||
}: FlexProps) {
|
||||
const layoutConfig = { ...defaultLayoutConfig, ...config };
|
||||
const classes = getResponsiveClasses(layoutConfig);
|
||||
|
||||
const directionClasses = {
|
||||
row: layoutConfig.direction === 'rtl' ? 'flex-row-reverse' : 'flex-row',
|
||||
col: 'flex-col',
|
||||
'row-reverse': layoutConfig.direction === 'rtl' ? 'flex-row' : 'flex-row-reverse',
|
||||
'col-reverse': 'flex-col-reverse',
|
||||
};
|
||||
|
||||
const alignClasses = {
|
||||
start: 'items-start',
|
||||
center: 'items-center',
|
||||
end: 'items-end',
|
||||
stretch: 'items-stretch',
|
||||
baseline: 'items-baseline',
|
||||
};
|
||||
|
||||
const justifyClasses = {
|
||||
start: 'justify-start',
|
||||
center: 'justify-center',
|
||||
end: 'justify-end',
|
||||
between: 'justify-between',
|
||||
around: 'justify-around',
|
||||
evenly: 'justify-evenly',
|
||||
};
|
||||
|
||||
const gapClasses = {
|
||||
sm: 'gap-2',
|
||||
md: 'gap-4',
|
||||
lg: 'gap-6',
|
||||
xl: 'gap-8',
|
||||
};
|
||||
|
||||
const wrapClass = wrap ? 'flex-wrap' : '';
|
||||
|
||||
// Build responsive classes
|
||||
const responsiveClasses = Object.entries(responsive)
|
||||
.map(([breakpoint, props]) => {
|
||||
const responsiveClassList = [];
|
||||
|
||||
if (props.direction) {
|
||||
const responsiveDirection = props.direction === 'row' && layoutConfig.direction === 'rtl'
|
||||
? 'flex-row-reverse'
|
||||
: props.direction === 'row-reverse' && layoutConfig.direction === 'rtl'
|
||||
? 'flex-row'
|
||||
: directionClasses[props.direction];
|
||||
responsiveClassList.push(`${breakpoint}:${responsiveDirection}`);
|
||||
}
|
||||
|
||||
if (props.align) {
|
||||
responsiveClassList.push(`${breakpoint}:${alignClasses[props.align]}`);
|
||||
}
|
||||
|
||||
if (props.justify) {
|
||||
responsiveClassList.push(`${breakpoint}:${justifyClasses[props.justify]}`);
|
||||
}
|
||||
|
||||
return responsiveClassList.join(' ');
|
||||
})
|
||||
.join(' ');
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`flex ${directionClasses[direction]} ${alignClasses[align]} ${justifyClasses[justify]} ${gapClasses[gap]} ${wrapClass} ${responsiveClasses} ${className}`}
|
||||
dir={layoutConfig.direction}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
56
app/components/layout/Grid.tsx
Normal file
56
app/components/layout/Grid.tsx
Normal file
@@ -0,0 +1,56 @@
|
||||
import { ReactNode } from 'react';
|
||||
import { defaultLayoutConfig, type LayoutConfig } from '~/lib/layout-utils';
|
||||
|
||||
interface GridProps {
|
||||
children: ReactNode;
|
||||
className?: string;
|
||||
config?: Partial<LayoutConfig>;
|
||||
cols?: 1 | 2 | 3 | 4 | 6 | 12;
|
||||
gap?: 'sm' | 'md' | 'lg' | 'xl';
|
||||
responsive?: {
|
||||
sm?: 1 | 2 | 3 | 4 | 6 | 12;
|
||||
md?: 1 | 2 | 3 | 4 | 6 | 12;
|
||||
lg?: 1 | 2 | 3 | 4 | 6 | 12;
|
||||
xl?: 1 | 2 | 3 | 4 | 6 | 12;
|
||||
};
|
||||
}
|
||||
|
||||
export function Grid({
|
||||
children,
|
||||
className = '',
|
||||
config = {},
|
||||
cols = 1,
|
||||
gap = 'md',
|
||||
responsive = {}
|
||||
}: GridProps) {
|
||||
const layoutConfig = { ...defaultLayoutConfig, ...config };
|
||||
|
||||
const colsClasses = {
|
||||
1: 'grid-cols-1',
|
||||
2: 'grid-cols-2',
|
||||
3: 'grid-cols-3',
|
||||
4: 'grid-cols-4',
|
||||
6: 'grid-cols-6',
|
||||
12: 'grid-cols-12',
|
||||
};
|
||||
|
||||
const gapClasses = {
|
||||
sm: 'gap-2',
|
||||
md: 'gap-4',
|
||||
lg: 'gap-6',
|
||||
xl: 'gap-8',
|
||||
};
|
||||
|
||||
const responsiveClasses = Object.entries(responsive)
|
||||
.map(([breakpoint, cols]) => `${breakpoint}:${colsClasses[cols]}`)
|
||||
.join(' ');
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`grid-rtl ${colsClasses[cols]} ${gapClasses[gap]} ${responsiveClasses} ${className}`}
|
||||
dir={layoutConfig.direction}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
257
app/components/layout/Sidebar.tsx
Normal file
257
app/components/layout/Sidebar.tsx
Normal file
@@ -0,0 +1,257 @@
|
||||
import { ReactNode, useState, useEffect } from 'react';
|
||||
import { Link, useLocation } from '@remix-run/react';
|
||||
import { getResponsiveClasses, defaultLayoutConfig, type LayoutConfig } from '~/lib/layout-utils';
|
||||
|
||||
interface SidebarProps {
|
||||
isCollapsed: boolean;
|
||||
onToggle: () => void;
|
||||
isMobile: boolean;
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
userAuthLevel: number;
|
||||
}
|
||||
|
||||
interface NavigationItem {
|
||||
name: string;
|
||||
href: string;
|
||||
icon: ReactNode;
|
||||
authLevel?: number; // Minimum auth level required
|
||||
}
|
||||
|
||||
const navigationItems: NavigationItem[] = [
|
||||
{
|
||||
name: 'لوحة التحكم',
|
||||
href: '/dashboard',
|
||||
icon: (
|
||||
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2H5a2 2 0 00-2-2z" />
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M8 5a2 2 0 012-2h4a2 2 0 012 2v6H8V5z" />
|
||||
</svg>
|
||||
),
|
||||
},
|
||||
{
|
||||
name: 'العملاء',
|
||||
href: '/customers',
|
||||
icon: (
|
||||
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197m13.5-9a2.5 2.5 0 11-5 0 2.5 2.5 0 015 0z" />
|
||||
</svg>
|
||||
),
|
||||
},
|
||||
{
|
||||
name: 'المركبات',
|
||||
href: '/vehicles',
|
||||
icon: (
|
||||
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 17a2 2 0 11-4 0 2 2 0 014 0zM19 17a2 2 0 11-4 0 2 2 0 014 0z" />
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 16V6a1 1 0 00-1-1H4a1 1 0 00-1 1v10a1 1 0 001 1h1m8-1a1 1 0 01-1-1V8a1 1 0 011-1h2.586a1 1 0 01.707.293l3.414 3.414a1 1 0 01.293.707V16a1 1 0 01-1 1h-1m-6 0a1 1 0 001 1h4a1 1 0 001-1m-6 0V9a1 1 0 00-1-1v0a1 1 0 00-1 1v8a1 1 0 001 1z" />
|
||||
</svg>
|
||||
),
|
||||
},
|
||||
{
|
||||
name: 'زيارات الصيانة',
|
||||
href: '/maintenance-visits',
|
||||
icon: (
|
||||
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" />
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
||||
</svg>
|
||||
),
|
||||
},
|
||||
{
|
||||
name: 'المصروفات',
|
||||
href: '/expenses',
|
||||
icon: (
|
||||
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M17 9V7a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2m2 4h10a2 2 0 002-2v-6a2 2 0 00-2-2H9a2 2 0 00-2 2v6a2 2 0 002 2zm7-5a2 2 0 11-4 0 2 2 0 014 0z" />
|
||||
</svg>
|
||||
),
|
||||
authLevel: 2, // Admin and above
|
||||
},
|
||||
{
|
||||
name: 'التقارير المالية',
|
||||
href: '/financial-reports',
|
||||
icon: (
|
||||
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z" />
|
||||
</svg>
|
||||
),
|
||||
authLevel: 2, // Admin and above
|
||||
},
|
||||
{
|
||||
name: 'إدارة المستخدمين',
|
||||
href: '/users',
|
||||
icon: (
|
||||
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197m13.5-9a2.5 2.5 0 11-5 0 2.5 2.5 0 015 0z" />
|
||||
</svg>
|
||||
),
|
||||
authLevel: 2, // Admin and above
|
||||
},
|
||||
{
|
||||
name: 'إعدادات النظام',
|
||||
href: '/settings',
|
||||
icon: (
|
||||
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" />
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
||||
</svg>
|
||||
),
|
||||
authLevel: 2, // Admin and above
|
||||
},
|
||||
];
|
||||
|
||||
export function Sidebar({ isCollapsed, onToggle, isMobile, isOpen, onClose, userAuthLevel }: SidebarProps) {
|
||||
const location = useLocation();
|
||||
|
||||
// Filter navigation items based on user auth level
|
||||
const filteredNavItems = navigationItems.filter(item =>
|
||||
!item.authLevel || userAuthLevel <= item.authLevel
|
||||
);
|
||||
|
||||
// Close sidebar on route change for mobile
|
||||
useEffect(() => {
|
||||
if (isMobile && isOpen) {
|
||||
onClose();
|
||||
}
|
||||
}, [location.pathname, isMobile, isOpen, onClose]);
|
||||
|
||||
if (isMobile) {
|
||||
return (
|
||||
<>
|
||||
{/* Mobile overlay */}
|
||||
{isOpen && (
|
||||
<div
|
||||
className="fixed inset-0 bg-black bg-opacity-50 z-40 transition-opacity duration-300"
|
||||
onClick={onClose}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Mobile Sidebar */}
|
||||
<div className={`
|
||||
fixed top-0 right-0 h-full w-64 bg-white shadow-lg z-50 transform transition-transform duration-300 ease-in-out
|
||||
${isOpen ? 'translate-x-0' : 'translate-x-full'}
|
||||
`} dir="rtl">
|
||||
{/* Mobile Header */}
|
||||
<div className="flex items-center justify-between h-16 px-4 border-b border-gray-200">
|
||||
<div className="flex items-center">
|
||||
<div className="h-8 w-8 bg-blue-600 rounded-full flex items-center justify-center">
|
||||
<svg className="h-5 w-5 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 10V3L4 14h7v7l9-11h-7z" />
|
||||
</svg>
|
||||
</div>
|
||||
<h1 className="ml-3 text-lg font-semibold text-gray-900">نظام الصيانة</h1>
|
||||
</div>
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="p-2 rounded-md text-gray-400 hover:text-gray-600 hover:bg-gray-100"
|
||||
>
|
||||
<svg className="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Mobile Navigation */}
|
||||
<nav className="mt-5 px-2 flex-1 overflow-y-auto">
|
||||
<div className="space-y-1">
|
||||
{filteredNavItems.map((item) => {
|
||||
const isActive = location.pathname === item.href;
|
||||
return (
|
||||
<Link
|
||||
key={item.name}
|
||||
to={item.href}
|
||||
className={`
|
||||
group flex items-center px-3 py-2 text-sm font-medium rounded-md transition-colors duration-150 relative
|
||||
${isActive ? 'bg-blue-100 text-blue-900' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'}
|
||||
`}
|
||||
>
|
||||
{isActive && <div className="absolute right-0 top-0 bottom-0 w-1 bg-blue-600 rounded-l-md"></div>}
|
||||
<div className={`flex-shrink-0 ${isActive ? 'text-blue-600' : 'text-gray-400 group-hover:text-gray-500'}`}>
|
||||
{item.icon}
|
||||
</div>
|
||||
<span className="ml-3">{item.name}</span>
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
// Desktop Sidebar
|
||||
return (
|
||||
<div className={`
|
||||
fixed top-0 right-0 h-full bg-white shadow-lg z-40 transition-all duration-300 ease-in-out
|
||||
${isCollapsed ? 'w-16' : 'w-64'}
|
||||
`} dir="rtl">
|
||||
{/* Desktop Header */}
|
||||
<div className="flex items-center justify-between h-16 px-4 border-b border-gray-200">
|
||||
<div className="flex items-center flex-1">
|
||||
<div className="h-8 w-8 bg-blue-600 rounded-full flex items-center justify-center">
|
||||
<svg className="h-5 w-5 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 10V3L4 14h7v7l9-11h-7z" />
|
||||
</svg>
|
||||
</div>
|
||||
{!isCollapsed && (
|
||||
<h1 className="ml-3 text-lg font-semibold text-gray-900">نظام الصيانة</h1>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<button
|
||||
onClick={onToggle}
|
||||
className="p-1 rounded-md text-gray-400 hover:text-gray-600 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||
>
|
||||
<svg
|
||||
className={`h-4 w-4 transform transition-transform duration-200 ${isCollapsed ? 'rotate-180' : ''}`}
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 19l-7-7 7-7" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Desktop Navigation */}
|
||||
<nav className="mt-5 px-2 flex-1 overflow-y-auto">
|
||||
<div className="space-y-1">
|
||||
{filteredNavItems.map((item) => {
|
||||
const isActive = location.pathname === item.href;
|
||||
return (
|
||||
<Link
|
||||
key={item.name}
|
||||
to={item.href}
|
||||
className={`
|
||||
group flex items-center px-3 py-2 text-sm font-medium rounded-md transition-colors duration-150 relative
|
||||
${isActive ? 'bg-blue-100 text-blue-900' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'}
|
||||
${isCollapsed ? 'justify-center' : ''}
|
||||
`}
|
||||
title={isCollapsed ? item.name : undefined}
|
||||
>
|
||||
{isActive && <div className="absolute right-0 top-0 bottom-0 w-1 bg-blue-600 rounded-l-md"></div>}
|
||||
<div className={`flex-shrink-0 ${isActive ? 'text-blue-600' : 'text-gray-400 group-hover:text-gray-500'}`}>
|
||||
{item.icon}
|
||||
</div>
|
||||
{!isCollapsed && (
|
||||
<span className="ml-3 truncate">{item.name}</span>
|
||||
)}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
{/* Desktop Footer */}
|
||||
{!isCollapsed && (
|
||||
<div className="absolute bottom-0 left-0 right-0 p-4 border-t border-gray-200">
|
||||
<div className="text-xs text-gray-500 text-center">
|
||||
نظام إدارة صيانة السيارات
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
5
app/components/layout/index.ts
Normal file
5
app/components/layout/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export { Container } from './Container';
|
||||
export { Grid } from './Grid';
|
||||
export { Flex } from './Flex';
|
||||
export { Sidebar } from './Sidebar';
|
||||
export { DashboardLayout } from './DashboardLayout';
|
||||
Reference in New Issue
Block a user