Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

1.3 KB
Raw Blame
import { RefreshCw } from 'lucide-react';
import { PULL_THRESHOLD, type PullState } from '../usePullToRefresh';

/**
 * The round glass badge under the top bar that a pull-to-refresh reveals: it
 * fades in and turns with the pull, and spins while the page reloads.
 */
export default function MPullIndicator({ state, label }: { state: PullState; label: string }) {
  const progress = Math.min(1, state.distance / PULL_THRESHOLD);
  const visible = state.refreshing || state.distance > 4;
  return (
    <div
      aria-hidden={!state.refreshing}
      role={state.refreshing ? 'status' : undefined}
      aria-label={state.refreshing ? label : undefined}
      className="m-span-x pointer-events-none fixed z-30 flex justify-center transition-opacity duration-200"
      style={{ top: 'calc(var(--m-safe-top, 12px) + 70px)', opacity: visible ? Math.max(0.35, progress) : 0 }}
    >
      <span className="flex h-9 w-9 items-center justify-center rounded-full border border-[color:var(--m-gbr)] bg-[color:var(--m-glass)] text-m-ink shadow-sm backdrop-blur-xl">
        <RefreshCw
          size={16}
          strokeWidth={2.2}
          className={state.refreshing ? 'animate-spin' : undefined}
          style={state.refreshing ? undefined : { transform: `rotate(${progress * 270}deg)` }}
        />
      </span>
    </div>
  );
}