● Zion Boggan
repos/Docket/components/record-archive.tsx
zionboggan.com ↗
116 lines · tsx
History for this file →
1
import { clsx } from "@/lib/cx";
2
import { SourceLink } from "@/components/source-link";
3
 
4
 
5
export function ArchiveLink({
6
  url,
7
  label = "Archived copy - Docket",
8
  className,
9
}: {
10
  url: string;
11
  label?: string;
12
  className?: string;
13
}) {
14
  const safeHref = /^https?:\/\
15
  return (
16
    <a
17
      href={safeHref}
18
      target="_blank"
19
      rel="noopener noreferrer nofollow"
20
      className={clsx(
21
        "focus-ring label inline-flex min-h-[40px] max-w-full flex-wrap items-center gap-x-1 gap-y-0.5 rounded-[3px] border border-line px-2 py-1 underline underline-offset-4 transition-colors text-ash hover:text-paper hover:border-paper",
22
        className
23
      )}
24
      title="Docket's preserved copy on archive.usdocket.org"
25
    >
26
      <span aria-hidden="true">⎘</span>
27
      <span>{label}</span>
28
    </a>
29
  );
30
}
31
 
32
export function PreservationNote({ className }: { className?: string }) {
33
  return (
34
    <p
35
      className={clsx("font-prose", className)}
36
      style={{ fontSize: "0.8125rem", lineHeight: 1.5, color: "var(--dk-ash-2)" }}
37
    >
38
      Docket preserves a copy so the record survives if the government page
39
      changes or is taken down. The official source is always linked first.
40
    </p>
41
  );
42
}
43
 
44
 
45
export function BillPdfViewer({
46
  pdfUrl,
47
  archivePdfUrl,
48
  sourceUrl,
49
  billNumber,
50
}: {
51
  pdfUrl: string;
52
  archivePdfUrl: string;
53
  sourceUrl: string;
54
  billNumber: string;
55
}) {
56
  const hasArchive = !!archivePdfUrl;
57
  const hasPdf = !!pdfUrl;
58
  const embedSrc = archivePdfUrl || pdfUrl;
59
  const officialUrl = pdfUrl || sourceUrl;
60
 
61
  return (
62
    <section className="mt-12" aria-label="Bill text">
63
      <div style={{ marginBottom: "20px" }}>
64
        <p
65
          className="label"
66
          style={{ color: "var(--dk-signal)", marginBottom: "10px", fontSize: "12px", letterSpacing: "0.14em" }}
67
        >
68
          Bill text
69
        </p>
70
        <h2
71
          className="font-display text-paper"
72
          style={{ fontSize: "clamp(1.2rem, 3.5vw, 1.5rem)", fontWeight: 800, letterSpacing: "-0.02em", textTransform: "uppercase", lineHeight: 1.05 }}
73
        >
74
          Read the official text
75
        </h2>
76
      </div>
77
 
78
      {embedSrc ? (
79
        <div className="rounded-[6px] border border-line bg-surface" style={{ overflow: "hidden" }}>
80
          <div
81
            className="flex flex-wrap items-center justify-between gap-2 border-b border-line"
82
            style={{ padding: "12px 16px" }}
83
          >
84
            <p className="label" style={{ color: "var(--dk-ash)" }}>
85
              <span className="font-mono">{billNumber}</span> - official PDF
86
            </p>
87
            <p className="label" style={{ color: "var(--dk-ash-2)" }}>
88
              {hasArchive ? "Showing Docket's preserved copy" : "Showing govinfo.gov copy"}
89
            </p>
90
          </div>
91
          <iframe
92
            src={embedSrc}
93
            title={`${billNumber} bill text (PDF)`}
94
            style={{ width: "100%", height: "70vh", border: "0", display: "block", background: "var(--dk-ink)" }}
95
          />
96
        </div>
97
      ) : null}
98
 
99
      {}
100
      <div className="mt-4 flex flex-wrap items-center gap-3">
101
        <SourceLink url={officialUrl} label="Official source" />
102
        {hasArchive ? <ArchiveLink url={archivePdfUrl} /> : null}
103
      </div>
104
      {hasArchive ? <PreservationNote className="mt-3" /> : null}
105
      {!embedSrc ? (
106
        <p
107
          className="mt-3 font-prose italic"
108
          style={{ fontSize: "0.9375rem", color: "var(--dk-ash-2)" }}
109
        >
110
          No PDF of the bill text is on file yet. The official record is linked
111
          above.
112
        </p>
113
      ) : null}
114
    </section>
115
  );
116
}