staging-tester / ocean-landing-serve / scripts/ check-ui.sh

#!/usr/bin/env bash
# Fails when app code sets type with raw Tailwind utilities instead of the type-* scale in src/routes/layout.css.
# shadcn primitives (src/lib/components/ui) are vendored and exempt.
set -euo pipefail
cd "$(dirname "$0")/.."
pattern='(^|[^a-z-])(text-(xs|sm|base|lg|xl|[2-9]xl|\[[0-9.]+(px|rem|em)\])|font-(thin|extralight|light|normal|medium|semibold|bold|extrabold|black|\[[0-9]+\])|tracking-[^ "]+|leading-[^ "]+|\[font-stretch:[^]]*\])'
hits=$(grep -rnE "$pattern" src --include='*.svelte' --exclude-dir=ui || true)
if [[ -n "$hits" ]]; then
	echo "Raw type utilities found; use a type-* utility from src/routes/layout.css (see docs/ui-rules.md):"
	echo "$hits"
	exit 1
fi
# Motion budget applies everywhere, vendored components included: nothing over 200ms, no soft ease-in-out/linear curves.
motion='(^|[^a-z-])(duration-(2[0-9][1-9]|2[1-9][0-9]|[3-9][0-9]{2}|[0-9]{4,})|duration-\[[0-9.]+m?s\]|ease-(in-out|linear|in)([^a-z-]|$)|transition-all)'
slow=$(grep -rnE "$motion" src --include='*.svelte' || true)
if [[ -n "$slow" ]]; then
	echo "Motion outside the budget; use duration-150/200 with ease-snappy or ease-exit (see docs/ui-rules.md):"
	echo "$slow"
	exit 1
fi

# App screens stay in the ocean palette: semantic tokens, blue and sky shades, and destructive red. Other hues were tried and reverted (see docs/ui-rules.md, Color).
# The profile skyline (src/lib/components/profile) is the one full-color exception and is deliberately outside these paths.
app='src/routes/(app) src/lib/components/app src/lib/components/repo'
hue='(^|[^a-z-])(bg|text|border|stroke|fill|ring|outline|decoration|from|via|to|accent|caret|divide)-(slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|indigo|violet|purple|fuchsia|pink|rose|success|warning|agent-[0-9])(-[0-9]{2,3})?(/[0-9]+)?([^a-z0-9-]|$)|#[0-9a-fA-F]{6}([^0-9a-fA-F]|$)'
loud=$(grep -rnE "$hue" $app --include='*.svelte' --include='*.ts' || true)
if [[ -n "$loud" ]]; then
	echo "Color outside the ocean palette in app code; use the semantic tokens or blue/sky shades (see docs/ui-rules.md, Color):"
	echo "$loud"
	exit 1
fi
# A scroll pane without a positioned box lets sr-only children lay out against the document and scroll the whole shell.
loose=$(grep -rnE "overflow-y-auto" $app --include='*.svelte' | grep -v "relative" || true)
if [[ -n "$loose" ]]; then
	echo "Scroll pane without relative; add it so sr-only children stay inside (see CLAUDE.md, Gotchas):"
	echo "$loose"
	exit 1
fi

# One version of everything ships; comparison pages were removed in October 2026 (see CLAUDE.md).
if [[ -e src/routes/variants ]]; then
	echo "src/routes/variants exists; build one version and ship it, no variants (see CLAUDE.md):"
	exit 1
fi

echo "check:ui passed"