Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

2.1 KB
Raw Blame
import { Link } from 'react-router';
import { Info } from 'lucide-react';

/**
 * Workflow-teaching empty state.
 *
 * A "no data" state should not just say "Nothing here" — it should name the
 * next action that unlocks the feature, e.g. "Configure one API provider to
 * enable autonomous CoS" or "Connect calendar to unlock schedule-aware goals".
 *
 * Props:
 *   icon        — Lucide component for the centered glyph (default: Info)
 *   title       — optional bold heading (the "what's missing")
 *   headingLevel — heading level for the title, 2–6 (default 2); pass 3 when
 *                  the empty state sits under an existing h2 section
 *   message     — the teaching hint that names the next action
 *   actionTo    — internal route for the call-to-action Link
 *   actionLabel — text for the call-to-action
 *   onAction    — render a <button> instead of a Link (in-page action)
 *   actionDisabled — disable the in-page action while it is processing
 */
export default function EmptyState({
  icon: Icon = Info,
  title,
  headingLevel = 2,
  message,
  actionTo,
  actionLabel,
  onAction,
  actionDisabled = false,
}) {
  const actionClass =
    'mt-4 px-4 py-2 rounded-lg text-sm font-medium bg-port-accent/10 text-port-accent hover:bg-port-accent/20 transition-colors';

  const Heading = `h${Math.min(6, Math.max(2, headingLevel))}`;

  return (
    <div className="flex flex-col items-center justify-center py-16 text-center">
      {Icon && <Icon size={32} className="text-gray-600 mb-3" />}
      {title && <Heading className="text-white font-semibold mb-1">{title}</Heading>}
      {message && <p className="text-gray-400 text-sm max-w-xs">{message}</p>}
      {actionLabel && (onAction ? (
        <button
          type="button"
          onClick={onAction}
          disabled={actionDisabled}
          aria-busy={actionDisabled || undefined}
          className={`${actionClass} disabled:cursor-not-allowed disabled:opacity-50`}
        >
          {actionLabel}
        </button>
      ) : actionTo ? (
        <Link to={actionTo} className={actionClass}>
          {actionLabel}
        </Link>
      ) : null)}
    </div>
  );
}