Use DataTable component for teams and projects tables

Consistent table styling across the app with:
- Row hover highlighting
- Clickable rows
- Standard cell padding and borders
- Proper header styling
This commit is contained in:
Mondo Diaz
2026-01-28 16:13:32 +00:00
parent 7d106998be
commit 2b9c039157
4 changed files with 112 additions and 236 deletions

View File

@@ -61,93 +61,18 @@
font-size: 1.25rem; font-size: 1.25rem;
} }
/* Projects Table */ /* Table utility classes */
.projects-table-container {
background: var(--color-bg);
border: 1px solid var(--color-border);
border-radius: var(--radius-md);
overflow: hidden;
}
.projects-table {
width: 100%;
border-collapse: collapse;
}
.projects-table th {
text-align: left;
padding: 0.75rem 1rem;
font-size: 0.75rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.05em;
color: var(--color-text-muted);
background: var(--color-bg-secondary);
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
border-right: 1px solid rgba(0, 0, 0, 0.06);
}
.projects-table th:last-child {
border-right: none;
}
.projects-table td {
padding: 0.75rem 1rem;
font-size: 0.875rem;
vertical-align: middle;
border-bottom: 1px solid rgba(0, 0, 0, 0.06);
border-right: 1px solid rgba(0, 0, 0, 0.06);
}
.projects-table td:last-child {
border-right: none;
}
.projects-table tbody tr:last-child td {
border-bottom: none;
}
.project-row {
cursor: pointer;
transition: background 0.1s ease;
}
.project-row:hover {
background: var(--color-bg-secondary);
}
.project-name-link {
font-weight: 500;
color: var(--color-text);
text-decoration: none;
}
.project-name-link:hover {
color: var(--color-primary);
}
.project-description-cell {
color: var(--color-text-secondary);
max-width: 300px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.text-muted { .text-muted {
color: var(--color-text-muted); color: var(--color-text-muted);
} }
.actions-cell {
width: 48px;
text-align: right;
}
.btn-ghost { .btn-ghost {
background: transparent; background: transparent;
color: var(--color-text-muted); color: var(--color-text-muted);
border: none; border: none;
padding: 0.375rem; padding: 0.375rem;
cursor: pointer;
border-radius: var(--radius-sm);
} }
.btn-ghost:hover { .btn-ghost:hover {

View File

@@ -5,6 +5,7 @@ import { getTeam, listTeamProjects, createProject } from '../api';
import { useAuth } from '../contexts/AuthContext'; import { useAuth } from '../contexts/AuthContext';
import { Badge } from '../components/Badge'; import { Badge } from '../components/Badge';
import { Breadcrumb } from '../components/Breadcrumb'; import { Breadcrumb } from '../components/Breadcrumb';
import { DataTable } from '../components/DataTable';
import './TeamDashboardPage.css'; import './TeamDashboardPage.css';
function TeamDashboardPage() { function TeamDashboardPage() {
@@ -202,44 +203,48 @@ function TeamDashboardPage() {
)} )}
</div> </div>
) : ( ) : (
<div className="projects-table-container"> <DataTable
<table className="projects-table"> data={projects?.items || []}
<thead> keyExtractor={(project) => project.id}
<tr> onRowClick={(project) => navigate(`/project/${project.name}`)}
<th>Name</th> columns={[
<th>Description</th> {
<th>Visibility</th> key: 'name',
<th>Created By</th> header: 'Name',
{isAdminOrOwner && <th></th>} render: (project) => (
</tr>
</thead>
<tbody>
{projects?.items.map(project => (
<tr
key={project.id}
className="project-row"
onClick={() => navigate(`/project/${project.name}`)}
>
<td>
<Link <Link
to={`/project/${project.name}`} to={`/project/${project.name}`}
className="project-name-link" className="cell-name"
onClick={(e) => e.stopPropagation()} onClick={(e) => e.stopPropagation()}
> >
{project.name} {project.name}
</Link> </Link>
</td> ),
<td className="project-description-cell"> },
{project.description || <span className="text-muted"></span>} {
</td> key: 'description',
<td> header: 'Description',
className: 'cell-description',
render: (project) => project.description || <span className="text-muted"></span>,
},
{
key: 'visibility',
header: 'Visibility',
render: (project) => (
<Badge variant={project.is_public ? 'public' : 'private'}> <Badge variant={project.is_public ? 'public' : 'private'}>
{project.is_public ? 'Public' : 'Private'} {project.is_public ? 'Public' : 'Private'}
</Badge> </Badge>
</td> ),
<td className="text-muted">{project.created_by}</td> },
{isAdminOrOwner && ( {
<td className="actions-cell"> key: 'created_by',
header: 'Created By',
render: (project) => <span className="text-muted">{project.created_by}</span>,
},
...(isAdminOrOwner ? [{
key: 'actions',
header: '',
render: (project: Project) => (
<button <button
className="btn btn-sm btn-ghost" className="btn btn-sm btn-ghost"
onClick={(e) => { onClick={(e) => {
@@ -253,13 +258,10 @@ function TeamDashboardPage() {
<path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/> <path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/>
</svg> </svg>
</button> </button>
</td> ),
)} }] : []),
</tr> ]}
))} />
</tbody>
</table>
</div>
)} )}
{projects && projects.pagination.total > 10 && ( {projects && projects.pagination.total > 10 && (

View File

@@ -171,60 +171,7 @@
color: var(--color-text-muted); color: var(--color-text-muted);
} }
/* Table */ /* Table cell styles */
.teams-table-container {
background: var(--color-bg);
border: 1px solid var(--color-border);
border-radius: var(--radius-md);
overflow: hidden;
}
.teams-table {
width: 100%;
border-collapse: collapse;
}
.teams-table th {
text-align: left;
padding: 0.75rem 1rem;
font-size: 0.75rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.05em;
color: var(--color-text-muted);
background: var(--color-bg-secondary);
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
border-right: 1px solid rgba(0, 0, 0, 0.06);
}
.teams-table th:last-child {
border-right: none;
}
.teams-table td {
padding: 0.75rem 1rem;
font-size: 0.875rem;
vertical-align: middle;
border-bottom: 1px solid rgba(0, 0, 0, 0.06);
border-right: 1px solid rgba(0, 0, 0, 0.06);
}
.teams-table td:last-child {
border-right: none;
}
.teams-table tbody tr:last-child td {
border-bottom: none;
}
.team-row {
cursor: pointer;
transition: background 0.1s ease;
}
.team-row:hover {
background: var(--color-bg-secondary);
}
.team-name-cell { .team-name-cell {
display: flex; display: flex;

View File

@@ -4,6 +4,7 @@ import { TeamDetail, TeamCreate, PaginatedResponse } from '../types';
import { listTeams, createTeam } from '../api'; import { listTeams, createTeam } from '../api';
import { useAuth } from '../contexts/AuthContext'; import { useAuth } from '../contexts/AuthContext';
import { Badge } from '../components/Badge'; import { Badge } from '../components/Badge';
import { DataTable } from '../components/DataTable';
import './TeamsPage.css'; import './TeamsPage.css';
function TeamsPage() { function TeamsPage() {
@@ -265,53 +266,54 @@ function TeamsPage() {
)} )}
</div> </div>
) : ( ) : (
<div className="teams-table-container"> <DataTable
<table className="teams-table"> data={filteredTeams}
<thead> keyExtractor={(team) => team.id}
<tr> onRowClick={(team) => navigate(`/teams/${team.slug}`)}
<th>Name</th> columns={[
<th>Description</th> {
<th>Role</th> key: 'name',
<th>Members</th> header: 'Name',
<th>Projects</th> render: (team) => (
</tr>
</thead>
<tbody>
{filteredTeams.map(team => (
<tr
key={team.id}
className="team-row"
onClick={() => navigate(`/teams/${team.slug}`)}
>
<td>
<div className="team-name-cell"> <div className="team-name-cell">
<Link <Link
to={`/teams/${team.slug}`} to={`/teams/${team.slug}`}
className="team-name-link" className="cell-name"
onClick={(e) => e.stopPropagation()} onClick={(e) => e.stopPropagation()}
> >
{team.name} {team.name}
</Link> </Link>
<span className="team-slug">@{team.slug}</span> <span className="team-slug">@{team.slug}</span>
</div> </div>
</td> ),
<td className="team-description-cell"> },
{team.description || <span className="text-muted"></span>} {
</td> key: 'description',
<td> header: 'Description',
{team.user_role && ( className: 'cell-description',
render: (team) => team.description || <span className="text-muted"></span>,
},
{
key: 'role',
header: 'Role',
render: (team) => team.user_role ? (
<Badge variant={roleConfig[team.user_role]?.variant || 'default'}> <Badge variant={roleConfig[team.user_role]?.variant || 'default'}>
{roleConfig[team.user_role]?.label || team.user_role} {roleConfig[team.user_role]?.label || team.user_role}
</Badge> </Badge>
)} ) : null,
</td> },
<td className="text-muted">{team.member_count}</td> {
<td className="text-muted">{team.project_count}</td> key: 'members',
</tr> header: 'Members',
))} render: (team) => <span className="text-muted">{team.member_count}</span>,
</tbody> },
</table> {
</div> key: 'projects',
header: 'Projects',
render: (team) => <span className="text-muted">{team.project_count}</span>,
},
]}
/>
)} )}
</div> </div>
); );