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:
@@ -61,93 +61,18 @@
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
/* Projects Table */
|
||||
.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;
|
||||
}
|
||||
|
||||
/* Table utility classes */
|
||||
.text-muted {
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.actions-cell {
|
||||
width: 48px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.btn-ghost {
|
||||
background: transparent;
|
||||
color: var(--color-text-muted);
|
||||
border: none;
|
||||
padding: 0.375rem;
|
||||
cursor: pointer;
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
|
||||
.btn-ghost:hover {
|
||||
|
||||
@@ -5,6 +5,7 @@ import { getTeam, listTeamProjects, createProject } from '../api';
|
||||
import { useAuth } from '../contexts/AuthContext';
|
||||
import { Badge } from '../components/Badge';
|
||||
import { Breadcrumb } from '../components/Breadcrumb';
|
||||
import { DataTable } from '../components/DataTable';
|
||||
import './TeamDashboardPage.css';
|
||||
|
||||
function TeamDashboardPage() {
|
||||
@@ -202,44 +203,48 @@ function TeamDashboardPage() {
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<div className="projects-table-container">
|
||||
<table className="projects-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Description</th>
|
||||
<th>Visibility</th>
|
||||
<th>Created By</th>
|
||||
{isAdminOrOwner && <th></th>}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{projects?.items.map(project => (
|
||||
<tr
|
||||
key={project.id}
|
||||
className="project-row"
|
||||
onClick={() => navigate(`/project/${project.name}`)}
|
||||
>
|
||||
<td>
|
||||
<DataTable
|
||||
data={projects?.items || []}
|
||||
keyExtractor={(project) => project.id}
|
||||
onRowClick={(project) => navigate(`/project/${project.name}`)}
|
||||
columns={[
|
||||
{
|
||||
key: 'name',
|
||||
header: 'Name',
|
||||
render: (project) => (
|
||||
<Link
|
||||
to={`/project/${project.name}`}
|
||||
className="project-name-link"
|
||||
className="cell-name"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{project.name}
|
||||
</Link>
|
||||
</td>
|
||||
<td className="project-description-cell">
|
||||
{project.description || <span className="text-muted">—</span>}
|
||||
</td>
|
||||
<td>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'description',
|
||||
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'}>
|
||||
{project.is_public ? 'Public' : 'Private'}
|
||||
</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
|
||||
className="btn btn-sm btn-ghost"
|
||||
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"/>
|
||||
</svg>
|
||||
</button>
|
||||
</td>
|
||||
)}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
),
|
||||
}] : []),
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
|
||||
{projects && projects.pagination.total > 10 && (
|
||||
|
||||
@@ -171,60 +171,7 @@
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
/* Table */
|
||||
.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);
|
||||
}
|
||||
/* Table cell styles */
|
||||
|
||||
.team-name-cell {
|
||||
display: flex;
|
||||
|
||||
@@ -4,6 +4,7 @@ import { TeamDetail, TeamCreate, PaginatedResponse } from '../types';
|
||||
import { listTeams, createTeam } from '../api';
|
||||
import { useAuth } from '../contexts/AuthContext';
|
||||
import { Badge } from '../components/Badge';
|
||||
import { DataTable } from '../components/DataTable';
|
||||
import './TeamsPage.css';
|
||||
|
||||
function TeamsPage() {
|
||||
@@ -265,53 +266,54 @@ function TeamsPage() {
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<div className="teams-table-container">
|
||||
<table className="teams-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Description</th>
|
||||
<th>Role</th>
|
||||
<th>Members</th>
|
||||
<th>Projects</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{filteredTeams.map(team => (
|
||||
<tr
|
||||
key={team.id}
|
||||
className="team-row"
|
||||
onClick={() => navigate(`/teams/${team.slug}`)}
|
||||
>
|
||||
<td>
|
||||
<DataTable
|
||||
data={filteredTeams}
|
||||
keyExtractor={(team) => team.id}
|
||||
onRowClick={(team) => navigate(`/teams/${team.slug}`)}
|
||||
columns={[
|
||||
{
|
||||
key: 'name',
|
||||
header: 'Name',
|
||||
render: (team) => (
|
||||
<div className="team-name-cell">
|
||||
<Link
|
||||
to={`/teams/${team.slug}`}
|
||||
className="team-name-link"
|
||||
className="cell-name"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{team.name}
|
||||
</Link>
|
||||
<span className="team-slug">@{team.slug}</span>
|
||||
</div>
|
||||
</td>
|
||||
<td className="team-description-cell">
|
||||
{team.description || <span className="text-muted">—</span>}
|
||||
</td>
|
||||
<td>
|
||||
{team.user_role && (
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'description',
|
||||
header: 'Description',
|
||||
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'}>
|
||||
{roleConfig[team.user_role]?.label || team.user_role}
|
||||
</Badge>
|
||||
)}
|
||||
</td>
|
||||
<td className="text-muted">{team.member_count}</td>
|
||||
<td className="text-muted">{team.project_count}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
) : null,
|
||||
},
|
||||
{
|
||||
key: 'members',
|
||||
header: 'Members',
|
||||
render: (team) => <span className="text-muted">{team.member_count}</span>,
|
||||
},
|
||||
{
|
||||
key: 'projects',
|
||||
header: 'Projects',
|
||||
render: (team) => <span className="text-muted">{team.project_count}</span>,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user