feat: align projects page with Figma design
This commit is contained in:
parent
78848dd7d1
commit
9de99c833b
42 changed files with 347 additions and 384 deletions
|
|
@ -1,58 +1,39 @@
|
|||
import React from 'react'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { Link, useLocation } from 'react-router-dom'
|
||||
import clsx from 'clsx'
|
||||
import { getProjects, subscribeProjectsStore } from '@/pages/projects/projectData'
|
||||
|
||||
interface RecentProjectItem {
|
||||
id: string
|
||||
name: string
|
||||
path: string
|
||||
dotColor: string
|
||||
}
|
||||
|
||||
const RECENT_PROJECTS: RecentProjectItem[] = [
|
||||
{
|
||||
id: 'proj-1',
|
||||
name: 'Phương tiện đô thị',
|
||||
path: '/projects/proj-1',
|
||||
dotColor: 'bg-indigo-500',
|
||||
},
|
||||
{
|
||||
id: 'proj-2',
|
||||
name: 'Giao thông đô thị',
|
||||
path: '/projects/proj-2',
|
||||
dotColor: 'bg-blue-600',
|
||||
},
|
||||
{
|
||||
id: 'proj-3',
|
||||
name: 'Phân vùng đường phố',
|
||||
path: '/projects/proj-3',
|
||||
dotColor: 'bg-violet-500',
|
||||
},
|
||||
]
|
||||
|
||||
export const RecentProjects: React.FC = () => {
|
||||
export const RecentProjects: React.FC<{ isProjectList?: boolean }> = ({ isProjectList = false }) => {
|
||||
const location = useLocation()
|
||||
const [recentProjects, setRecentProjects] = useState(() => getProjects().slice(0, 3))
|
||||
|
||||
useEffect(() => subscribeProjectsStore(() => setRecentProjects(getProjects().slice(0, 3))), [])
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="px-2 mb-2 text-[10px] font-bold uppercase tracking-wider text-slate-500">
|
||||
<div className={`px-2 mb-2 text-[9px] font-semibold text-slate-500 ${isProjectList ? 'tracking-normal text-[#332926]' : 'uppercase tracking-wider'}`}>
|
||||
DỰ ÁN GẦN ĐÂY
|
||||
</div>
|
||||
<div className="space-y-0.5">
|
||||
{RECENT_PROJECTS.map((project) => {
|
||||
const isCurrent = location.pathname.startsWith(project.path)
|
||||
{recentProjects.map((project) => {
|
||||
const projectPath = `/projects/${project.id}`
|
||||
const dotColors = ['bg-[#a29fff]', 'bg-[#a29fff]', 'bg-[#a29fff]']
|
||||
const isCurrent = location.pathname.startsWith(projectPath)
|
||||
return (
|
||||
<Link
|
||||
key={project.id}
|
||||
to={project.path}
|
||||
to={projectPath}
|
||||
className={clsx(
|
||||
'flex items-center gap-2.5 rounded-lg px-2.5 py-2 text-xs font-medium transition-colors',
|
||||
'flex items-center transition-colors',
|
||||
isProjectList
|
||||
? 'gap-2 px-2.5 py-0.5 text-[11px] font-normal leading-[17px] text-[#332926]'
|
||||
: 'gap-2.5 rounded-lg px-2.5 py-2 text-xs font-medium',
|
||||
isCurrent
|
||||
? 'bg-slate-100 text-slate-900 font-semibold'
|
||||
: 'text-slate-600 hover:bg-slate-50 hover:text-slate-900'
|
||||
)}
|
||||
>
|
||||
<span className={clsx('h-1.5 w-1.5 rounded-full shrink-0', project.dotColor)} />
|
||||
<span className={`h-[5px] w-[5px] shrink-0 rounded-full ${isProjectList ? 'bg-[#a29fff]' : 'bg-indigo-500'}`} />
|
||||
<span className="truncate">{project.name}</span>
|
||||
</Link>
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue