feat(scenarios): add detail page, comfortable DescriptionList layout, and environment card refactor
- Add ScenarioDetailPage with DescriptionList, steps table, run/delete actions - Add /scenarios/:id route - Add i18n keys for scenario detail fields, steps columns, and 404 error - Add 'comfortable' and 'inline' layout variants to DescriptionList (with compact as default stacked) - Apply layout="comfortable" to session, environment, and scenario detail pages - Apply layout="compact" to EnvironmentsPage card DescriptionList - Refactor EnvironmentsPage card to use ContextMenu (view/edit/delete) with icons - Add ScenariosPage clickable rows, Play icon (primary) and Trash2 icon (danger) action buttons - Add Page.module.css sectionHeading and stepsSection utility classes - Fix Notification.tsx and Table.tsx formatting (prettier)
This commit is contained in:
@@ -8,6 +8,7 @@ import { KeysPage } from './pages/KeysPage';
|
|||||||
import { SessionsPage } from './pages/SessionsPage';
|
import { SessionsPage } from './pages/SessionsPage';
|
||||||
import { SessionDetailPage } from './pages/SessionDetailPage';
|
import { SessionDetailPage } from './pages/SessionDetailPage';
|
||||||
import { ScenariosPage } from './pages/ScenariosPage';
|
import { ScenariosPage } from './pages/ScenariosPage';
|
||||||
|
import { ScenarioDetailPage } from './pages/ScenarioDetailPage';
|
||||||
import { NavLink, Navigate, Route, Routes } from 'react-router-dom';
|
import { NavLink, Navigate, Route, Routes } from 'react-router-dom';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Globe, KeyRound, Monitor, ClipboardList } from 'lucide-react';
|
import { Globe, KeyRound, Monitor, ClipboardList } from 'lucide-react';
|
||||||
@@ -61,6 +62,7 @@ export default function App() {
|
|||||||
<Route path="/sessions" element={<SessionsPage />} />
|
<Route path="/sessions" element={<SessionsPage />} />
|
||||||
<Route path="/sessions/:id" element={<SessionDetailPage />} />
|
<Route path="/sessions/:id" element={<SessionDetailPage />} />
|
||||||
<Route path="/scenarios" element={<ScenariosPage />} />
|
<Route path="/scenarios" element={<ScenariosPage />} />
|
||||||
|
<Route path="/scenarios/:id" element={<ScenarioDetailPage />} />
|
||||||
<Route path="*" element={<Navigate to="/scenarios" replace />} />
|
<Route path="*" element={<Navigate to="/scenarios" replace />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
"not_found": "Not found",
|
"not_found": "Not found",
|
||||||
"not_found_session": "Session {{id}} does not exist or has been deleted.",
|
"not_found_session": "Session {{id}} does not exist or has been deleted.",
|
||||||
"not_found_environment": "Environment {{id}} does not exist or has been deleted.",
|
"not_found_environment": "Environment {{id}} does not exist or has been deleted.",
|
||||||
|
"not_found_scenario": "Scenario {{id}} does not exist or has been deleted.",
|
||||||
"generic": "Something went wrong. Please try again."
|
"generic": "Something went wrong. Please try again."
|
||||||
},
|
},
|
||||||
"nav": {
|
"nav": {
|
||||||
@@ -70,8 +71,19 @@
|
|||||||
"col_name": "Name",
|
"col_name": "Name",
|
||||||
"col_updated": "Updated",
|
"col_updated": "Updated",
|
||||||
"empty": "No scenarios yet.",
|
"empty": "No scenarios yet.",
|
||||||
|
"loading": "Loading…",
|
||||||
"action_run": "Run",
|
"action_run": "Run",
|
||||||
"action_delete": "Delete"
|
"action_delete": "Delete",
|
||||||
|
"field_id": "ID",
|
||||||
|
"field_name": "Name",
|
||||||
|
"field_steps": "Steps",
|
||||||
|
"field_created": "Created",
|
||||||
|
"field_updated": "Updated",
|
||||||
|
"steps_heading": "Steps",
|
||||||
|
"step_order": "#",
|
||||||
|
"step_type": "Type",
|
||||||
|
"step_session": "Session",
|
||||||
|
"step_updated": "Updated"
|
||||||
},
|
},
|
||||||
"theme": {
|
"theme": {
|
||||||
"switch_to_light": "Switch to light theme",
|
"switch_to_light": "Switch to light theme",
|
||||||
|
|||||||
@@ -91,11 +91,7 @@ export function CreateEnvironmentPage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className={styles.formActions}>
|
<div className={styles.formActions}>
|
||||||
<Button
|
<Button type="button" variant="secondary" onClick={() => navigate('/environments')}>
|
||||||
type="button"
|
|
||||||
variant="secondary"
|
|
||||||
onClick={() => navigate('/environments')}
|
|
||||||
>
|
|
||||||
{t('environments.action_cancel')}
|
{t('environments.action_cancel')}
|
||||||
</Button>
|
</Button>
|
||||||
<Button type="submit" loading={saving}>
|
<Button type="submit" loading={saving}>
|
||||||
|
|||||||
@@ -41,7 +41,11 @@ export function EnvironmentDetailPage() {
|
|||||||
/>
|
/>
|
||||||
{env && (
|
{env && (
|
||||||
<div className={styles.toolbarActions}>
|
<div className={styles.toolbarActions}>
|
||||||
<Button variant="secondary" size="sm" onClick={() => navigate(`/environments/${env.id}/edit`)}>
|
<Button
|
||||||
|
variant="secondary"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => navigate(`/environments/${env.id}/edit`)}
|
||||||
|
>
|
||||||
<Pencil size={14} />
|
<Pencil size={14} />
|
||||||
{t('environments.action_edit')}
|
{t('environments.action_edit')}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -68,6 +72,7 @@ export function EnvironmentDetailPage() {
|
|||||||
<>
|
<>
|
||||||
<div className={styles.detailMeta}>
|
<div className={styles.detailMeta}>
|
||||||
<DescriptionList
|
<DescriptionList
|
||||||
|
layout="comfortable"
|
||||||
items={[
|
items={[
|
||||||
{ term: t('environments.field_id'), detail: env.id },
|
{ term: t('environments.field_id'), detail: env.id },
|
||||||
{
|
{
|
||||||
@@ -88,6 +93,7 @@ export function EnvironmentDetailPage() {
|
|||||||
<p className={styles.muted}>{t('environments.no_urls')}</p>
|
<p className={styles.muted}>{t('environments.no_urls')}</p>
|
||||||
) : (
|
) : (
|
||||||
<DescriptionList
|
<DescriptionList
|
||||||
|
layout="comfortable"
|
||||||
items={Object.entries(env.urls)
|
items={Object.entries(env.urls)
|
||||||
.filter(([, v]) => v)
|
.filter(([, v]) => v)
|
||||||
.map(([key, value]) => ({
|
.map(([key, value]) => ({
|
||||||
|
|||||||
@@ -15,32 +15,34 @@ function EnvironmentCard({ env, onDelete }: { env: Environment; onDelete: (id: n
|
|||||||
const header = (
|
const header = (
|
||||||
<div className={styles.envCardHeader}>
|
<div className={styles.envCardHeader}>
|
||||||
<span className={styles.envCardName}>{env.name}</span>
|
<span className={styles.envCardName}>{env.name}</span>
|
||||||
<div onClick={(e) => e.stopPropagation()}><ContextMenu
|
<div onClick={(e) => e.stopPropagation()}>
|
||||||
align="right"
|
<ContextMenu
|
||||||
trigger={
|
align="right"
|
||||||
<Button variant="ghost" size="sm" aria-label={t('environments.menu_label')}>
|
trigger={
|
||||||
<Settings size={14} />
|
<Button variant="ghost" size="sm" aria-label={t('environments.menu_label')}>
|
||||||
</Button>
|
<Settings size={14} />
|
||||||
}
|
</Button>
|
||||||
items={[
|
}
|
||||||
{
|
items={[
|
||||||
label: t('environments.action_view'),
|
{
|
||||||
icon: <ExternalLink size={14} />,
|
label: t('environments.action_view'),
|
||||||
onClick: () => navigate(`/environments/${env.id}`),
|
icon: <ExternalLink size={14} />,
|
||||||
},
|
onClick: () => navigate(`/environments/${env.id}`),
|
||||||
{
|
},
|
||||||
label: t('environments.action_edit'),
|
{
|
||||||
icon: <Pencil size={14} />,
|
label: t('environments.action_edit'),
|
||||||
onClick: () => navigate(`/environments/${env.id}/edit`),
|
icon: <Pencil size={14} />,
|
||||||
},
|
onClick: () => navigate(`/environments/${env.id}/edit`),
|
||||||
{
|
},
|
||||||
label: t('environments.action_delete'),
|
{
|
||||||
icon: <Trash2 size={14} />,
|
label: t('environments.action_delete'),
|
||||||
variant: 'danger',
|
icon: <Trash2 size={14} />,
|
||||||
onClick: () => onDelete(env.id),
|
variant: 'danger',
|
||||||
},
|
onClick: () => onDelete(env.id),
|
||||||
]}
|
},
|
||||||
/></div>
|
]}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -60,7 +62,11 @@ function EnvironmentCard({ env, onDelete }: { env: Environment; onDelete: (id: n
|
|||||||
onClick={() => navigate(`/environments/${env.id}`)}
|
onClick={() => navigate(`/environments/${env.id}`)}
|
||||||
>
|
>
|
||||||
{urlEntries.length > 0 && (
|
{urlEntries.length > 0 && (
|
||||||
<DescriptionList truncate items={urlEntries.map(([key, value]) => ({ term: key, detail: value }))} />
|
<DescriptionList
|
||||||
|
layout="compact"
|
||||||
|
truncate
|
||||||
|
items={urlEntries.map(([key, value]) => ({ term: key, detail: value }))}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
{urlEntries.length === 0 && (
|
{urlEntries.length === 0 && (
|
||||||
<p className={styles.envCardEmpty}>{t('environments.no_urls')}</p>
|
<p className={styles.envCardEmpty}>{t('environments.no_urls')}</p>
|
||||||
|
|||||||
@@ -5,6 +5,17 @@
|
|||||||
color: var(--color-text);
|
color: var(--color-text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sectionHeading {
|
||||||
|
margin: var(--space-6) 0 var(--space-3);
|
||||||
|
font-size: var(--font-size-md);
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--color-text);
|
||||||
|
}
|
||||||
|
|
||||||
|
.stepsSection {
|
||||||
|
margin-top: var(--space-2);
|
||||||
|
}
|
||||||
|
|
||||||
.breadcrumbs {
|
.breadcrumbs {
|
||||||
margin-bottom: var(--space-4);
|
margin-bottom: var(--space-4);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,141 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { useNavigate, useParams } from 'react-router-dom';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { Play, Trash2 } from 'lucide-react';
|
||||||
|
import { scenarios } from '../api';
|
||||||
|
import type { Scenario, ScenarioStep } from '../api';
|
||||||
|
import {
|
||||||
|
Badge,
|
||||||
|
Breadcrumbs,
|
||||||
|
Button,
|
||||||
|
Card,
|
||||||
|
DescriptionList,
|
||||||
|
Notification,
|
||||||
|
Table,
|
||||||
|
Timestamp,
|
||||||
|
type TableColumn,
|
||||||
|
} from '../ui';
|
||||||
|
import styles from './Page.module.css';
|
||||||
|
|
||||||
|
const STEP_TYPE_VARIANT: Record<string, 'info' | 'warning' | 'success'> = {
|
||||||
|
login: 'success',
|
||||||
|
exec: 'info',
|
||||||
|
sign: 'warning',
|
||||||
|
};
|
||||||
|
|
||||||
|
export function ScenarioDetailPage() {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { id } = useParams<{ id: string }>();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const [scenario, setScenario] = useState<(Scenario & { steps: ScenarioStep[] }) | null>(null);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!id) return;
|
||||||
|
scenarios
|
||||||
|
.get(Number(id))
|
||||||
|
.then(setScenario)
|
||||||
|
.catch((err: Error) => setError(err.message))
|
||||||
|
.finally(() => setLoading(false));
|
||||||
|
}, [id]);
|
||||||
|
|
||||||
|
const handleRun = async () => {
|
||||||
|
if (!scenario) return;
|
||||||
|
await scenarios.run(scenario.id);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDelete = async () => {
|
||||||
|
if (!scenario) return;
|
||||||
|
await scenarios.remove(scenario.id);
|
||||||
|
navigate('/scenarios');
|
||||||
|
};
|
||||||
|
|
||||||
|
const stepColumns: TableColumn<ScenarioStep>[] = [
|
||||||
|
{ key: 'order', header: t('scenarios.step_order'), render: (s) => s.order, width: 60 },
|
||||||
|
{
|
||||||
|
key: 'type',
|
||||||
|
header: t('scenarios.step_type'),
|
||||||
|
width: 90,
|
||||||
|
render: (s) => <Badge variant={STEP_TYPE_VARIANT[s.type] ?? 'neutral'}>{s.type}</Badge>,
|
||||||
|
},
|
||||||
|
{ key: 'session', header: t('scenarios.step_session'), render: (s) => s.sessionName },
|
||||||
|
{
|
||||||
|
key: 'updated',
|
||||||
|
header: t('scenarios.step_updated'),
|
||||||
|
width: 140,
|
||||||
|
render: (s) => <Timestamp value={s.updatedAt} />,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className={styles.pageToolbar}>
|
||||||
|
<Breadcrumbs
|
||||||
|
items={[
|
||||||
|
{ label: t('scenarios.title'), onClick: () => navigate('/scenarios') },
|
||||||
|
{ label: scenario?.name ?? `#${id}` },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
{scenario && (
|
||||||
|
<div className={styles.toolbarActions}>
|
||||||
|
<Button size="sm" onClick={handleRun}>
|
||||||
|
<Play size={14} />
|
||||||
|
{t('scenarios.action_run')}
|
||||||
|
</Button>
|
||||||
|
<Button variant="danger" size="sm" onClick={handleDelete}>
|
||||||
|
<Trash2 size={14} />
|
||||||
|
{t('scenarios.action_delete')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{error && (
|
||||||
|
<Notification
|
||||||
|
variant="error"
|
||||||
|
title={error.startsWith('404') ? t('errors.not_found') : undefined}
|
||||||
|
>
|
||||||
|
{error.startsWith('404') ? t('errors.not_found_scenario', { id }) : error}
|
||||||
|
</Notification>
|
||||||
|
)}
|
||||||
|
{loading && <p className={styles.muted}>{t('scenarios.loading')}</p>}
|
||||||
|
|
||||||
|
{scenario && (
|
||||||
|
<>
|
||||||
|
<Card>
|
||||||
|
<DescriptionList
|
||||||
|
layout="comfortable"
|
||||||
|
items={[
|
||||||
|
{ term: t('scenarios.field_id'), detail: scenario.id },
|
||||||
|
{ term: t('scenarios.field_name'), detail: scenario.name },
|
||||||
|
{ term: t('scenarios.field_steps'), detail: scenario.steps.length },
|
||||||
|
{
|
||||||
|
term: t('scenarios.field_created'),
|
||||||
|
detail: <Timestamp value={scenario.createdAt} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
term: t('scenarios.field_updated'),
|
||||||
|
detail: <Timestamp value={scenario.updatedAt} />,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
{scenario.steps.length > 0 && (
|
||||||
|
<div className={styles.stepsSection}>
|
||||||
|
<h2 className={styles.sectionHeading}>{t('scenarios.steps_heading')}</h2>
|
||||||
|
<Table
|
||||||
|
columns={stepColumns}
|
||||||
|
data={scenario.steps}
|
||||||
|
rowKey={(s) => s.id}
|
||||||
|
loading={false}
|
||||||
|
emptyMessage=""
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
import { useCallback, useEffect, useState } from 'react';
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { Play, Trash2 } from 'lucide-react';
|
||||||
import { scenarios } from '../api';
|
import { scenarios } from '../api';
|
||||||
import type { Scenario } from '../api';
|
import type { Scenario } from '../api';
|
||||||
import { Breadcrumbs, Button, Table, type TableColumn, Timestamp } from '../ui';
|
import { Breadcrumbs, Button, Table, type TableColumn, Timestamp } from '../ui';
|
||||||
@@ -7,6 +9,7 @@ import styles from './Page.module.css';
|
|||||||
|
|
||||||
export function ScenariosPage() {
|
export function ScenariosPage() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const navigate = useNavigate();
|
||||||
const [items, setItems] = useState<Scenario[]>([]);
|
const [items, setItems] = useState<Scenario[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
@@ -45,15 +48,20 @@ export function ScenariosPage() {
|
|||||||
{
|
{
|
||||||
key: 'actions',
|
key: 'actions',
|
||||||
header: '',
|
header: '',
|
||||||
width: 140,
|
width: 100,
|
||||||
align: 'right',
|
align: 'right',
|
||||||
render: (s) => (
|
render: (s) => (
|
||||||
<span style={{ display: 'inline-flex', gap: 6 }}>
|
<span style={{ display: 'inline-flex', gap: 6 }}>
|
||||||
<Button size="sm" onClick={() => handleRun(s.id)}>
|
<Button size="sm" title={t('scenarios.action_run')} onClick={() => handleRun(s.id)}>
|
||||||
{t('scenarios.action_run')}
|
<Play size={14} />
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="secondary" size="sm" onClick={() => handleDelete(s.id)}>
|
<Button
|
||||||
{t('scenarios.action_delete')}
|
variant="danger"
|
||||||
|
size="sm"
|
||||||
|
title={t('scenarios.action_delete')}
|
||||||
|
onClick={() => handleDelete(s.id)}
|
||||||
|
>
|
||||||
|
<Trash2 size={14} />
|
||||||
</Button>
|
</Button>
|
||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
@@ -72,6 +80,7 @@ export function ScenariosPage() {
|
|||||||
emptyMessage={t('scenarios.empty')}
|
emptyMessage={t('scenarios.empty')}
|
||||||
pageSize={10}
|
pageSize={10}
|
||||||
pageSizeOptions={[10, 25, 50]}
|
pageSizeOptions={[10, 25, 50]}
|
||||||
|
onRowClick={(s) => navigate(`/scenarios/${s.id}`)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ export function SessionDetailPage() {
|
|||||||
{session && (
|
{session && (
|
||||||
<Card>
|
<Card>
|
||||||
<DescriptionList
|
<DescriptionList
|
||||||
|
layout="comfortable"
|
||||||
items={[
|
items={[
|
||||||
{ term: t('sessions.field_id'), detail: session.id },
|
{ term: t('sessions.field_id'), detail: session.id },
|
||||||
{ term: t('sessions.field_name'), detail: session.sessionName },
|
{ term: t('sessions.field_name'), detail: session.sessionName },
|
||||||
@@ -71,7 +72,10 @@ export function SessionDetailPage() {
|
|||||||
</Badge>
|
</Badge>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{ term: t('sessions.field_token'), detail: <code className={styles.codeInline}>{session.token}</code> },
|
{
|
||||||
|
term: t('sessions.field_token'),
|
||||||
|
detail: <code className={styles.codeInline}>{session.token}</code>,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
term: t('sessions.field_lastUsed'),
|
term: t('sessions.field_lastUsed'),
|
||||||
detail: session.lastUsedAt ? <Timestamp value={session.lastUsedAt} /> : '—',
|
detail: session.lastUsedAt ? <Timestamp value={session.lastUsedAt} /> : '—',
|
||||||
|
|||||||
@@ -39,9 +39,7 @@ export function SessionsPage() {
|
|||||||
key: 'status',
|
key: 'status',
|
||||||
header: t('sessions.col_status'),
|
header: t('sessions.col_status'),
|
||||||
width: 100,
|
width: 100,
|
||||||
render: (s) => (
|
render: (s) => <Badge variant={s.status === 'open' ? 'success' : 'error'}>{s.status}</Badge>,
|
||||||
<Badge variant={s.status === 'open' ? 'success' : 'error'}>{s.status}</Badge>
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'lastUsed',
|
key: 'lastUsed',
|
||||||
|
|||||||
@@ -45,3 +45,35 @@
|
|||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ── Layout modifiers ───────────────────────────────────────── */
|
||||||
|
|
||||||
|
.inline .row {
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: baseline;
|
||||||
|
gap: var(--space-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.inline .term {
|
||||||
|
min-width: 120px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comfortable {
|
||||||
|
gap: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comfortable .row {
|
||||||
|
padding: var(--space-4) 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comfortable .row:first-child {
|
||||||
|
padding-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comfortable .term {
|
||||||
|
margin-bottom: var(--space-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.comfortable .detail {
|
||||||
|
font-size: var(--font-size-md);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,14 +15,19 @@ export interface DescriptionListItem {
|
|||||||
|
|
||||||
export interface DescriptionListProps {
|
export interface DescriptionListProps {
|
||||||
items: DescriptionListItem[];
|
items: DescriptionListItem[];
|
||||||
/** 'compact' stacks term above detail; 'inline' places them side by side (default) */
|
/** 'compact' stacks term above detail; 'inline' places them side by side; 'comfortable' adds generous spacing with dividers (default) */
|
||||||
layout?: 'inline' | 'compact';
|
layout?: 'inline' | 'compact' | 'comfortable';
|
||||||
/** Truncate detail values with ellipsis; full value shown in a tooltip on hover */
|
/** Truncate detail values with ellipsis; full value shown in a tooltip on hover */
|
||||||
truncate?: boolean;
|
truncate?: boolean;
|
||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DescriptionList({ items, layout = 'inline', truncate, className }: DescriptionListProps) {
|
export function DescriptionList({
|
||||||
|
items,
|
||||||
|
layout = 'inline',
|
||||||
|
truncate,
|
||||||
|
className,
|
||||||
|
}: DescriptionListProps) {
|
||||||
return (
|
return (
|
||||||
<dl className={[styles.list, styles[layout], className].filter(Boolean).join(' ')}>
|
<dl className={[styles.list, styles[layout], className].filter(Boolean).join(' ')}>
|
||||||
{items.map((item, i) => (
|
{items.map((item, i) => (
|
||||||
|
|||||||
@@ -11,19 +11,14 @@ export interface NotificationProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ICONS: Record<NotificationVariant, React.ReactNode> = {
|
const ICONS: Record<NotificationVariant, React.ReactNode> = {
|
||||||
info: <Info size={16} />,
|
info: <Info size={16} />,
|
||||||
success: <CheckCircle2 size={16} />,
|
success: <CheckCircle2 size={16} />,
|
||||||
error: <AlertCircle size={16} />,
|
error: <AlertCircle size={16} />,
|
||||||
warning: <AlertTriangle size={16} />,
|
warning: <AlertTriangle size={16} />,
|
||||||
note: <StickyNote size={16} />,
|
note: <StickyNote size={16} />,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function Notification({
|
export function Notification({ variant = 'info', title, children, className }: NotificationProps) {
|
||||||
variant = 'info',
|
|
||||||
title,
|
|
||||||
children,
|
|
||||||
className,
|
|
||||||
}: NotificationProps) {
|
|
||||||
return (
|
return (
|
||||||
<div className={[styles.notification, styles[variant], className].filter(Boolean).join(' ')}>
|
<div className={[styles.notification, styles[variant], className].filter(Boolean).join(' ')}>
|
||||||
<span className={styles.icon}>{ICONS[variant]}</span>
|
<span className={styles.icon}>{ICONS[variant]}</span>
|
||||||
|
|||||||
@@ -82,7 +82,9 @@ export function Table<T>({
|
|||||||
visibleData.map((row) => (
|
visibleData.map((row) => (
|
||||||
<tr
|
<tr
|
||||||
key={rowKey(row)}
|
key={rowKey(row)}
|
||||||
className={[styles.tr, onRowClick ? styles.clickable : ''].filter(Boolean).join(' ')}
|
className={[styles.tr, onRowClick ? styles.clickable : '']
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(' ')}
|
||||||
onClick={onRowClick ? () => onRowClick(row) : undefined}
|
onClick={onRowClick ? () => onRowClick(row) : undefined}
|
||||||
>
|
>
|
||||||
{columns.map((col) => (
|
{columns.map((col) => (
|
||||||
|
|||||||
Reference in New Issue
Block a user