feat(design): switch to IMS Admin tokens, Geist and the 1px-rule gate
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -14,7 +14,7 @@ export default async function LoginPage({ searchParams }: Props) {
|
||||
Password updated — sign in with your new password.
|
||||
</div>
|
||||
)}
|
||||
<div className="bg-surface border-2 border-divider p-8 w-full max-w-sm">
|
||||
<div className="bg-surface border border-divider p-8 w-full max-w-sm">
|
||||
<LoginForm />
|
||||
</div>
|
||||
</main>
|
||||
|
||||
+102
-89
@@ -1,50 +1,65 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
/* Modernist tokens. Source of truth: the Modernist styles.css under design-system/_ds.
|
||||
/* IMS Admin refresh tokens. Source of truth: design-system/design.md section 2.
|
||||
Static emits every variable so plain CSS can use var(--color-*) too. */
|
||||
@theme static {
|
||||
--color-bg: #f3f2f2;
|
||||
--color-surface: #eae9e9;
|
||||
--color-text: #201e1d;
|
||||
--color-accent: #ec3013;
|
||||
--color-accent-2: #e15b47;
|
||||
--color-divider: color-mix(in srgb, #201e1d 40%, transparent);
|
||||
--color-ink: #1f1f1f;
|
||||
--color-ink-2: #303030;
|
||||
--color-ink-3: #4a4a4a;
|
||||
--color-muted: #616161;
|
||||
--color-faint: #8a8a8a;
|
||||
--color-rule: #ebebeb;
|
||||
--color-rule-2: #e3e3e3;
|
||||
--color-ring: #d4d4d4;
|
||||
--color-surface: #ffffff;
|
||||
--color-surface-2: #f7f7f7;
|
||||
--color-ground: #f1f1f1;
|
||||
--color-accent: #0f766e;
|
||||
--color-accent-tint: #f2f7f6;
|
||||
--color-accent-tint-2: #e6f4f1;
|
||||
--color-danger: #b3261e;
|
||||
--color-topbar: #1a1a1a;
|
||||
|
||||
/* Utility-friendly aliases: bg-ground, text-ink */
|
||||
--color-ground: var(--color-bg);
|
||||
--color-ink: var(--color-text);
|
||||
/* Status pills: a dark step on a light tint, one pair per hue. */
|
||||
--color-st-amber-bg: #fff1c2;
|
||||
--color-st-amber-fg: #6b4a00;
|
||||
--color-st-blue-bg: #e0efff;
|
||||
--color-st-blue-fg: #00527c;
|
||||
--color-st-violet-bg: #ede7ff;
|
||||
--color-st-violet-fg: #4b2e99;
|
||||
--color-st-orange-bg: #ffe6cf;
|
||||
--color-st-orange-fg: #7a3a00;
|
||||
--color-st-indigo-bg: #e3e8ff;
|
||||
--color-st-indigo-fg: #2c3e8f;
|
||||
--color-st-green-bg: #d7f4e3;
|
||||
--color-st-green-fg: #0c5132;
|
||||
--color-st-grey-bg: #ebebeb;
|
||||
--color-st-grey-fg: #4a4a4a;
|
||||
--color-st-red-bg: #fee3e0;
|
||||
--color-st-red-fg: #8e1f0b;
|
||||
|
||||
--color-neutral-100: #f8f4f4;
|
||||
--color-neutral-200: #eae7e7;
|
||||
--color-neutral-300: #d7d3d3;
|
||||
--color-neutral-400: #bab6b6;
|
||||
--color-neutral-500: #9b9797;
|
||||
--color-neutral-600: #7d7979;
|
||||
--color-neutral-700: #605d5d;
|
||||
--color-neutral-800: #444141;
|
||||
--color-neutral-900: #2d2b2b;
|
||||
/* Legacy names kept, re-valued, until every page is migrated. */
|
||||
--color-divider: #e3e3e3;
|
||||
--color-neutral-100: #f7f7f7;
|
||||
--color-neutral-200: #ebebeb;
|
||||
--color-neutral-300: #d4d4d4;
|
||||
--color-neutral-400: #c4c4c4;
|
||||
--color-neutral-500: #8a8a8a;
|
||||
--color-neutral-600: #616161;
|
||||
--color-neutral-700: #4a4a4a;
|
||||
--color-neutral-800: #303030;
|
||||
--color-neutral-900: #1f1f1f;
|
||||
|
||||
--color-accent-100: #fff2ef;
|
||||
--color-accent-200: #ffe0d9;
|
||||
--color-accent-300: #ffc4b8;
|
||||
--color-accent-400: #ff9783;
|
||||
--color-accent-500: #ff563c;
|
||||
--color-accent-600: #dd2b0f;
|
||||
--color-accent-700: #ae1800;
|
||||
--color-accent-800: #7c1405;
|
||||
--color-accent-900: #4d170e;
|
||||
--color-accent-100: #e6f4f1;
|
||||
--color-accent-200: #c5e8e0;
|
||||
--color-accent-300: #9fd3c7;
|
||||
--color-accent-400: #5fb3a5;
|
||||
--color-accent-500: #2b9488;
|
||||
--color-accent-600: #0c615a;
|
||||
--color-accent-700: #0b4f47;
|
||||
--color-accent-800: #083b36;
|
||||
--color-accent-900: #052a26;
|
||||
|
||||
--color-accent-2-100: #fff2ef;
|
||||
--color-accent-2-200: #ffe0da;
|
||||
--color-accent-2-300: #ffc4b9;
|
||||
--color-accent-2-400: #ff9784;
|
||||
--color-accent-2-500: #ef6853;
|
||||
--color-accent-2-600: #c94b39;
|
||||
--color-accent-2-700: #9e3526;
|
||||
--color-accent-2-800: #71261b;
|
||||
--color-accent-2-900: #471d16;
|
||||
|
||||
/* Existing gray-* utilities render on the neutral ramp. */
|
||||
--color-gray-50: var(--color-neutral-100);
|
||||
--color-gray-100: var(--color-neutral-200);
|
||||
--color-gray-200: var(--color-neutral-300);
|
||||
@@ -54,11 +69,9 @@
|
||||
--color-gray-600: var(--color-neutral-700);
|
||||
--color-gray-700: var(--color-neutral-800);
|
||||
--color-gray-800: var(--color-neutral-900);
|
||||
--color-gray-900: var(--color-text);
|
||||
--color-gray-950: var(--color-text);
|
||||
--color-gray-900: var(--color-ink);
|
||||
--color-gray-950: var(--color-ink);
|
||||
|
||||
/* Existing blue-* utilities render on the accent ramp. 600 is the canonical
|
||||
accent; 700 and darker are safe for body-size text. */
|
||||
--color-blue-50: var(--color-accent-100);
|
||||
--color-blue-100: var(--color-accent-100);
|
||||
--color-blue-200: var(--color-accent-200);
|
||||
@@ -71,59 +84,63 @@
|
||||
--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);
|
||||
--color-red-50: #fee3e0;
|
||||
--color-red-100: #fee3e0;
|
||||
--color-red-200: #f9c4bd;
|
||||
--color-red-300: #f2a198;
|
||||
--color-red-400: #e06a5a;
|
||||
--color-red-500: #c9382a;
|
||||
--color-red-600: var(--color-danger);
|
||||
--color-red-700: #8e1f0b;
|
||||
--color-red-800: #6b1708;
|
||||
--color-red-900: #4a1005;
|
||||
|
||||
/* Zero corner radius, everywhere. */
|
||||
--radius: 0px;
|
||||
--radius-xs: 0px;
|
||||
--radius-sm: 0px;
|
||||
--radius-md: 0px;
|
||||
--radius-lg: 0px;
|
||||
--radius-xl: 0px;
|
||||
--radius-2xl: 0px;
|
||||
--radius-3xl: 0px;
|
||||
--radius-4xl: 0px;
|
||||
/* Radius scale: 8 buttons, chips, inputs, pills; 12 cards; 14 drawer. */
|
||||
--radius: 8px;
|
||||
--radius-xs: 4px;
|
||||
--radius-sm: 6px;
|
||||
--radius-md: 8px;
|
||||
--radius-lg: 8px;
|
||||
--radius-xl: 12px;
|
||||
--radius-2xl: 14px;
|
||||
--radius-3xl: 14px;
|
||||
--radius-4xl: 14px;
|
||||
|
||||
/* Elevation, tuned to the ground. */
|
||||
--shadow-sm: 0 1px 2px color-mix(in srgb, #2d2b2b 14%, transparent);
|
||||
--shadow-md: 0 3px 10px color-mix(in srgb, #2d2b2b 16%, transparent);
|
||||
--shadow-lg: 0 12px 32px color-mix(in srgb, #2d2b2b 22%, transparent);
|
||||
--shadow-xl: var(--shadow-lg);
|
||||
--shadow-2xl: var(--shadow-lg);
|
||||
--shadow-card: 0 0 0 1px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
|
||||
--shadow-float: 0 0 0 1px rgba(0,0,0,.1), 0 12px 32px rgba(0,0,0,.18);
|
||||
--shadow-drawer: 0 0 0 1px rgba(0,0,0,.1), 0 24px 60px rgba(0,0,0,.24);
|
||||
--shadow-primary: inset 0 -1px 0 #000, inset 0 1px 0 rgba(255,255,255,.18), 0 1px 2px rgba(0,0,0,.2);
|
||||
--shadow-secondary: inset 0 0 0 1px var(--color-ring), 0 1px 0 rgba(0,0,0,.05);
|
||||
--shadow-input: inset 0 0 0 1px var(--color-faint);
|
||||
--shadow-chip: inset 0 0 0 1px var(--color-ring);
|
||||
--shadow-chip-set: inset 0 0 0 1px var(--color-accent-300);
|
||||
--shadow-sm: 0 1px 2px rgba(0,0,0,.06);
|
||||
--shadow-md: 0 3px 10px rgba(0,0,0,.12);
|
||||
--shadow-lg: var(--shadow-float);
|
||||
--shadow-xl: var(--shadow-float);
|
||||
--shadow-2xl: var(--shadow-float);
|
||||
|
||||
--font-sans: var(--font-archivo), system-ui, sans-serif;
|
||||
--font-heading: var(--font-archivo), system-ui, sans-serif;
|
||||
--font-sans: var(--font-geist), system-ui, sans-serif;
|
||||
--font-mono: var(--font-geist-mono), ui-monospace, SFMono-Regular, Menlo, monospace;
|
||||
}
|
||||
|
||||
@layer base {
|
||||
html {
|
||||
background: var(--color-bg);
|
||||
background: var(--color-ground);
|
||||
}
|
||||
|
||||
body {
|
||||
background: var(--color-bg);
|
||||
color: var(--color-text);
|
||||
background: var(--color-ground);
|
||||
color: var(--color-ink);
|
||||
font-family: var(--font-sans);
|
||||
font-size: 15px;
|
||||
line-height: 1.55;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-family: var(--font-heading);
|
||||
font-weight: 800;
|
||||
line-height: 1.12;
|
||||
letter-spacing: -0.015em;
|
||||
font-weight: 650;
|
||||
line-height: 1.25;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
:focus {
|
||||
@@ -136,18 +153,18 @@
|
||||
}
|
||||
|
||||
::selection {
|
||||
background: color-mix(in srgb, var(--color-accent) 30%, transparent);
|
||||
background: color-mix(in srgb, var(--color-accent) 25%, transparent);
|
||||
}
|
||||
|
||||
input,
|
||||
textarea,
|
||||
select {
|
||||
color: var(--color-text);
|
||||
color: var(--color-ink);
|
||||
}
|
||||
|
||||
input::placeholder,
|
||||
textarea::placeholder {
|
||||
color: color-mix(in srgb, var(--color-text) 55%, transparent);
|
||||
color: var(--color-faint);
|
||||
}
|
||||
|
||||
button:disabled,
|
||||
@@ -158,7 +175,3 @@
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
.grayscale {
|
||||
filter: grayscale(1) contrast(1.08);
|
||||
}
|
||||
|
||||
+9
-4
@@ -1,11 +1,16 @@
|
||||
import type { Metadata } from 'next'
|
||||
import { Archivo } from 'next/font/google'
|
||||
import { Geist, Geist_Mono } from 'next/font/google'
|
||||
import './globals.css'
|
||||
import { I18nProvider } from '@/lib/i18n/context'
|
||||
import { getLocale, loadMessages } from '@/lib/i18n/server'
|
||||
|
||||
const archivo = Archivo({
|
||||
variable: '--font-archivo',
|
||||
const geist = Geist({
|
||||
variable: '--font-geist',
|
||||
subsets: ['latin'],
|
||||
})
|
||||
|
||||
const geistMono = Geist_Mono({
|
||||
variable: '--font-geist-mono',
|
||||
subsets: ['latin'],
|
||||
})
|
||||
|
||||
@@ -25,7 +30,7 @@ export default async function RootLayout({
|
||||
return (
|
||||
<html
|
||||
lang={locale}
|
||||
className={`${archivo.variable} h-full antialiased`}
|
||||
className={`${geist.variable} ${geistMono.variable} h-full antialiased`}
|
||||
>
|
||||
<head>
|
||||
<link rel="manifest" href="/manifest.json" />
|
||||
|
||||
@@ -30,7 +30,7 @@ export function AdminPanel({ users, sites, siteOptions, trucks }: Props) {
|
||||
<button
|
||||
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 ${
|
||||
className={`px-4 py-2.5 text-sm font-medium border-b -mb-px transition-colors cursor-pointer ${
|
||||
tab === t.id
|
||||
? 'border-accent text-ink'
|
||||
: 'border-transparent text-gray-500 hover:text-gray-700'
|
||||
|
||||
@@ -83,7 +83,7 @@ export function BulkImportForm() {
|
||||
if (stage === 'upload') {
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<label className="block cursor-pointer border-2 border-dashed border-divider p-6 text-center hover:bg-gray-50">
|
||||
<label className="block cursor-pointer border border-dashed border-divider p-6 text-center hover:bg-gray-50">
|
||||
<input
|
||||
type="file"
|
||||
onChange={handleUpload}
|
||||
|
||||
@@ -134,7 +134,7 @@ export function SiteZoneManager({ sites }: Props) {
|
||||
</div>
|
||||
|
||||
{site.zones.length > 0 && (
|
||||
<ul className="mt-3 space-y-1.5 pl-3 border-l-2 border-divider">
|
||||
<ul className="mt-3 space-y-1.5 pl-3 border-l border-divider">
|
||||
{site.zones.map(z => (
|
||||
<li key={z.id} className={`flex items-center justify-between ${!z.active ? 'opacity-50' : ''}`}>
|
||||
<span className="text-xs text-gray-700 font-medium">{z.name}</span>
|
||||
|
||||
@@ -39,7 +39,7 @@ export function LoginForm() {
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit} className="flex flex-col gap-4 w-full max-w-sm">
|
||||
<div className="pb-3 border-b-2 border-divider">
|
||||
<div className="pb-3 border-b border-divider">
|
||||
<h1 className="text-3xl font-extrabold">IMS</h1>
|
||||
<p className="text-sm text-ink/60 mt-1">HSE Incident Management</p>
|
||||
</div>
|
||||
|
||||
@@ -101,8 +101,8 @@ export function CapaBoard({ capas }: Props) {
|
||||
</div>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
{STATUS_ORDER.filter(s => s !== 'reopened').map(status => (
|
||||
<div key={status} className={`border-2 p-4 bg-ground ${COLUMN_BORDER[status]}`}>
|
||||
<h3 className="text-xs font-extrabold uppercase tracking-wide text-ink/70 mb-3 pb-2 border-b-2 border-divider">
|
||||
<div key={status} className={`border p-4 bg-ground ${COLUMN_BORDER[status]}`}>
|
||||
<h3 className="text-xs font-extrabold uppercase tracking-wide text-ink/70 mb-3 pb-2 border-b border-divider">
|
||||
{STATUS_LABELS[status]} ({byStatus[status].length})
|
||||
</h3>
|
||||
<div className="space-y-2 max-h-96 overflow-y-auto pr-2">
|
||||
|
||||
@@ -20,7 +20,7 @@ function TabsInner({ activeTab }: { activeTab: string }) {
|
||||
<button
|
||||
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 ${
|
||||
className={`px-4 py-2.5 text-sm font-medium whitespace-nowrap border-b transition-colors ${
|
||||
activeTab === tab.key
|
||||
? 'border-accent text-accent-700'
|
||||
: 'border-transparent text-gray-500 hover:text-gray-700 hover:border-divider'
|
||||
|
||||
@@ -57,7 +57,7 @@ export function FileUpload({ onFilesChange, disabled = false }: Props) {
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<div
|
||||
className={`border-2 border-dashed p-6 text-center cursor-pointer transition-colors
|
||||
className={`border border-dashed p-6 text-center cursor-pointer transition-colors
|
||||
${dragging ? 'border-accent bg-accent-100' : 'border-divider hover:border-gray-400'}
|
||||
${disabled ? 'opacity-50 pointer-events-none' : ''}`}
|
||||
onClick={() => inputRef.current?.click()}
|
||||
|
||||
@@ -87,7 +87,7 @@ function useNavItems(role: string): NavItem[] {
|
||||
return NAV_ITEMS[role] ?? NAV_ITEMS.reporter
|
||||
}
|
||||
|
||||
const LINK_BASE = 'flex items-center gap-3 px-3 py-2 text-sm border-l-2 transition-colors'
|
||||
const LINK_BASE = 'flex items-center gap-3 px-3 py-2 text-sm border-l transition-colors'
|
||||
const LINK_ACTIVE = 'border-accent text-accent-700 font-extrabold bg-accent-100/50'
|
||||
const LINK_IDLE = 'border-transparent text-ink/70 font-medium hover:bg-ink/7 hover:text-ink'
|
||||
|
||||
@@ -124,8 +124,8 @@ export function Sidebar({ role, userName, userEmail }: SidebarProps) {
|
||||
return (
|
||||
<>
|
||||
{/* Desktop sidebar */}
|
||||
<aside className="hidden sm:flex fixed left-0 top-0 h-full w-60 bg-ground border-r-2 border-divider flex-col z-40">
|
||||
<div className="flex items-center justify-between px-4 py-4 border-b-2 border-divider">
|
||||
<aside className="hidden sm:flex fixed left-0 top-0 h-full w-60 bg-ground border-r border-divider flex-col z-40">
|
||||
<div className="flex items-center justify-between px-4 py-4 border-b border-divider">
|
||||
<span className="text-lg font-extrabold tracking-tight text-ink">IMS</span>
|
||||
<NotificationBell />
|
||||
</div>
|
||||
@@ -136,7 +136,7 @@ export function Sidebar({ role, userName, userEmail }: SidebarProps) {
|
||||
))}
|
||||
</nav>
|
||||
|
||||
<div className="border-t-2 border-divider py-3">
|
||||
<div className="border-t border-divider py-3">
|
||||
<div className="flex items-center gap-2 px-4 py-2 mb-1">
|
||||
<div className="w-8 h-8 rounded-full bg-accent flex items-center justify-center text-ground text-xs font-extrabold flex-shrink-0">
|
||||
{initials(displayName)}
|
||||
@@ -170,7 +170,7 @@ export function Sidebar({ role, userName, userEmail }: SidebarProps) {
|
||||
</aside>
|
||||
|
||||
{/* Mobile bottom tab bar */}
|
||||
<nav className="sm:hidden fixed bottom-0 left-0 right-0 bg-ground border-t-2 border-divider flex z-40 safe-area-pb">
|
||||
<nav className="sm:hidden fixed bottom-0 left-0 right-0 bg-ground border-t border-divider flex z-40 safe-area-pb">
|
||||
{mobileItems.map(item => {
|
||||
const active = isActivePath(item.href, pathname)
|
||||
return (
|
||||
|
||||
@@ -75,7 +75,7 @@ export function NotificationBell() {
|
||||
|
||||
{open && (
|
||||
<div className="absolute right-0 mt-2 w-80 max-h-96 overflow-y-auto bg-surface shadow-lg border border-divider">
|
||||
<div className="flex items-center justify-between px-4 py-2 border-b-2 border-divider">
|
||||
<div className="flex items-center justify-between px-4 py-2 border-b border-divider">
|
||||
<span className="text-sm font-extrabold text-ink">Notifications</span>
|
||||
{unread > 0 && (
|
||||
<button onClick={markAllRead} className="text-xs text-accent-700 hover:underline">
|
||||
|
||||
@@ -28,7 +28,7 @@ export function Modal({ open, onClose, title, children, footer, width = 'md' }:
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center p-4" role="dialog" aria-modal="true">
|
||||
<div className="absolute inset-0 bg-neutral-900/50" onClick={onClose} />
|
||||
<div className={`relative w-full ${maxW} bg-surface shadow-lg`}>
|
||||
<div className="flex items-center justify-between px-6 py-4 border-b-2 border-divider">
|
||||
<div className="flex items-center justify-between px-6 py-4 border-b border-divider">
|
||||
<h2 className="text-xl font-extrabold text-ink">{title}</h2>
|
||||
<button
|
||||
onClick={onClose}
|
||||
|
||||
@@ -2,14 +2,9 @@ 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-2px-border', re: /(?<![\w-])border(?:-[tblrxy])?-2(?![\w-])/ },
|
||||
{ rule: 'no-archivo', re: /Archivo/ },
|
||||
{ rule: 'no-bg-white', re: /(?<![\w-])bg-white(?![\w-])/ },
|
||||
{ rule: 'no-heavy-shadow', re: /(?<![\w-])shadow-(?:xl|2xl)(?![\w-])/ },
|
||||
{
|
||||
@@ -22,14 +17,9 @@ const RULES = [
|
||||
|
||||
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() })
|
||||
if (re.test(text)) out.push({ file, line: i + 1, rule, text: text.trim() })
|
||||
}
|
||||
})
|
||||
return out
|
||||
|
||||
@@ -28,7 +28,7 @@ describe('Sidebar (Modernist shell)', () => {
|
||||
it('is flat: a 2px divider rule, ground fill and no rounded corners except the avatar', () => {
|
||||
const { container } = render(<Sidebar role="hse" userName="Ada" userEmail="" />)
|
||||
const aside = container.querySelector('aside')
|
||||
expect(aside?.className).toContain('border-r-2')
|
||||
expect(aside?.className).toContain('border-r')
|
||||
expect(aside?.className).toContain('bg-ground')
|
||||
const rounded = container.innerHTML.match(/rounded[\w-]*/g) ?? []
|
||||
expect(rounded.every(r => r === 'rounded-full')).toBe(true)
|
||||
|
||||
@@ -35,7 +35,7 @@ describe('Modal (Modernist dialog)', () => {
|
||||
)
|
||||
const html = screen.getByRole('dialog').innerHTML
|
||||
expect(html).not.toMatch(/rounded/)
|
||||
expect(html).toContain('border-b-2')
|
||||
expect(html).toContain('border-b')
|
||||
})
|
||||
|
||||
it('closes from the X button and on Escape', () => {
|
||||
|
||||
+66
-43
@@ -4,59 +4,82 @@ import path from 'path'
|
||||
|
||||
const css = readFileSync(path.resolve(__dirname, '../../app/globals.css'), 'utf8')
|
||||
|
||||
describe('Modernist tokens in globals.css', () => {
|
||||
describe('IMS Admin tokens in globals.css', () => {
|
||||
it.each([
|
||||
['--color-bg', '#f3f2f2'],
|
||||
['--color-surface', '#eae9e9'],
|
||||
['--color-text', '#201e1d'],
|
||||
['--color-accent', '#ec3013'],
|
||||
['--color-accent-700', '#ae1800'],
|
||||
['--color-neutral-900', '#2d2b2b'],
|
||||
['--color-ink', '#1f1f1f'],
|
||||
['--color-ink-2', '#303030'],
|
||||
['--color-ink-3', '#4a4a4a'],
|
||||
['--color-muted', '#616161'],
|
||||
['--color-faint', '#8a8a8a'],
|
||||
['--color-rule', '#ebebeb'],
|
||||
['--color-rule-2', '#e3e3e3'],
|
||||
['--color-ring', '#d4d4d4'],
|
||||
['--color-surface', '#ffffff'],
|
||||
['--color-surface-2', '#f7f7f7'],
|
||||
['--color-ground', '#f1f1f1'],
|
||||
['--color-accent', '#0f766e'],
|
||||
['--color-accent-tint', '#f2f7f6'],
|
||||
['--color-accent-tint-2', '#e6f4f1'],
|
||||
['--color-danger', '#b3261e'],
|
||||
['--color-topbar', '#1a1a1a'],
|
||||
])('declares %s as %s', (name, value) => {
|
||||
expect(css).toMatch(new RegExp(`${name}:\\s*${value}`, 'i'))
|
||||
expect(css).toMatch(new RegExp(`${name}:\\s*${value}\\b`, 'i'))
|
||||
})
|
||||
|
||||
it.each(['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl'])('zeroes --radius-%s', size => {
|
||||
expect(css).toMatch(new RegExp(`--radius-${size}:\\s*0px`))
|
||||
it.each([
|
||||
['amber', '#fff1c2', '#6b4a00'],
|
||||
['blue', '#e0efff', '#00527c'],
|
||||
['violet', '#ede7ff', '#4b2e99'],
|
||||
['orange', '#ffe6cf', '#7a3a00'],
|
||||
['indigo', '#e3e8ff', '#2c3e8f'],
|
||||
['green', '#d7f4e3', '#0c5132'],
|
||||
['grey', '#ebebeb', '#4a4a4a'],
|
||||
['red', '#fee3e0', '#8e1f0b'],
|
||||
])('declares the %s status pair', (hue, bg, fg) => {
|
||||
expect(css).toMatch(new RegExp(`--color-st-${hue}-bg:\\s*${bg}`, 'i'))
|
||||
expect(css).toMatch(new RegExp(`--color-st-${hue}-fg:\\s*${fg}`, 'i'))
|
||||
})
|
||||
|
||||
it('zeroes the bare --radius used by the plain rounded class', () => {
|
||||
expect(css).toMatch(/--radius:\s*0px/)
|
||||
it('sets the radius scale: md 8, xl 12', () => {
|
||||
expect(css).toMatch(/--radius-md:\s*8px/)
|
||||
expect(css).toMatch(/--radius-xl:\s*12px/)
|
||||
})
|
||||
|
||||
it('declares the card and floating shadows', () => {
|
||||
expect(css).toMatch(/--shadow-card:\s*0 0 0 1px rgba\(0, ?0, ?0, ?\.08\), 0 1px 2px rgba\(0, ?0, ?0, ?\.06\)/)
|
||||
expect(css).toMatch(/--shadow-float:\s*0 0 0 1px rgba\(0, ?0, ?0, ?\.1\), 0 12px 32px rgba\(0, ?0, ?0, ?\.18\)/)
|
||||
})
|
||||
|
||||
it('declares the component shadows', () => {
|
||||
for (const name of ['drawer', 'primary', 'secondary', 'input', 'chip', 'chip-set']) {
|
||||
expect(css).toMatch(new RegExp(`--shadow-${name}:`))
|
||||
}
|
||||
})
|
||||
|
||||
it('uses Geist through the next/font variables', () => {
|
||||
expect(css).toMatch(/--font-sans:\s*var\(--font-geist\)/)
|
||||
expect(css).toMatch(/--font-mono:\s*var\(--font-geist-mono\)/)
|
||||
})
|
||||
|
||||
it('keeps the legacy remaps so unmigrated pages still render', () => {
|
||||
expect(css).toMatch(/--color-gray-100:\s*var\(--color-neutral-200\)/)
|
||||
expect(css).toMatch(/--color-blue-600:\s*var\(--color-accent\)/)
|
||||
expect(css).toMatch(/--color-red-600:\s*var\(--color-danger\)/)
|
||||
expect(css).toMatch(/--color-divider:/)
|
||||
})
|
||||
|
||||
it('styles keyboard focus with the 2px accent ring', () => {
|
||||
expect(css).toMatch(/:focus-visible\s*\{[^}]*outline:\s*2px solid var\(--color-accent\)/)
|
||||
})
|
||||
|
||||
it('has no dark mode block and no Modernist leftovers', () => {
|
||||
expect(css).not.toContain('prefers-color-scheme')
|
||||
expect(css).not.toMatch(/ec3013/i)
|
||||
expect(css).not.toMatch(/archivo/i)
|
||||
})
|
||||
|
||||
it('has no stray comment terminator before @theme', () => {
|
||||
const head = css.slice(0, css.indexOf('@theme'))
|
||||
expect(head.match(/\*\//g)?.length).toBe(head.match(/\/\*/g)?.length)
|
||||
})
|
||||
|
||||
it('remaps the gray ramp onto the neutral ramp', () => {
|
||||
expect(css).toMatch(/--color-gray-100:\s*var\(--color-neutral-200\)/)
|
||||
expect(css).toMatch(/--color-gray-900:\s*var\(--color-text\)/)
|
||||
})
|
||||
|
||||
it('remaps the blue ramp onto the accent ramp', () => {
|
||||
expect(css).toMatch(/--color-blue-600:\s*var\(--color-accent\)/)
|
||||
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\)/)
|
||||
})
|
||||
|
||||
it('uses Archivo through the next/font variable', () => {
|
||||
expect(css).toMatch(/--font-sans:\s*var\(--font-archivo\)/)
|
||||
})
|
||||
|
||||
it('has no dark mode block', () => {
|
||||
expect(css).not.toContain('prefers-color-scheme')
|
||||
})
|
||||
|
||||
it('styles keyboard focus with the 2px accent ring', () => {
|
||||
expect(css).toMatch(/:focus-visible\s*\{[^}]*outline:\s*2px solid var\(--color-accent\)/)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { findViolations, ROUND_ALLOWED } from '../../scripts/check-design-gates.mjs'
|
||||
import { findViolations } 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')
|
||||
describe('design gates (IMS Admin refresh)', () => {
|
||||
it('allows the radius scale, including rounded-full', () => {
|
||||
expect(rules('<div className="rounded-md rounded-xl rounded-[5px] rounded-full" />')).toEqual([])
|
||||
})
|
||||
|
||||
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.each(['border-2', 'border-b-2', 'border-t-2', 'border-l-2', 'border-r-2'])('flags %s', cls => {
|
||||
expect(rules(`<div className="${cls}" />`)).toContain('no-2px-border')
|
||||
})
|
||||
|
||||
it('accepts 1px rules', () => {
|
||||
expect(rules('<div className="border border-b border-rule" />')).toEqual([])
|
||||
})
|
||||
|
||||
it('flags the retired Archivo font', () => {
|
||||
expect(rules("import { Archivo } from 'next/font/google'")).toContain('no-archivo')
|
||||
})
|
||||
|
||||
it('flags off-palette colors but accepts remapped gray, blue and red', () => {
|
||||
@@ -21,7 +27,11 @@ describe('design gates', () => {
|
||||
expect(rules('<p className="text-gray-500 text-blue-700 bg-red-50" />')).toEqual([])
|
||||
})
|
||||
|
||||
it('flags hard-coded hex colors', () => {
|
||||
it('accepts the status token classes', () => {
|
||||
expect(rules('<span className="bg-st-green-bg text-st-green-fg" />')).toEqual([])
|
||||
})
|
||||
|
||||
it('flags hard-coded hex colors, including the retired Modernist red', () => {
|
||||
expect(rules('<div style={{ color: "#ec3013" }} />')).toContain('no-hex')
|
||||
expect(rules('<p>'quoted'</p>')).not.toContain('no-hex')
|
||||
})
|
||||
@@ -35,11 +45,11 @@ describe('design gates', () => {
|
||||
})
|
||||
|
||||
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' })
|
||||
const v = findViolations('a\n<div className="border-2" />', 'components/y.tsx')
|
||||
expect(v[0]).toMatchObject({ file: 'components/y.tsx', line: 2, rule: 'no-2px-border' })
|
||||
})
|
||||
|
||||
it('accepts clean on-system markup', () => {
|
||||
expect(rules('<div className="bg-surface border border-divider p-4 text-ink shadow-sm" />')).toEqual([])
|
||||
expect(rules('<div className="bg-surface border border-rule p-4 text-ink shadow-card rounded-xl" />')).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user