feat(design): sweep off-system styles and add the check:design gate

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-30 20:39:44 +08:00
co-authored by Claude Haiku 4.5
parent ba9eeefe47
commit c5a98eed06
56 changed files with 335 additions and 216 deletions
+4 -4
View File
@@ -32,7 +32,7 @@ export default function ForgotPasswordPage() {
<p className="text-sm text-gray-500">
If an account exists for <strong>{email}</strong>, a password reset link has been sent.
</p>
<Link href="/login" className="text-sm text-blue-600 hover:underline">
<Link href="/login" className="text-sm text-accent-700 hover:underline">
Back to sign in
</Link>
</div>
@@ -57,19 +57,19 @@ export default function ForgotPasswordPage() {
onChange={e => setEmail(e.target.value)}
required
autoComplete="email"
className="border border-divider px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
className="border border-divider px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-accent"
/>
<button
type="submit"
disabled={loading}
className="bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 disabled:opacity-50 transition-colors"
className="bg-accent hover:bg-accent-600 text-white font-medium py-2 disabled:opacity-50 transition-colors"
>
{loading ? 'Sending…' : 'Send reset link'}
</button>
<p className="text-center text-sm text-gray-500">
<Link href="/login" className="text-blue-600 hover:underline">
<Link href="/login" className="text-accent-700 hover:underline">
Back to sign in
</Link>
</p>
+3 -3
View File
@@ -8,13 +8,13 @@ interface Props {
export default async function LoginPage({ searchParams }: Props) {
const { message } = await searchParams
return (
<main className="min-h-screen flex items-center justify-center bg-gray-50 p-4">
<main className="min-h-screen flex items-center justify-center bg-ground p-4">
{message === 'password_reset' && (
<div className="fixed top-4 left-1/2 -translate-x-1/2 bg-green-50 border border-green-200 text-green-700 text-sm px-4 py-2 shadow">
<div className="fixed top-4 left-1/2 -translate-x-1/2 bg-neutral-100 border border-divider text-ink text-sm px-4 py-2 shadow">
Password updated — sign in with your new password.
</div>
)}
<div className="bg-surface shadow-sm border p-8 w-full max-w-sm">
<div className="bg-surface border-2 border-divider p-8 w-full max-w-sm">
<LoginForm />
</div>
</main>
+3 -3
View File
@@ -68,7 +68,7 @@ export default function ResetPasswordPage() {
required
minLength={8}
autoComplete="new-password"
className="border border-divider px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
className="border border-divider px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-accent"
/>
<input
type="password"
@@ -77,13 +77,13 @@ export default function ResetPasswordPage() {
onChange={e => setConfirm(e.target.value)}
required
autoComplete="new-password"
className="border border-divider px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
className="border border-divider px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-accent"
/>
<button
type="submit"
disabled={loading}
className="bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 disabled:opacity-50 transition-colors"
className="bg-accent hover:bg-accent-600 text-white font-medium py-2 disabled:opacity-50 transition-colors"
>
{loading ? 'Saving…' : 'Set password'}
</button>
+1 -1
View File
@@ -57,7 +57,7 @@ export default async function AdminHome() {
<p className="text-sm text-gray-500 mt-0.5">Manage users, sites, zones, and trucks</p>
</div>
<div className="mb-6 flex gap-3">
<Link href="/bulk-import" className="px-4 py-2 bg-green-600 text-white text-sm font-medium hover:bg-green-700">
<Link href="/bulk-import" className="px-4 py-2 bg-accent text-white text-sm font-medium hover:bg-accent-600">
Bulk Import Incidents
</Link>
</div>
+1 -1
View File
@@ -86,7 +86,7 @@ export default async function CapaOwnerPage() {
<div className="flex-1 min-w-0">
<p className="text-sm text-gray-800">{capa.description}</p>
{capa.incidentRefNo && (
<Link href={`/hse/incidents/${capa.incidentId}`} className="text-xs text-blue-600 hover:underline mt-0.5 inline-block">
<Link href={`/hse/incidents/${capa.incidentId}`} className="text-xs text-accent-700 hover:underline mt-0.5 inline-block">
{capa.incidentRefNo}
</Link>
)}
+1 -1
View File
@@ -53,7 +53,7 @@ export default async function CapaDetailPage({ params }: Props) {
return (
<main className="max-w-2xl mx-auto px-4 py-6">
<Link href="/hse/capa" className="text-sm text-blue-600 hover:underline mb-4 inline-block">
<Link href="/hse/capa" className="text-sm text-accent-700 hover:underline mb-4 inline-block">
← CAPA Board
</Link>
+1 -1
View File
@@ -52,7 +52,7 @@ export default async function CapaListPage() {
<main className="max-w-6xl mx-auto px-4 py-6">
<div className="flex items-center justify-between mb-6">
<h1 className="text-2xl font-bold text-gray-900">CAPA Board</h1>
<Link href="/hse/incidents" className="text-sm text-blue-600 hover:underline">
<Link href="/hse/incidents" className="text-sm text-accent-700 hover:underline">
← Incidents
</Link>
</div>
+14 -14
View File
@@ -175,7 +175,7 @@ export default async function HseDashboardPage({
>
JKKP 8
</a>
<Link href="/hse/incidents" className="text-sm text-blue-600 hover:underline">
<Link href="/hse/incidents" className="text-sm text-accent-700 hover:underline">
All incidents →
</Link>
</div>
@@ -187,8 +187,8 @@ export default async function HseDashboardPage({
{(tab === 'overview') && (
<>
{now.getMonth() === 0 && (
<div className="bg-amber-50 border border-amber-200 p-4 mb-6">
<p className="text-sm text-amber-800">
<div className="bg-accent-100 border border-accent-300 p-4 mb-6">
<p className="text-sm text-accent-700">
<strong>JKKP 8 annual register due:</strong> the {now.getFullYear() - 1} register must be
submitted to DOSH before 31 January {now.getFullYear()}.{' '}
<a href={`/api/reports/jkkp8?year=${now.getFullYear() - 1}`} className="underline font-medium">
@@ -218,18 +218,18 @@ export default async function HseDashboardPage({
Leading: hazard + near-miss reports (predict risk) · Lagging: injuries (past harm)
</p>
<div className="flex gap-4">
<div className="flex-1 text-center bg-blue-50 p-4">
<p className="text-3xl font-bold text-blue-600">{leadingCount}</p>
<p className="text-xs text-blue-700 mt-1">Leading (Hazards + Near Misses)</p>
<div className="flex-1 text-center bg-neutral-100 p-4">
<p className="text-3xl font-bold text-accent-700">{leadingCount}</p>
<p className="text-xs text-accent-700 mt-1">Leading (Hazards + Near Misses)</p>
</div>
<div className="flex-1 text-center bg-red-50 p-4">
<p className="text-3xl font-bold text-red-600">{laggingCount}</p>
<p className="text-xs text-red-700 mt-1">Lagging (Injuries)</p>
</div>
{capaOnTimeRate !== null && (
<div className="flex-1 text-center bg-green-50 p-4">
<p className="text-3xl font-bold text-green-600">{capaOnTimeRate}%</p>
<p className="text-xs text-green-700 mt-1">CAPA On-Time Rate</p>
<div className="flex-1 text-center bg-neutral-100 p-4">
<p className="text-3xl font-bold text-ink">{capaOnTimeRate}%</p>
<p className="text-xs text-ink mt-1">CAPA On-Time Rate</p>
</div>
)}
</div>
@@ -253,7 +253,7 @@ export default async function HseDashboardPage({
return (
<div key={m.month} className="flex-1 flex flex-col items-center gap-1">
<div className="w-full flex flex-col-reverse" style={{ height: '192px' }}>
<div className="w-full bg-blue-400" style={{ height: `${(m.leading / monthlyMax) * 192}px` }} />
<div className="w-full bg-accent-400" style={{ height: `${(m.leading / monthlyMax) * 192}px` }} />
<div className="w-full bg-red-400" style={{ height: `${(m.lagging / monthlyMax) * 192}px` }} />
<div className="w-full bg-gray-300" style={{ height: `${(Math.max(0, other) / monthlyMax) * 192}px` }} />
</div>
@@ -296,9 +296,9 @@ export default async function HseDashboardPage({
{by_zone.map(({ name, count }) => (
<div key={name} className="flex items-center gap-3">
<span className="text-sm text-gray-600 w-36 shrink-0 truncate">{name}</span>
<div className="flex-1 bg-gray-100 rounded-full h-3">
<div className="flex-1 bg-gray-100 h-3">
<div
className="h-3 rounded-full"
className="h-3"
style={{
width: `${(count / zoneMax) * 100}%`,
backgroundColor: `hsl(220, 70%, ${Math.max(30, 80 - Math.round((count / zoneMax) * 50))}%)`,
@@ -318,9 +318,9 @@ export default async function HseDashboardPage({
{Object.entries(by_type).sort((a, b) => b[1] - a[1]).map(([type, count]) => (
<div key={type} className="flex items-center gap-3">
<span className="text-sm text-gray-600 w-32 shrink-0">{TYPE_LABELS[type] ?? type}</span>
<div className="flex-1 bg-gray-100 rounded-full h-2">
<div className="flex-1 bg-gray-100 h-2">
<div
className="bg-blue-500 h-2 rounded-full"
className="bg-accent h-2"
style={{ width: total > 0 ? `${(count / total) * 100}%` : '0%' }}
/>
</div>
@@ -31,7 +31,7 @@ export default async function NewCapaPage({ params }: Props) {
return (
<main className="max-w-lg mx-auto px-4 py-6">
<Link href={`/hse/incidents/${id}`} className="text-sm text-blue-600 hover:underline mb-4 inline-block">
<Link href={`/hse/incidents/${id}`} className="text-sm text-accent-700 hover:underline mb-4 inline-block">
← Back to incident
</Link>
<h1 className="text-xl font-bold text-gray-900 mb-1">Add CAPA Action</h1>
@@ -43,7 +43,7 @@ export default async function InvestigationPage({ params }: Props) {
return (
<main className="max-w-2xl mx-auto px-4 py-6">
<Link href={`/hse/incidents/${id}`} className="text-sm text-blue-600 hover:underline mb-4 inline-block">
<Link href={`/hse/incidents/${id}`} className="text-sm text-accent-700 hover:underline mb-4 inline-block">
← Back to incident
</Link>
<h1 className="text-xl font-bold text-gray-900 mb-1">Investigation Workspace</h1>
+1 -1
View File
@@ -194,7 +194,7 @@ export default async function HseIncidentDetailPage({ params }: Props) {
href={`/api/incidents/${id}/report-pdf`}
target="_blank"
rel="noopener noreferrer"
className="flex items-center gap-1.5 px-3 py-1.5 bg-green-600 text-white text-xs font-semibold hover:bg-green-700 transition-colors"
className="flex items-center gap-1.5 px-3 py-1.5 bg-accent text-white text-xs font-semibold hover:bg-accent-600 transition-colors"
>
<svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
<path strokeLinecap="round" strokeLinejoin="round" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
@@ -35,7 +35,7 @@ export default async function TriagePage({ params }: Props) {
return (
<main className="max-w-lg mx-auto px-4 py-6">
<Link href={`/hse/incidents/${id}`} className="text-sm text-blue-600 hover:underline mb-4 inline-block">
<Link href={`/hse/incidents/${id}`} className="text-sm text-accent-700 hover:underline mb-4 inline-block">
← Back to incident
</Link>
<h1 className="text-xl font-bold text-gray-900 mb-1">Triage Incident</h1>
+3 -3
View File
@@ -123,9 +123,9 @@ export default async function ManagementPage() {
<h2 className="text-sm font-semibold text-gray-700 uppercase tracking-wide mb-1">Leading vs Lagging — Last 30 Days</h2>
<p className="text-xs text-gray-400 mb-4">Leading: hazard + near-miss · Lagging: injuries</p>
<div className="flex gap-6">
<div className="flex-1 text-center bg-blue-50 p-4">
<p className="text-3xl font-bold text-blue-600">{leadingCount}</p>
<p className="text-xs text-blue-700 mt-1">Leading (Hazards + Near Misses)</p>
<div className="flex-1 text-center bg-neutral-100 p-4">
<p className="text-3xl font-bold text-accent-700">{leadingCount}</p>
<p className="text-xs text-accent-700 mt-1">Leading (Hazards + Near Misses)</p>
</div>
<div className="flex-1 text-center bg-red-50 p-4">
<p className="text-3xl font-bold text-red-600">{laggingCount}</p>
@@ -60,7 +60,7 @@ export default async function ReporterIncidentDetail({
return (
<main className="max-w-2xl mx-auto px-4 py-6 space-y-4">
<div className="flex items-center gap-2 mb-2">
<Link href="/reporter" className="text-sm text-blue-600 hover:underline">← My Reports</Link>
<Link href="/reporter" className="text-sm text-accent-700 hover:underline">← My Reports</Link>
</div>
<div className="bg-surface shadow-sm p-5">
@@ -105,11 +105,11 @@ export default async function ReporterIncidentDetail({
{capas.map(c => (
<div key={c.id} className="flex items-start justify-between gap-3 text-sm">
<p className="text-gray-700 flex-1">{c.description}</p>
<span className={`text-xs rounded-full px-2 py-0.5 shrink-0 ${
c.status === 'verified' ? 'bg-green-100 text-green-700' :
c.status === 'pending_verification' ? 'bg-purple-100 text-purple-700' :
'bg-gray-100 text-gray-600'
}`}>{c.status.replace(/_/g, ' ')}</span>
<span className={`text-xs px-2 py-0.5 shrink-0 ${
c.status === 'verified' ? 'bg-neutral-100 text-ink' :
c.status === 'pending_verification' ? 'bg-accent-100 text-accent-700' :
'bg-gray-100 text-gray-600'
}`}>{c.status.replace(/_/g, ' ')}</span>
</div>
))}
</div>
+4 -4
View File
@@ -54,7 +54,7 @@ export default async function ReporterPage() {
</div>
<Link
href="/report"
className="bg-blue-600 text-white px-4 py-2 text-sm font-semibold hover:bg-blue-700"
className="bg-accent text-white px-4 py-2 text-sm font-semibold hover:bg-accent-600"
>
+ New Report
</Link>
@@ -66,11 +66,11 @@ export default async function ReporterPage() {
<p className="text-xs text-gray-500 mt-1">Total Submitted</p>
</div>
<div className="bg-surface shadow-sm p-4 flex-1 text-center">
<p className="text-2xl font-bold text-yellow-600">{openCount}</p>
<p className="text-2xl font-bold text-accent-700">{openCount}</p>
<p className="text-xs text-gray-500 mt-1">In Progress</p>
</div>
<div className="bg-surface shadow-sm p-4 flex-1 text-center">
<p className="text-2xl font-bold text-green-600">{closedCount}</p>
<p className="text-2xl font-bold text-ink">{closedCount}</p>
<p className="text-xs text-gray-500 mt-1">Closed</p>
</div>
</div>
@@ -78,7 +78,7 @@ export default async function ReporterPage() {
{rows.length === 0 ? (
<div className="bg-surface shadow-sm p-8 text-center">
<p className="text-gray-400 text-sm mb-4">No incidents reported yet.</p>
<Link href="/report" className="text-blue-600 text-sm hover:underline">Submit your first report →</Link>
<Link href="/report" className="text-accent-700 text-sm hover:underline">Submit your first report →</Link>
</div>
) : (
<div className="bg-surface shadow-sm divide-y divide-gray-50">
@@ -136,7 +136,7 @@ export default async function SupervisorIncidentDetailPage({ params }: Props) {
return (
<main className="max-w-3xl mx-auto px-4 py-6">
<Link href="/supervisor/incidents" className="text-sm text-blue-600 hover:underline mb-4 inline-block">
<Link href="/supervisor/incidents" className="text-sm text-accent-700 hover:underline mb-4 inline-block">
← Back to inbox
</Link>
<IncidentDetail incident={incidentProp} />
+1 -1
View File
@@ -111,7 +111,7 @@ export default async function SupervisorPage() {
<h1 className="text-2xl font-bold text-gray-900">Supervisor Portal</h1>
<p className="text-sm text-gray-500 mt-1">{siteName}</p>
</div>
<Link href="/supervisor/incidents" className="text-sm text-blue-600 hover:underline">
<Link href="/supervisor/incidents" className="text-sm text-accent-700 hover:underline">
All incidents →
</Link>
</div>
+13
View File
@@ -71,6 +71,19 @@
--color-blue-900: var(--color-accent-900);
--color-blue-950: var(--color-accent-900);
/* Existing red-* utilities (errors, destructive) render on the accent ramp;
600 and 700 map to accent-700 so body-size text clears contrast. */
--color-red-50: var(--color-accent-100);
--color-red-100: var(--color-accent-100);
--color-red-200: var(--color-accent-200);
--color-red-300: var(--color-accent-300);
--color-red-400: var(--color-accent-400);
--color-red-500: var(--color-accent-600);
--color-red-600: var(--color-accent-700);
--color-red-700: var(--color-accent-700);
--color-red-800: var(--color-accent-800);
--color-red-900: var(--color-accent-900);
/* Zero corner radius, everywhere. */
--radius: 0px;
--radius-xs: 0px;
+1 -1
View File
@@ -67,7 +67,7 @@ export default async function ReportPage({ searchParams }: Props) {
{siteName ?? 'Unknown Site'} — {zoneName}
</p>
) : (
<p className="text-sm text-amber-600 mt-1">No zone detected — zone will not be recorded</p>
<p className="text-sm text-accent-700 mt-1">No zone detected — zone will not be recorded</p>
)}
</div>
<ReportForm
+1 -1
View File
@@ -21,7 +21,7 @@ export default async function ReportSuccessPage({ searchParams }: Props) {
<p className="text-sm text-gray-500 mb-6">
The supervisor and HSE officer have been notified.
</p>
<Link href="/report" className="text-sm text-blue-600 hover:underline">
<Link href="/report" className="text-sm text-accent-700 hover:underline">
Submit another report
</Link>
</div>
+5 -5
View File
@@ -67,7 +67,7 @@ export default function ChangePasswordForm() {
onChange={e => setCurrent(e.target.value)}
disabled={loading}
autoComplete="current-password"
className="w-full border border-divider px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50"
className="w-full border border-divider px-3 py-2 text-sm focus:ring-2 focus:ring-accent focus:border-transparent disabled:opacity-50"
/>
</div>
<div>
@@ -80,7 +80,7 @@ export default function ChangePasswordForm() {
onChange={e => setNewPass(e.target.value)}
disabled={loading}
autoComplete="new-password"
className="w-full border border-divider px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50"
className="w-full border border-divider px-3 py-2 text-sm focus:ring-2 focus:ring-accent focus:border-transparent disabled:opacity-50"
/>
</div>
<div>
@@ -93,17 +93,17 @@ export default function ChangePasswordForm() {
onChange={e => setConfirm(e.target.value)}
disabled={loading}
autoComplete="new-password"
className="w-full border border-divider px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50"
className="w-full border border-divider px-3 py-2 text-sm focus:ring-2 focus:ring-accent focus:border-transparent disabled:opacity-50"
/>
</div>
{error && <p className="text-xs text-red-600 mt-1">{error}</p>}
{success && <p className="text-xs text-green-600 mt-1">Password changed successfully.</p>}
{success && <p className="text-xs text-ink mt-1">Password changed successfully.</p>}
<button
type="submit"
disabled={loading}
className="bg-blue-600 text-white px-4 py-2 text-sm font-semibold disabled:opacity-50 hover:bg-blue-700"
className="bg-accent text-white px-4 py-2 text-sm font-semibold disabled:opacity-50 hover:bg-accent-600"
>
{loading ? 'Saving…' : 'Update Password'}
</button>
+7 -7
View File
@@ -31,15 +31,15 @@ export function AdminPanel({ users, sites, siteOptions, trucks }: Props) {
key={t.id}
onClick={() => setTab(t.id)}
className={`px-4 py-2.5 text-sm font-medium border-b-2 -mb-px transition-colors cursor-pointer ${
tab === t.id
? 'border-green-600 text-green-700'
: 'border-transparent text-gray-500 hover:text-gray-700'
}`}
tab === t.id
? 'border-accent text-ink'
: 'border-transparent text-gray-500 hover:text-gray-700'
}`}
>
{t.label}
<span className={`ml-1.5 text-xs px-1.5 py-0.5 rounded-full ${
tab === t.id ? 'bg-green-100 text-green-700' : 'bg-gray-100 text-gray-500'
}`}>{t.count}</span>
<span className={`ml-1.5 text-xs px-1.5 py-0.5 ${
tab === t.id ? 'bg-neutral-100 text-ink' : 'bg-gray-100 text-gray-500'
}`}>{t.count}</span>
</button>
))}
</div>
+3 -3
View File
@@ -208,7 +208,7 @@ export function BulkImportForm() {
<button
onClick={handleImport}
disabled={!canImport || loading}
className="px-4 py-2 bg-blue-600 text-white disabled:opacity-50 disabled:cursor-not-allowed"
className="px-4 py-2 bg-accent text-white disabled:opacity-50 disabled:cursor-not-allowed"
>
{loading ? 'Importing...' : 'Import All'}
</button>
@@ -220,9 +220,9 @@ export function BulkImportForm() {
return (
<div className="space-y-4">
<h3 className="font-bold text-green-600">✓ Import Complete</h3>
<h3 className="font-bold text-ink">✓ Import Complete</h3>
<p>{folders.length} incidents created</p>
{message && <p className="text-green-600 text-sm">{message}</p>}
{message && <p className="text-ink text-sm">{message}</p>}
</div>
)
}
+15 -15
View File
@@ -3,6 +3,7 @@
import { useState } from 'react'
import { useRouter } from 'next/navigation'
import { Modal } from '@/components/ui/modal'
import { INPUT_CLASS as inp } from '@/components/ui/field'
export type SiteWithZones = {
id: string
@@ -16,7 +17,6 @@ interface Props {
sites: SiteWithZones[]
}
const inp = 'w-full border border-gray-300 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-green-500'
const lbl = 'block text-xs font-medium text-gray-600 mb-1'
type DeleteTarget = { kind: 'site'; id: string; name: string } | { kind: 'zone'; id: string; name: string }
@@ -96,7 +96,7 @@ export function SiteZoneManager({ sites }: Props) {
Add Zone
</button>
<button onClick={() => { setShowAddSite(true); setError(null) }}
className="flex items-center gap-1.5 px-3 py-1.5 bg-green-600 text-white text-xs font-semibold hover:bg-green-700 transition-colors cursor-pointer">
className="flex items-center gap-1.5 px-3 py-1.5 bg-accent text-white text-xs font-semibold hover:bg-accent-600 transition-colors cursor-pointer">
<svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2.5}>
<path strokeLinecap="round" strokeLinejoin="round" d="M12 4v16m8-8H4" />
</svg>
@@ -118,11 +118,11 @@ export function SiteZoneManager({ sites }: Props) {
<div className="flex items-center gap-2">
<button disabled={busyId === site.id}
onClick={() => send('PATCH', { kind: 'site', id: site.id, active: !site.active })}
className={`text-xs font-medium px-2.5 py-1 rounded-full border transition-colors cursor-pointer disabled:opacity-50 ${
site.active
? 'bg-green-50 text-green-700 border-green-200 hover:bg-green-100'
: 'bg-gray-50 text-gray-500 border-divider hover:bg-gray-100'
}`}>
className={`text-xs font-medium px-2.5 py-1 border transition-colors cursor-pointer disabled:opacity-50 ${
site.active
? 'bg-neutral-100 text-ink border-divider hover:bg-neutral-200'
: 'bg-gray-50 text-gray-500 border-divider hover:bg-gray-100'
}`}>
{site.active ? 'Active' : 'Inactive'}
</button>
<button disabled={busyId === site.id}
@@ -140,16 +140,16 @@ export function SiteZoneManager({ sites }: Props) {
<span className="text-xs text-gray-700 font-medium">{z.name}</span>
<div className="flex items-center gap-3">
<a href={`/report?zone=${z.qr_code_token}`} target="_blank"
className="text-xs text-blue-600 hover:underline cursor-pointer">
className="text-xs text-accent-700 hover:underline cursor-pointer">
Report link
</a>
<button disabled={busyId === z.id}
onClick={() => send('PATCH', { kind: 'zone', id: z.id, active: !z.active })}
className={`text-xs font-medium px-2 py-0.5 rounded-full border transition-colors cursor-pointer disabled:opacity-50 ${
z.active
? 'bg-green-50 text-green-700 border-green-200 hover:bg-green-100'
: 'bg-gray-50 text-gray-500 border-divider hover:bg-gray-100'
}`}>
className={`text-xs font-medium px-2 py-0.5 border transition-colors cursor-pointer disabled:opacity-50 ${
z.active
? 'bg-neutral-100 text-ink border-divider hover:bg-neutral-200'
: 'bg-gray-50 text-gray-500 border-divider hover:bg-gray-100'
}`}>
{z.active ? 'Active' : 'Inactive'}
</button>
<button disabled={busyId === z.id}
@@ -183,7 +183,7 @@ export function SiteZoneManager({ sites }: Props) {
</button>
<button disabled={busy || !siteName.trim()}
onClick={async () => { if (await post({ kind: 'site', name: siteName })) { setSiteName(''); setShowAddSite(false) } }}
className="px-4 py-2 bg-green-600 text-white text-sm font-semibold hover:bg-green-700 disabled:opacity-50 cursor-pointer transition-colors">
className="px-4 py-2 bg-accent text-white text-sm font-semibold hover:bg-accent-600 disabled:opacity-50 cursor-pointer transition-colors">
{busy ? 'Adding…' : 'Add Site'}
</button>
</>
@@ -214,7 +214,7 @@ export function SiteZoneManager({ sites }: Props) {
setZoneName(''); setZoneSiteId(''); setShowAddZone(false)
}
}}
className="px-4 py-2 bg-green-600 text-white text-sm font-semibold hover:bg-green-700 disabled:opacity-50 cursor-pointer transition-colors">
className="px-4 py-2 bg-accent text-white text-sm font-semibold hover:bg-accent-600 disabled:opacity-50 cursor-pointer transition-colors">
{busy ? 'Adding…' : 'Add Zone'}
</button>
</>
+9 -9
View File
@@ -3,6 +3,7 @@
import { useState } from 'react'
import { useRouter } from 'next/navigation'
import { Modal } from '@/components/ui/modal'
import { INPUT_CLASS as inp } from '@/components/ui/field'
export type Truck = {
id: string
@@ -15,7 +16,6 @@ interface Props {
trucks: Truck[]
}
const inp = 'w-full border border-gray-300 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-green-500'
const lbl = 'block text-xs font-medium text-gray-600 mb-1'
export function TruckManager({ trucks }: Props) {
@@ -90,7 +90,7 @@ export function TruckManager({ trucks }: Props) {
<p className="text-xs text-gray-400 mt-0.5">{trucks.length} vehicle{trucks.length !== 1 ? 's' : ''}</p>
</div>
<button onClick={() => { setShowAdd(true); setError(null) }}
className="flex items-center gap-1.5 px-3 py-1.5 bg-green-600 text-white text-xs font-semibold hover:bg-green-700 transition-colors cursor-pointer">
className="flex items-center gap-1.5 px-3 py-1.5 bg-accent text-white text-xs font-semibold hover:bg-accent-600 transition-colors cursor-pointer">
<svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2.5}>
<path strokeLinecap="round" strokeLinejoin="round" d="M12 4v16m8-8H4" />
</svg>
@@ -109,16 +109,16 @@ export function TruckManager({ trucks }: Props) {
</div>
<div className="flex items-center gap-3">
<a href={`/report?truck_id=${tk.id}`} target="_blank"
className="text-xs text-blue-600 hover:underline cursor-pointer">
className="text-xs text-accent-700 hover:underline cursor-pointer">
Report link
</a>
<button disabled={busyId === tk.id}
onClick={() => send('PATCH', { id: tk.id, active: !tk.active })}
className={`text-xs font-medium px-2.5 py-1 rounded-full border transition-colors cursor-pointer disabled:opacity-50 ${
tk.active
? 'bg-green-50 text-green-700 border-green-200 hover:bg-green-100'
: 'bg-gray-50 text-gray-500 border-divider hover:bg-gray-100'
}`}>
className={`text-xs font-medium px-2.5 py-1 border transition-colors cursor-pointer disabled:opacity-50 ${
tk.active
? 'bg-neutral-100 text-ink border-divider hover:bg-neutral-200'
: 'bg-gray-50 text-gray-500 border-divider hover:bg-gray-100'
}`}>
{tk.active ? 'Active' : 'Inactive'}
</button>
<button disabled={busyId === tk.id} onClick={() => setConfirmDelete(tk)}
@@ -143,7 +143,7 @@ export function TruckManager({ trucks }: Props) {
Cancel
</button>
<button disabled={submitting || !truckNo.trim()} onClick={handleAdd}
className="px-4 py-2 bg-green-600 text-white text-sm font-semibold hover:bg-green-700 disabled:opacity-50 cursor-pointer transition-colors">
className="px-4 py-2 bg-accent text-white text-sm font-semibold hover:bg-accent-600 disabled:opacity-50 cursor-pointer transition-colors">
{submitting ? 'Adding…' : 'Add Truck'}
</button>
</>
+10 -10
View File
@@ -4,6 +4,7 @@ import { useState } from 'react'
import { useRouter } from 'next/navigation'
import { ALL_ROLES, type UserRole } from '@/lib/auth/roles'
import { Modal } from '@/components/ui/modal'
import { INPUT_CLASS as inp } from '@/components/ui/field'
export type AdminUser = {
id: string
@@ -24,7 +25,6 @@ interface Props {
const EMPTY = { email: '', name: '', phone: '', role: 'reporter' as UserRole, site_id: '', password: '' }
const inp = 'w-full border border-gray-300 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-green-500'
const lbl = 'block text-xs font-medium text-gray-600 mb-1'
export function UserManager({ users, sites }: Props) {
@@ -103,7 +103,7 @@ export function UserManager({ users, sites }: Props) {
</div>
<button
onClick={() => { setShowAdd(true); setError(null) }}
className="flex items-center gap-1.5 px-3 py-1.5 bg-green-600 text-white text-xs font-semibold hover:bg-green-700 transition-colors cursor-pointer"
className="flex items-center gap-1.5 px-3 py-1.5 bg-accent text-white text-xs font-semibold hover:bg-accent-600 transition-colors cursor-pointer"
>
<svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2.5}>
<path strokeLinecap="round" strokeLinejoin="round" d="M12 4v16m8-8H4" />
@@ -134,14 +134,14 @@ export function UserManager({ users, sites }: Props) {
<td className="px-5 py-3">
<select value={u.role} disabled={busyId === u.id}
onChange={e => patchUser(u.id, { role: e.target.value })}
className="border border-divider px-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-green-500 cursor-pointer">
className="border border-divider px-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-accent cursor-pointer">
{ALL_ROLES.map(r => <option key={r} value={r}>{r.replace(/_/g, ' ')}</option>)}
</select>
</td>
<td className="px-5 py-3">
<select value={u.site_id ?? ''} disabled={busyId === u.id}
onChange={e => patchUser(u.id, { site_id: e.target.value || null })}
className="border border-divider px-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-green-500 cursor-pointer">
className="border border-divider px-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-accent cursor-pointer">
<option value="">No site</option>
{sites.map(s => <option key={s.id} value={s.id}>{s.name}</option>)}
</select>
@@ -149,11 +149,11 @@ export function UserManager({ users, sites }: Props) {
<td className="px-5 py-3">
<button disabled={busyId === u.id}
onClick={() => patchUser(u.id, { active: !u.active })}
className={`text-xs px-2.5 py-1 rounded-full font-medium border transition-colors cursor-pointer ${
u.active
? 'bg-green-50 text-green-700 border-green-200 hover:bg-green-100'
: 'bg-gray-50 text-gray-500 border-divider hover:bg-gray-100'
}`}>
className={`text-xs px-2.5 py-1 font-medium border transition-colors cursor-pointer ${
u.active
? 'bg-neutral-100 text-ink border-divider hover:bg-neutral-200'
: 'bg-gray-50 text-gray-500 border-divider hover:bg-gray-100'
}`}>
{u.active ? 'Active' : 'Inactive'}
</button>
</td>
@@ -182,7 +182,7 @@ export function UserManager({ users, sites }: Props) {
Cancel
</button>
<button form="add-user-form" type="submit" disabled={submitting}
className="px-4 py-2 bg-green-600 text-white text-sm font-semibold hover:bg-green-700 disabled:opacity-50 cursor-pointer transition-colors">
className="px-4 py-2 bg-accent text-white text-sm font-semibold hover:bg-accent-600 disabled:opacity-50 cursor-pointer transition-colors">
{submitting ? 'Adding…' : 'Add User'}
</button>
</>
+12 -16
View File
@@ -4,6 +4,8 @@
import { useState } from 'react'
import { useRouter } from 'next/navigation'
import Link from 'next/link'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/field'
export function LoginForm() {
const [email, setEmail] = useState('')
@@ -37,44 +39,38 @@ export function LoginForm() {
return (
<form onSubmit={handleSubmit} className="flex flex-col gap-4 w-full max-w-sm">
<div className="text-center">
<h1 className="text-2xl font-bold">IMS</h1>
<p className="text-sm text-gray-500 mt-1">HSE Incident Management</p>
<div className="pb-3 border-b-2 border-divider">
<h1 className="text-3xl font-extrabold">IMS</h1>
<p className="text-sm text-ink/60 mt-1">HSE Incident Management</p>
</div>
{error && (
<p className="bg-red-50 border border-red-200 text-red-700 text-sm px-3 py-2">
<p className="bg-accent-100 border border-accent text-accent-800 text-sm px-3 py-2">
{error}
</p>
)}
<input
<Input
type="email"
placeholder="Email"
value={email}
onChange={(e) => setEmail(e.target.value)}
required
autoComplete="email"
className="border px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
/>
<input
<Input
type="password"
placeholder="Password"
value={password}
onChange={(e) => setPassword(e.target.value)}
required
autoComplete="current-password"
className="border px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
/>
<button
type="submit"
disabled={loading}
className="bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 disabled:opacity-50 transition-colors"
>
<Button type="submit" variant="primary" block disabled={loading}>
{loading ? 'Signing in…' : 'Sign in'}
</button>
<p className="text-center text-sm text-gray-500">
<Link href="/forgot-password" className="text-blue-600 hover:underline">
</Button>
<p className="text-sm text-ink/60">
<Link href="/forgot-password" className="text-accent-700 hover:underline">
Forgot password?
</Link>
</p>
+2 -2
View File
@@ -54,7 +54,7 @@ export function CapaBoard({ capas }: Props) {
return (
<div>
<div className="flex justify-end mb-3">
<button onClick={() => setView('board')} className="text-sm text-blue-600 hover:underline">Board view</button>
<button onClick={() => setView('board')} className="text-sm text-accent-700 hover:underline">Board view</button>
</div>
<div className="overflow-x-auto">
<table className="w-full text-sm">
@@ -75,7 +75,7 @@ export function CapaBoard({ capas }: Props) {
{(c.incidents as { reference_no: string | null } | null)?.reference_no ?? '—'}
</td>
<td className="py-2 pr-4">
<Link href={`/hse/capa/${c.id}`} className="text-blue-600 hover:underline line-clamp-2">
<Link href={`/hse/capa/${c.id}`} className="text-accent-700 hover:underline line-clamp-2">
{c.description}
</Link>
</td>
+1 -1
View File
@@ -121,7 +121,7 @@ export function CapaForm({ incidentId }: Props) {
{error && <p className="text-sm text-red-600">{error}</p>}
<button type="submit" disabled={saving}
className="w-full bg-amber-600 text-white py-2 text-sm font-semibold disabled:opacity-50">
className="w-full bg-accent text-white py-2 text-sm font-semibold disabled:opacity-50">
{saving ? 'Creating…' : 'Create CAPA Action'}
</button>
</form>
+1 -1
View File
@@ -48,7 +48,7 @@ export function CapaOwnerActions({ capaId, currentStatus }: Props) {
<button
onClick={() => updateStatus('pending_verification')}
disabled={loading}
className="text-sm px-3 py-1.5 bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50"
className="text-sm px-3 py-1.5 bg-accent text-white hover:bg-accent-600 disabled:opacity-50"
>
{loading ? '…' : 'Submit for Verification'}
</button>
+2 -2
View File
@@ -39,7 +39,7 @@ export function CapaOwnerNotesForm({ capaId, initialNotes }: Props) {
onChange={e => { setNotes(e.target.value); setSaved(false) }}
rows={2}
placeholder="Add any notes or updates for this action…"
className="w-full border border-divider px-3 py-2 text-sm text-gray-800 resize-none focus:outline-none focus:ring-2 focus:ring-blue-500"
className="w-full border border-divider px-3 py-2 text-sm text-gray-800 resize-none focus:outline-none focus:ring-2 focus:ring-accent"
/>
{error && <p className="text-xs text-red-600">{error}</p>}
<div className="flex items-center gap-2">
@@ -50,7 +50,7 @@ export function CapaOwnerNotesForm({ capaId, initialNotes }: Props) {
>
{saving ? 'Saving…' : 'Save Notes'}
</button>
{saved && <span className="text-xs text-green-600">Saved</span>}
{saved && <span className="text-xs text-ink">Saved</span>}
</div>
</div>
)
+2 -2
View File
@@ -31,7 +31,7 @@ export function CloseCapaButton({ capaId }: Props) {
}
return (
<div className="border border-divider p-5 space-y-3 bg-green-50">
<div className="border border-divider p-5 space-y-3 bg-neutral-100">
<h3 className="text-sm font-semibold text-gray-800">Close CAPA</h3>
<p className="text-sm text-gray-600">
This CAPA has been verified as effective. Close it to mark it fully resolved.
@@ -40,7 +40,7 @@ export function CloseCapaButton({ capaId }: Props) {
<button
onClick={handleClose}
disabled={loading}
className="w-full bg-green-700 text-white py-2 text-sm font-semibold hover:bg-green-800 disabled:opacity-50"
className="w-full bg-accent text-white py-2 text-sm font-semibold hover:bg-accent-700 disabled:opacity-50"
>
{loading ? 'Closing…' : 'Close CAPA'}
</button>
+9 -9
View File
@@ -39,17 +39,17 @@ export function VerifyForm({ capaId }: Props) {
}
return (
<form onSubmit={handleSubmit} className="border border-divider p-5 space-y-4 bg-purple-50">
<form onSubmit={handleSubmit} className="border border-divider p-5 space-y-4 bg-accent-100">
<h3 className="text-sm font-semibold text-gray-800">HSE Verification</h3>
<div className="flex gap-3">
<button
type="button"
onClick={() => setVerdict('verified')}
className={`flex-1 py-2 text-sm font-medium border ${
verdict === 'verified'
? 'bg-green-600 text-white border-green-600'
: 'bg-surface text-gray-700 border-divider hover:border-green-500'
}`}
verdict === 'verified'
? 'bg-accent text-white border-accent'
: 'bg-surface text-gray-700 border-divider hover:border-accent'
}`}
>
Verified — Effective
</button>
@@ -57,10 +57,10 @@ export function VerifyForm({ capaId }: Props) {
type="button"
onClick={() => setVerdict('reopened')}
className={`flex-1 py-2 text-sm font-medium border ${
verdict === 'reopened'
? 'bg-orange-600 text-white border-orange-600'
: 'bg-surface text-gray-700 border-divider hover:border-orange-500'
}`}
verdict === 'reopened'
? 'bg-accent text-white border-accent'
: 'bg-surface text-gray-700 border-divider hover:border-accent'
}`}
>
Reopen — Ineffective
</button>
+4 -4
View File
@@ -21,10 +21,10 @@ function TabsInner({ activeTab }: { activeTab: string }) {
key={tab.key}
onClick={() => router.replace(`${pathname}?tab=${tab.key}`)}
className={`px-4 py-2.5 text-sm font-medium whitespace-nowrap border-b-2 transition-colors ${
activeTab === tab.key
? 'border-blue-600 text-blue-600'
: 'border-transparent text-gray-500 hover:text-gray-700 hover:border-divider'
}`}
activeTab === tab.key
? 'border-accent text-accent-700'
: 'border-transparent text-gray-500 hover:text-gray-700 hover:border-divider'
}`}
>
{tab.label}
</button>
+1 -1
View File
@@ -51,7 +51,7 @@ export function RiskFlagsPanel() {
<button
onClick={analyze}
disabled={loading}
className="bg-purple-50 text-purple-700 border border-purple-300 px-3 py-1.5 text-xs font-semibold disabled:opacity-50 hover:bg-purple-100"
className="bg-accent-100 text-accent-700 border border-accent-300 px-3 py-1.5 text-xs font-semibold disabled:opacity-50 hover:bg-accent-200"
>
{loading ? 'Analyzing…' : flags ? 'Re-analyze' : 'Analyze 90-Day Risk'}
</button>
+2 -2
View File
@@ -7,8 +7,8 @@ interface Props {
const ACCENT = {
default: 'border-gray-200',
green: 'border-green-400',
yellow: 'border-yellow-400',
green: 'border-divider',
yellow: 'border-accent-300',
red: 'border-red-400',
}
+1 -1
View File
@@ -78,7 +78,7 @@ export function ClosurePanel({ incidentId, status, canClose, canAddAddenda }: Pr
<button
onClick={closeIncident}
disabled={busy}
className="bg-green-700 text-white px-4 py-2 text-sm font-semibold hover:bg-green-800 disabled:opacity-50"
className="bg-accent text-white px-4 py-2 text-sm font-semibold hover:bg-accent-700 disabled:opacity-50"
>
{busy ? 'Closing…' : 'Close Incident'}
</button>
+2 -2
View File
@@ -58,8 +58,8 @@ export function FileUpload({ onFilesChange, disabled = false }: Props) {
<div className="space-y-2">
<div
className={`border-2 border-dashed p-6 text-center cursor-pointer transition-colors
${dragging ? 'border-blue-500 bg-blue-50' : 'border-divider hover:border-gray-400'}
${disabled ? 'opacity-50 pointer-events-none' : ''}`}
${dragging ? 'border-accent bg-accent-100' : 'border-divider hover:border-gray-400'}
${disabled ? 'opacity-50 pointer-events-none' : ''}`}
onClick={() => inputRef.current?.click()}
onDragOver={e => { e.preventDefault(); setDragging(true) }}
onDragLeave={() => setDragging(false)}
+5 -5
View File
@@ -77,20 +77,20 @@ function FiltersInner({ sites, trucks }: FiltersProps) {
placeholder="Search reference or description..."
value={search}
onChange={e => handleSearch(e.target.value)}
className="w-full pl-8 pr-3 py-1.5 text-sm border border-divider focus:outline-none focus:ring-2 focus:ring-blue-500"
className="w-full pl-8 pr-3 py-1.5 text-sm border border-divider focus:outline-none focus:ring-2 focus:ring-accent"
/>
</div>
<select
value={searchParams.get('status') ?? ''}
onChange={e => updateParam('status', e.target.value)}
className="text-sm border border-divider px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-500 bg-surface"
className="text-sm border border-divider px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent bg-surface"
>
{STATUS_OPTIONS.map(o => <option key={o.value} value={o.value}>{o.label}</option>)}
</select>
<select
value={searchParams.get('type') ?? ''}
onChange={e => updateParam('type', e.target.value)}
className="text-sm border border-divider px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-500 bg-surface"
className="text-sm border border-divider px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent bg-surface"
>
{TYPE_OPTIONS.map(o => <option key={o.value} value={o.value}>{o.label}</option>)}
</select>
@@ -98,7 +98,7 @@ function FiltersInner({ sites, trucks }: FiltersProps) {
<select
value={searchParams.get('site_id') ?? ''}
onChange={e => updateParam('site_id', e.target.value)}
className="text-sm border border-divider px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-500 bg-surface"
className="text-sm border border-divider px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent bg-surface"
>
<option value="">All Sites</option>
{sites.map(s => <option key={s.id} value={s.id}>{s.name}</option>)}
@@ -108,7 +108,7 @@ function FiltersInner({ sites, trucks }: FiltersProps) {
<select
value={searchParams.get('truck_id') ?? ''}
onChange={e => updateParam('truck_id', e.target.value)}
className="text-sm border border-divider px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-500 bg-surface"
className="text-sm border border-divider px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent bg-surface"
>
<option value="">All Trucks</option>
{trucks.map(tk => <option key={tk.id} value={tk.id}>{tk.truck_no}</option>)}
+3 -3
View File
@@ -43,7 +43,7 @@ export function IncidentHeader({
{canTriage && (
<Link
href={`/hse/incidents/${incidentId}/triage`}
className="text-xs px-3 py-1.5 bg-blue-600 text-white font-medium hover:bg-blue-700"
className="text-xs px-3 py-1.5 bg-accent text-white font-medium hover:bg-accent-600"
>
Triage
</Link>
@@ -51,7 +51,7 @@ export function IncidentHeader({
{canInvestigate && (
<Link
href={`/hse/incidents/${incidentId}/investigation`}
className="text-xs px-3 py-1.5 bg-indigo-600 text-white font-medium hover:bg-indigo-700"
className="text-xs px-3 py-1.5 bg-accent text-white font-medium hover:bg-accent-600"
>
Investigate
</Link>
@@ -59,7 +59,7 @@ export function IncidentHeader({
{canAddCapa && (
<Link
href={`/hse/incidents/${incidentId}/capa/new`}
className="text-xs px-3 py-1.5 bg-amber-600 text-white font-medium hover:bg-amber-700"
className="text-xs px-3 py-1.5 bg-accent text-white font-medium hover:bg-accent-600"
>
Add CAPA
</Link>
+3 -3
View File
@@ -60,12 +60,12 @@ export function IncidentList({ incidents, basePath }: Props) {
<input
type="search"
placeholder="Search ref, type, site…"
className="border border-divider px-3 py-2 text-sm w-48 focus:outline-none focus:ring-2 focus:ring-blue-500"
className="border border-divider px-3 py-2 text-sm w-48 focus:outline-none focus:ring-2 focus:ring-accent"
value={search}
onChange={e => setSearch(e.target.value)}
/>
<select
className="border border-divider px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
className="border border-divider px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-accent"
value={typeFilter}
onChange={e => setTypeFilter(e.target.value)}
>
@@ -75,7 +75,7 @@ export function IncidentList({ incidents, basePath }: Props) {
))}
</select>
<select
className="border border-divider px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
className="border border-divider px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-accent"
value={statusFilter}
onChange={e => setStatusFilter(e.target.value)}
>
+10 -10
View File
@@ -136,7 +136,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
type="button"
onClick={getAiDraft}
disabled={aiDraftLoading}
className="bg-purple-50 text-purple-700 border border-purple-300 px-3 py-1.5 text-xs font-semibold disabled:opacity-50 hover:bg-purple-100"
className="bg-accent-100 text-accent-700 border border-accent-300 px-3 py-1.5 text-xs font-semibold disabled:opacity-50 hover:bg-accent-200"
>
{aiDraftLoading ? 'Drafting…' : 'Get AI Draft'}
</button>
@@ -149,10 +149,10 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
key={m} type="button"
onClick={() => setMethod(m)}
className={`px-3 py-1.5 text-sm font-medium border ${
method === m
? 'bg-blue-600 text-white border-blue-600'
: 'bg-surface text-gray-700 border-divider hover:border-blue-400'
}`}
method === m
? 'bg-accent text-white border-accent'
: 'bg-surface text-gray-700 border-divider hover:border-accent'
}`}
>
{m === 'five_why' ? '5-Why' : m === 'fishbone' ? 'Fishbone' : 'Other'}
</button>
@@ -182,7 +182,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
))}
{fiveWhy.length < 5 && (
<button type="button" onClick={addWhyStep}
className="text-sm text-blue-600 hover:underline">
className="text-sm text-accent-700 hover:underline">
+ Add another Why
</button>
)}
@@ -205,7 +205,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
/>
))}
<button type="button" onClick={() => addFishboneCause(catIdx)}
className="text-xs text-blue-600 hover:underline">
className="text-xs text-accent-700 hover:underline">
+ Add cause
</button>
</div>
@@ -262,7 +262,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
<button
type="button"
onClick={() => setWitnessRefs([...witnessRefs, ''])}
className="text-xs text-blue-600 hover:underline"
className="text-xs text-accent-700 hover:underline"
>
+ Add witness statement
</button>
@@ -293,7 +293,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
{!existingInvestigationId && (
<label className="flex items-center gap-2 text-sm text-gray-700">
<input type="checkbox" checked={complete} onChange={e => setComplete(e.target.checked)}
className="border-divider text-blue-600" />
className="border-divider text-accent-700" />
Mark investigation complete (transitions incident to CAPA Pending)
</label>
)}
@@ -301,7 +301,7 @@ export function InvestigationForm({ incidentId, existingInvestigationId }: Props
{error && <p className="text-sm text-red-600">{error}</p>}
<button type="submit" disabled={saving}
className="w-full bg-indigo-600 text-white py-2 text-sm font-semibold disabled:opacity-50">
className="w-full bg-accent text-white py-2 text-sm font-semibold disabled:opacity-50">
{saving ? 'Saving…' : existingInvestigationId ? 'Update Investigation' : 'Start Investigation'}
</button>
</form>
+6 -6
View File
@@ -40,11 +40,11 @@ export function InvestigationPanel({ investigation: inv }: Props) {
<h2 className="text-sm font-semibold text-gray-900">Investigation</h2>
<div className="flex items-center gap-2">
<span className="text-xs text-gray-500">{METHOD_LABELS[inv.method] ?? inv.method}</span>
<span className={`text-xs font-medium px-2 py-0.5 rounded-full ${
inv.completed_at
? 'bg-green-100 text-green-700'
: 'bg-yellow-100 text-yellow-700'
}`}>
<span className={`text-xs font-medium px-2 py-0.5 ${
inv.completed_at
? 'bg-neutral-100 text-ink'
: 'bg-accent-100 text-accent-700'
}`}>
{inv.completed_at ? 'Completed' : 'In Progress'}
</span>
</div>
@@ -67,7 +67,7 @@ export function InvestigationPanel({ investigation: inv }: Props) {
<ol className="space-y-3">
{inv.five_why_steps.map((step, i) => (
<li key={i} className="flex gap-3">
<span className="flex-shrink-0 w-6 h-6 rounded-full bg-blue-100 text-blue-700 text-xs font-bold flex items-center justify-center">
<span className="flex-shrink-0 w-6 h-6 bg-accent-100 text-accent-700 text-xs font-bold flex items-center justify-center">
{i + 1}
</span>
<div className="flex-1 min-w-0">
+4 -4
View File
@@ -56,15 +56,15 @@ export function OfflineSync() {
if (pendingCount === 0) return null
return (
<div className="fixed bottom-4 left-4 right-4 bg-yellow-50 border border-yellow-300 p-3 flex items-center justify-between shadow-md z-50">
<span className="text-sm text-yellow-800 font-medium">
<div className="fixed bottom-4 left-4 right-4 bg-accent-100 border border-accent-300 p-3 flex items-center justify-between shadow-md z-50">
<span className="text-sm text-accent-700 font-medium">
{pendingCount} report{pendingCount > 1 ? 's' : ''} saved offline
</span>
<button
onClick={syncNow}
disabled={syncing || !navigator.onLine}
className="text-xs bg-yellow-600 text-white px-3 py-1.5 font-medium
hover:bg-yellow-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
className="text-xs bg-accent text-white px-3 py-1.5 font-medium
hover:bg-accent-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
>
{syncing ? 'Syncing…' : 'Sync now'}
</button>
+1 -1
View File
@@ -15,7 +15,7 @@ export function Pagination({ page, pageSize, total, href }: Props) {
disabled ? (
<span className="px-3 py-1.5 text-sm text-gray-300">{label}</span>
) : (
<Link href={`${href}?page=${p}`} className="px-3 py-1.5 text-sm text-blue-600 hover:underline">
<Link href={`${href}?page=${p}`} className="px-3 py-1.5 text-sm text-accent-700 hover:underline">
{label}
</Link>
)
+18 -18
View File
@@ -73,7 +73,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
value={(typeDetails[key] as string) ?? ''}
onChange={e => setDetail(key, e.target.value)}
placeholder={placeholder}
className="w-full border border-divider px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
className="w-full border border-divider px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-accent"
/>
</div>
)
@@ -82,7 +82,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
<label className="flex items-center gap-3 cursor-pointer">
<input
type="checkbox"
className="w-4 h-4 text-blue-600"
className="w-4 h-4 text-accent-700"
checked={Boolean(typeDetails[key])}
onChange={e => setDetail(key, e.target.checked)}
/>
@@ -205,7 +205,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
if (savedOffline) {
return (
<div className="bg-green-50 border border-green-200 p-5 text-sm text-green-700">
<div className="bg-neutral-100 border border-divider p-5 text-sm text-ink">
{t.savedOffline}
</div>
)
@@ -214,7 +214,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
return (
<form onSubmit={handleSubmit} className="space-y-5 bg-surface shadow-sm p-5">
{!isOnline && (
<div className="bg-yellow-50 border border-yellow-200 p-3 text-sm text-yellow-700">
<div className="bg-accent-100 border border-accent-300 p-3 text-sm text-accent-700">
{t.offlineBanner}
</div>
)}
@@ -231,7 +231,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
</label>
<select
required
className="w-full border border-divider px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
className="w-full border border-divider px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-accent"
value={form.incident_type}
onChange={e => {
setForm(f => ({ ...f, incident_type: e.target.value as IncidentType, truck_id: '' }))
@@ -278,7 +278,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
</label>
<select
required
className="w-full border border-divider px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
className="w-full border border-divider px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-accent"
value={form.truck_id}
onChange={e => setForm(f => ({ ...f, truck_id: e.target.value }))}
>
@@ -301,31 +301,31 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
minLength={10}
rows={4}
placeholder={t.descriptionPlaceholder}
className="w-full border border-divider px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 resize-none"
className="w-full border border-divider px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-accent resize-none"
value={form.description}
onChange={e => setForm(f => ({ ...f, description: e.target.value }))}
/>
</div>
{qualityCheck && !qualityCheck.passes && (
<div className="bg-amber-50 border border-amber-200 p-3 space-y-2">
<p className="text-xs font-semibold text-amber-700 uppercase tracking-wide">
<div className="bg-accent-100 border border-accent-300 p-3 space-y-2">
<p className="text-xs font-semibold text-accent-700 uppercase tracking-wide">
{t.qualityScoreLabel.replace('{score}', String(qualityCheck.score))}
</p>
<p className="text-sm text-amber-800">{qualityCheck.feedback}</p>
<p className="text-sm text-accent-700">{qualityCheck.feedback}</p>
{qualityCheck.suggestions.length > 0 && (
<ul className="list-disc list-inside space-y-1">
{qualityCheck.suggestions.map((s, i) => (
<li key={i} className="text-xs text-amber-700">{s}</li>
<li key={i} className="text-xs text-accent-700">{s}</li>
))}
</ul>
)}
<label className="flex items-center gap-2 text-xs text-amber-700 cursor-pointer mt-1">
<label className="flex items-center gap-2 text-xs text-accent-700 cursor-pointer mt-1">
<input
type="checkbox"
checked={overrideQuality}
onChange={e => setOverrideQuality(e.target.checked)}
className="border-amber-300 text-amber-600"
className="border-accent-300 text-accent-700"
/>
{t.submitAnyway}
</label>
@@ -336,7 +336,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
<label className="flex items-center gap-3 cursor-pointer">
<input
type="checkbox"
className="w-4 h-4 text-blue-600"
className="w-4 h-4 text-accent-700"
checked={form.injury_involved}
onChange={e => setForm(f => ({ ...f, injury_involved: e.target.checked, medical_status: '' }))}
/>
@@ -350,7 +350,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
</label>
<select
required={form.injury_involved}
className="w-full border border-divider px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
className="w-full border border-divider px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-accent"
value={form.medical_status}
onChange={e => setForm(f => ({ ...f, medical_status: e.target.value as MedicalStatus }))}
>
@@ -365,7 +365,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
<label className="flex items-center gap-3 cursor-pointer">
<input
type="checkbox"
className="w-4 h-4 text-blue-600"
className="w-4 h-4 text-accent-700"
checked={form.asset_involved}
onChange={e => setForm(f => ({ ...f, asset_involved: e.target.checked }))}
/>
@@ -383,8 +383,8 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) {
<button
type="submit"
disabled={submitting || !form.incident_type || (form.incident_type === 'transport' && !form.truck_id)}
className="w-full bg-blue-600 text-white py-3 font-medium text-sm
hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
className="w-full bg-accent text-white py-3 font-medium text-sm
hover:bg-accent-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
>
{submitting ? t.submitting : t.submitButton}
</button>
@@ -60,7 +60,7 @@ export function SimilarIncidentsPanel({ incidentId }: Props) {
<a
key={inc.id}
href={`/hse/incidents/${inc.id}`}
className="block border border-divider p-3 hover:border-blue-300 hover:bg-blue-50 transition-colors"
className="block border border-divider p-3 hover:border-accent hover:bg-neutral-100 transition-colors"
>
<div className="flex items-center justify-between mb-1">
<span className="text-xs font-medium text-gray-500">
+12 -12
View File
@@ -102,10 +102,10 @@ export function TriageForm({ incidentId, currentSeverity }: Props) {
type="button"
onClick={() => setSeverity(v)}
className={`flex-1 py-2 text-xs font-medium transition-colors ${
severity === v
? 'bg-blue-600 text-white border-blue-600'
: 'bg-surface text-gray-700 hover:bg-gray-50'
}`}
severity === v
? 'bg-accent text-white border-accent'
: 'bg-surface text-gray-700 hover:bg-gray-50'
}`}
>
<span className="block font-bold">{v}</span>
<span className="block">{SEVERITY_LABELS[v].split(' / ')[0]}</span>
@@ -126,7 +126,7 @@ export function TriageForm({ incidentId, currentSeverity }: Props) {
<input
type="checkbox" checked={value}
onChange={e => set(e.target.checked)}
className="border-divider text-blue-600"
className="border-divider text-accent-700"
/>
{label}
</label>
@@ -151,16 +151,16 @@ export function TriageForm({ incidentId, currentSeverity }: Props) {
value={triageNotes}
onChange={e => setTriageNotes(e.target.value)}
rows={3}
className="w-full border border-divider px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent"
className="w-full border border-divider px-3 py-2 text-sm focus:ring-2 focus:ring-accent focus:border-transparent"
placeholder="Initial assessment, immediate actions taken..."
/>
</div>
{aiRationale && (
<div className="bg-purple-50 border border-purple-200 p-3">
<p className="text-xs font-semibold text-purple-700 mb-1">AI Suggestion Rationale</p>
<p className="text-xs text-purple-600">{aiRationale}</p>
<p className="text-xs text-purple-400 mt-1">Fields pre-filled — review before submitting.</p>
<div className="bg-accent-100 border border-accent-300 p-3">
<p className="text-xs font-semibold text-accent-700 mb-1">AI Suggestion Rationale</p>
<p className="text-xs text-accent-700">{aiRationale}</p>
<p className="text-xs text-accent-400 mt-1">Fields pre-filled — review before submitting.</p>
</div>
)}
@@ -171,14 +171,14 @@ export function TriageForm({ incidentId, currentSeverity }: Props) {
type="button"
onClick={getAiSuggestion}
disabled={aiLoading || saving}
className="flex-1 bg-purple-50 text-purple-700 border border-purple-300 py-2 text-sm font-semibold disabled:opacity-50 hover:bg-purple-100"
className="flex-1 bg-accent-100 text-accent-700 border border-accent-300 py-2 text-sm font-semibold disabled:opacity-50 hover:bg-accent-200"
>
{aiLoading ? 'Getting suggestion…' : 'Get AI Suggestion'}
</button>
<button
type="submit"
disabled={saving}
className="flex-1 bg-blue-600 text-white py-2 text-sm font-semibold disabled:opacity-50"
className="flex-1 bg-accent text-white py-2 text-sm font-semibold disabled:opacity-50"
>
{saving ? 'Saving…' : 'Complete Triage'}
</button>
+1 -1
View File
@@ -33,7 +33,7 @@ export function LanguageSwitcher() {
value={current}
onChange={e => handleChange(e.target.value)}
aria-label="Select language"
className="text-xs border border-divider px-2 py-1 bg-surface text-gray-700 focus:outline-none focus:ring-1 focus:ring-blue-500"
className="text-xs border border-divider px-2 py-1 bg-surface text-gray-700 focus:outline-none focus:ring-1 focus:ring-accent"
>
{Object.entries(LOCALES).map(([code, label]) => (
<option key={code} value={code}>{label}</option>
+8 -8
View File
@@ -47,11 +47,11 @@ export function ApiKeyForm({ settings }: Props) {
<div key={key} className="bg-surface shadow-sm p-5">
<div className="flex items-center justify-between mb-1">
<label className="text-sm font-semibold text-gray-800">{KEY_LABELS[key]}</label>
<span className={`text-xs font-medium px-2 py-0.5 rounded-full ${
status?.set
? 'bg-green-100 text-green-700'
: 'bg-yellow-100 text-yellow-700'
}`}>
<span className={`text-xs font-medium px-2 py-0.5 ${
status?.set
? 'bg-neutral-100 text-ink'
: 'bg-accent-100 text-accent-700'
}`}>
{status?.set ? 'Configured' : 'Not set'}
</span>
</div>
@@ -66,18 +66,18 @@ export function ApiKeyForm({ settings }: Props) {
value={values[key]}
onChange={e => setValues(v => ({ ...v, [key]: e.target.value }))}
placeholder={status?.set ? 'Enter new key to replace…' : 'Enter API key…'}
className="flex-1 border border-divider px-3 py-2 text-sm text-gray-900 placeholder-gray-500 focus:ring-2 focus:ring-blue-500 focus:border-transparent font-mono"
className="flex-1 border border-divider px-3 py-2 text-sm text-gray-900 placeholder-gray-500 focus:ring-2 focus:ring-accent focus:border-transparent font-mono"
/>
<button
onClick={() => save(key)}
disabled={saving[key] || !values[key]}
className="bg-blue-600 text-white px-4 py-2 text-sm font-semibold disabled:opacity-50 hover:bg-blue-700"
className="bg-accent text-white px-4 py-2 text-sm font-semibold disabled:opacity-50 hover:bg-accent-600"
>
{saving[key] ? 'Saving…' : 'Save'}
</button>
</div>
{results[key] === 'ok' && (
<p className="text-xs text-green-600 mt-2">Saved. Reload the page to confirm.</p>
<p className="text-xs text-ink mt-2">Saved. Reload the page to confirm.</p>
)}
{results[key] === 'error' && (
<p className="text-xs text-red-600 mt-2">Save failed. Check your permissions.</p>
@@ -451,7 +451,6 @@ function transformClassAttr(attr) {
out = out.replace(/(?<![\w-])shadow-(?:xl|2xl)(?![\w-])/g, 'shadow-lg')
out = out.replace(/(["'])([^"'`$]*)\1/g, (_, q, body) => q + body.trim().replace(/ {2,}/g, ' ') + q)
out = out.replace(/^(className=\{`)\s+/, '$1').replace(/\s+(`\})$/, '$1')
out = out.replace(/ {2,}/g, ' ')
return out
}
+2 -1
View File
@@ -9,7 +9,8 @@
"lint": "eslint",
"test": "vitest run",
"test:watch": "vitest",
"generate-qr": "tsx scripts/generate-qr.ts"
"generate-qr": "tsx scripts/generate-qr.ts",
"check:design": "node scripts/check-design-gates.mjs"
},
"dependencies": {
"@anthropic-ai/sdk": "^0.111.0",
+61
View File
@@ -0,0 +1,61 @@
import { readdirSync, readFileSync, statSync } from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
// Files where a circular element is legitimate (avatar). Add others only with a reason.
export const ROUND_ALLOWED = ['components/layout/sidebar.tsx']
const RULES = [
{
rule: 'no-rounded',
re: /(?<=[\s"'`:{])(?:[\w-]+:)*rounded(?:-(?!full(?![\w-]))[\w]+)*(?=[\s"'`}])/,
},
{ rule: 'no-bg-white', re: /(?<![\w-])bg-white(?![\w-])/ },
{ rule: 'no-heavy-shadow', re: /(?<![\w-])shadow-(?:xl|2xl)(?![\w-])/ },
{
rule: 'off-palette',
re: /(?<![\w-])(?:bg|text|border|ring|from|to|via|divide|fill|stroke|outline)-(?:green|yellow|amber|orange|purple|indigo|teal|emerald|sky|cyan|pink|rose|violet|lime|fuchsia)-\d{2,3}/,
},
{ rule: 'no-hex', re: /(?<![&\w])#[0-9a-fA-F]{3,8}\b/ },
{ rule: 'no-centered-button', re: /<button[^>]*className=[^>]*(?<![\w-])text-center(?![\w-])/ },
]
export function findViolations(src, file) {
const out = []
const roundAllowed = ROUND_ALLOWED.includes(file)
src.split('\n').forEach((text, i) => {
const line = i + 1
for (const { rule, re } of RULES) {
if (re.test(text)) out.push({ file, line, rule, text: text.trim() })
}
if (!roundAllowed && /(?<=[\s"'`:{])(?:[\w-]+:)*rounded-full(?=[\s"'`}])/.test(text)) {
out.push({ file, line, rule: 'no-rounded-full', text: text.trim() })
}
})
return out
}
function walk(dir, files = []) {
for (const name of readdirSync(dir)) {
const full = path.join(dir, name)
if (statSync(full).isDirectory()) walk(full, files)
else if (full.endsWith('.tsx')) files.push(full)
}
return files
}
function main() {
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
const all = []
for (const dir of ['app', 'components']) {
for (const abs of walk(path.join(root, dir))) {
const rel = path.relative(root, abs).split(path.sep).join('/')
all.push(...findViolations(readFileSync(abs, 'utf8'), rel))
}
}
for (const v of all) console.log(`${v.file}:${v.line} [${v.rule}] ${v.text}`)
console.log(all.length === 0 ? 'design gates: clean' : `design gates: ${all.length} violation(s)`)
process.exit(all.length === 0 ? 0 : 1)
}
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) main()
-1
View File
@@ -17,7 +17,6 @@ function transformClassAttr(attr) {
out = out.replace(/(?<![\w-])shadow-(?:xl|2xl)(?![\w-])/g, 'shadow-lg')
out = out.replace(/(["'])([^"'`$]*)\1/g, (_, q, body) => q + body.trim().replace(/ {2,}/g, ' ') + q)
out = out.replace(/^(className=\{`)\s+/, '$1').replace(/\s+(`\})$/, '$1')
out = out.replace(/ {2,}/g, ' ')
return out
}
+5
View File
@@ -39,6 +39,11 @@ describe('Modernist tokens in globals.css', () => {
expect(css).toMatch(/--color-blue-700:\s*var\(--color-accent-700\)/)
})
it('remaps the red ramp onto the accent ramp, with body-size steps on accent-700', () => {
expect(css).toMatch(/--color-red-600:\s*var\(--color-accent-700\)/)
expect(css).toMatch(/--color-red-50:\s*var\(--color-accent-100\)/)
})
it('maps shadows onto the Modernist elevation tokens', () => {
expect(css).toMatch(/--shadow-2xl:\s*var\(--shadow-lg\)/)
})
+45
View File
@@ -0,0 +1,45 @@
import { describe, it, expect } from 'vitest'
import { findViolations, ROUND_ALLOWED } from '../../scripts/check-design-gates.mjs'
const rules = (src: string, file = 'components/x.tsx'): string[] =>
(findViolations(src, file) as Array<{ rule: string }>).map(v => v.rule)
describe('design gates', () => {
it('flags rounded corner classes', () => {
expect(rules('<div className="rounded-lg p-2" />')).toContain('no-rounded')
expect(rules('<div className="p-2 hover:rounded-md" />')).toContain('no-rounded')
})
it('flags rounded-full outside the allowlist and accepts it inside', () => {
expect(rules('<div className="rounded-full" />')).toContain('no-rounded-full')
expect(rules('<div className="rounded-full" />', ROUND_ALLOWED[0])).not.toContain('no-rounded-full')
})
it('flags off-palette colors but accepts remapped gray, blue and red', () => {
expect(rules('<p className="text-green-700" />')).toContain('off-palette')
expect(rules('<p className="bg-purple-100" />')).toContain('off-palette')
expect(rules('<p className="text-gray-500 text-blue-700 bg-red-50" />')).toEqual([])
})
it('flags hard-coded hex colors', () => {
expect(rules('<div style={{ color: "#ec3013" }} />')).toContain('no-hex')
expect(rules('<p>&#39;quoted&#39;</p>')).not.toContain('no-hex')
})
it('flags centered button labels', () => {
expect(rules('<button className="text-center px-2">x</button>')).toContain('no-centered-button')
})
it('flags leftovers the codemod should have replaced', () => {
expect(rules('<div className="bg-white shadow-2xl" />')).toEqual(expect.arrayContaining(['no-bg-white', 'no-heavy-shadow']))
})
it('reports file and 1-based line numbers', () => {
const v = findViolations('a\n<div className="rounded-md" />', 'components/y.tsx')
expect(v[0]).toMatchObject({ file: 'components/y.tsx', line: 2, rule: 'no-rounded' })
})
it('accepts clean on-system markup', () => {
expect(rules('<div className="bg-surface border border-divider p-4 text-ink shadow-sm" />')).toEqual([])
})
})