@tscircuit/fake-snippets 0.0.98 → 0.0.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,21 @@ import Header from "@/components/Header"
5
5
  import Footer from "@/components/Footer"
6
6
  import ExpandableText from "@/components/ExpandableText"
7
7
  import type { Datasheet } from "fake-snippets-api/lib/db/schema"
8
+ import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card"
9
+ import { Button } from "@/components/ui/button"
10
+ import { Loader2, AlertCircle, FileText } from "lucide-react"
11
+
12
+ const SectionCard = ({
13
+ title,
14
+ children,
15
+ }: { title: string; children: React.ReactNode }) => (
16
+ <Card className="mb-6">
17
+ <CardHeader className="pb-2">
18
+ <CardTitle className="text-xl font-semibold">{title}</CardTitle>
19
+ </CardHeader>
20
+ <CardContent>{children}</CardContent>
21
+ </Card>
22
+ )
8
23
 
9
24
  export const DatasheetPage = () => {
10
25
  const { chipName } = useParams<{ chipName: string }>()
@@ -19,85 +34,160 @@ export const DatasheetPage = () => {
19
34
  return (
20
35
  <div className="min-h-screen flex flex-col">
21
36
  <Header />
22
- <main className="container mx-auto flex-1 px-4 py-8">
23
- <h1 className="text-3xl font-bold mb-6">{chipName} Datasheet</h1>
24
- <p className="mb-4">
37
+ <main className="flex-grow mx-auto px-4 md:px-20 lg:px-28 py-8 w-full">
38
+ <div className="mb-8">
39
+ <h1 className="text-3xl md:text-4xl font-bold text-gray-900 mb-2 break-words">
40
+ {chipName} Datasheet
41
+ </h1>
42
+ <p className="text-lg text-gray-600 mb-4">
43
+ View and download the datasheet for{" "}
44
+ <span className="font-semibold text-gray-800">{chipName}</span>. If
45
+ the datasheet is not available, you can request its creation.
46
+ </p>
25
47
  <a
26
48
  href={`https://api.tscircuit.com/datasheets/get?chip_name=${encodeURIComponent(chipName)}`}
27
- className="text-blue-600 underline"
49
+ className="inline-flex items-center gap-1 text-blue-600 hover:underline text-sm font-medium"
50
+ target="_blank"
51
+ rel="noopener noreferrer"
28
52
  >
29
- Download JSON
53
+ <FileText className="w-4 h-4" /> Download JSON
30
54
  </a>
31
- </p>
55
+ </div>
56
+
32
57
  {datasheetQuery.isLoading ? (
33
- <p>Loading...</p>
58
+ <div className="flex flex-col items-center justify-center py-16">
59
+ <Loader2 className="w-10 h-10 animate-spin text-blue-500 mb-4" />
60
+ <h3 className="text-xl font-semibold mb-2">Loading Datasheet...</h3>
61
+ <p className="text-gray-500 max-w-md text-center">
62
+ Please wait while we fetch the datasheet information for{" "}
63
+ <span className="font-semibold">{chipName}</span>.
64
+ </p>
65
+ </div>
34
66
  ) : datasheetQuery.data ? (
35
- <div>
36
- {!datasheetQuery.data.pin_information &&
37
- !datasheetQuery.data.datasheet_pdf_urls && (
38
- <p>Datasheet is processing. Please check back later.</p>
39
- )}
40
-
41
- <h2 className="text-xl font-semibold mb-2">PDFs</h2>
42
- {datasheetQuery.data.datasheet_pdf_urls ? (
43
- <ul className="list-disc pl-5 mb-6">
44
- {datasheetQuery.data.datasheet_pdf_urls.map((url) => (
45
- <li key={url}>
46
- <a href={url} className="text-blue-600 underline">
47
- {url}
48
- </a>
49
- </li>
50
- ))}
51
- </ul>
52
- ) : (
53
- <p>No datasheet PDFs available.</p>
67
+ <>
68
+ {!(
69
+ datasheetQuery.data.pin_information ||
70
+ datasheetQuery.data.datasheet_pdf_urls
71
+ ) && (
72
+ <SectionCard title="Processing">
73
+ <div className="flex items-center gap-3 text-yellow-700">
74
+ <Loader2 className="w-5 h-5 animate-spin" />
75
+ <span>Datasheet is processing. Please check back later.</span>
76
+ </div>
77
+ </SectionCard>
54
78
  )}
55
79
 
56
- <h2 className="text-xl font-semibold mb-2">Pin Information</h2>
57
- {datasheetQuery.data.pin_information ? (
58
- <table className="table-auto border-collapse mb-6">
59
- <thead>
60
- <tr>
61
- <th className="border px-2 py-1">Pin</th>
62
- <th className="border px-2 py-1">Name</th>
63
- <th className="border px-2 py-1">Description</th>
64
- <th className="border px-2 py-1">Capabilities</th>
65
- </tr>
66
- </thead>
67
- <tbody>
68
- {datasheetQuery.data.pin_information.map((pin) => (
69
- <tr key={pin.pin_number}>
70
- <td className="border px-2 py-1">{pin.pin_number}</td>
71
- <td className="border px-2 py-1">{pin.name}</td>
72
- <td className="border px-2 py-1">{pin.description}</td>
73
- <td className="border px-2 py-1">
74
- <ExpandableText
75
- text={pin.capabilities.join(", ")}
76
- maxChars={30}
77
- />
78
- </td>
79
- </tr>
80
+ <SectionCard title="Description">
81
+ {datasheetQuery.data.ai_description ? (
82
+ <div className="flex items-center gap-3 text-gray-500">
83
+ <span>{datasheetQuery.data.ai_description}</span>
84
+ </div>
85
+ ) : (
86
+ <p className="text-gray-500">No description available.</p>
87
+ )}
88
+ </SectionCard>
89
+
90
+ <SectionCard title="PDFs">
91
+ {datasheetQuery.data.datasheet_pdf_urls &&
92
+ datasheetQuery.data.datasheet_pdf_urls.length > 0 ? (
93
+ <ul className="list-disc pl-5 space-y-2">
94
+ {datasheetQuery.data.datasheet_pdf_urls.map((url) => (
95
+ <li key={url}>
96
+ <a
97
+ href={url}
98
+ className="text-blue-600 underline break-all"
99
+ target="_blank"
100
+ rel="noopener noreferrer"
101
+ >
102
+ {url}
103
+ </a>
104
+ </li>
80
105
  ))}
81
- </tbody>
82
- </table>
83
- ) : (
84
- <p>No pin information available.</p>
85
- )}
86
- </div>
106
+ </ul>
107
+ ) : (
108
+ <p className="text-gray-500">No datasheet PDFs available.</p>
109
+ )}
110
+ </SectionCard>
111
+
112
+ <SectionCard title="Pin Information">
113
+ {datasheetQuery.data.pin_information &&
114
+ datasheetQuery.data.pin_information.length > 0 ? (
115
+ <div className="overflow-x-auto">
116
+ <table className="min-w-full border-collapse text-sm">
117
+ <thead>
118
+ <tr>
119
+ <th className="border-b px-3 py-2 text-left font-semibold">
120
+ Pin
121
+ </th>
122
+ <th className="border-b px-3 py-2 text-left font-semibold">
123
+ Name
124
+ </th>
125
+ <th className="border-b px-3 py-2 text-left font-semibold">
126
+ Description
127
+ </th>
128
+ <th className="border-b px-3 py-2 text-left font-semibold">
129
+ Capabilities
130
+ </th>
131
+ </tr>
132
+ </thead>
133
+ <tbody>
134
+ {datasheetQuery.data.pin_information.map((pin) => (
135
+ <tr key={pin.pin_number} className="hover:bg-gray-50">
136
+ <td className="border-b px-3 py-2 font-mono">
137
+ {pin.pin_number}
138
+ </td>
139
+ <td className="border-b px-3 py-2">{pin.name}</td>
140
+ <td className="border-b px-3 py-2">
141
+ {pin.description}
142
+ </td>
143
+ <td className="border-b px-3 py-2">
144
+ <ExpandableText
145
+ text={pin.capabilities.join(", ")}
146
+ maxChars={30}
147
+ />
148
+ </td>
149
+ </tr>
150
+ ))}
151
+ </tbody>
152
+ </table>
153
+ </div>
154
+ ) : (
155
+ <p className="text-gray-500">No pin information available.</p>
156
+ )}
157
+ </SectionCard>
158
+ </>
87
159
  ) : datasheetQuery.error &&
88
160
  (datasheetQuery.error as any).status === 404 ? (
89
- <div>
90
- <p>No datasheet found.</p>
91
- <button
92
- className="mt-2 px-4 py-2 bg-blue-500 text-white rounded"
93
- onClick={handleCreate}
94
- disabled={createDatasheet.isLoading}
95
- >
96
- {createDatasheet.isLoading ? "Creating..." : "Create Datasheet"}
97
- </button>
98
- </div>
161
+ <SectionCard title="No Datasheet Found">
162
+ <div className="flex flex-col items-center gap-4">
163
+ <AlertCircle className="w-8 h-8 text-red-500" />
164
+ <p className="text-gray-700 text-center">
165
+ No datasheet found for{" "}
166
+ <span className="font-semibold">{chipName}</span>.<br />
167
+ You can request its creation below.
168
+ </p>
169
+ <Button
170
+ className="mt-2"
171
+ onClick={handleCreate}
172
+ disabled={createDatasheet.isLoading}
173
+ size="lg"
174
+ >
175
+ {createDatasheet.isLoading ? "Creating..." : "Create Datasheet"}
176
+ </Button>
177
+ </div>
178
+ </SectionCard>
99
179
  ) : (
100
- <p>Error loading datasheet.</p>
180
+ <div className="flex flex-col items-center justify-center py-16">
181
+ <AlertCircle className="w-10 h-10 text-red-500 mb-4" />
182
+ <h3 className="text-xl font-semibold mb-2">
183
+ Error loading datasheet
184
+ </h3>
185
+ <p className="text-gray-500 max-w-md text-center">
186
+ There was an error loading the datasheet for{" "}
187
+ <span className="font-semibold">{chipName}</span>. Please try
188
+ again later.
189
+ </p>
190
+ </div>
101
191
  )}
102
192
  </main>
103
193
  <Footer />
@@ -43,7 +43,7 @@ export const DatasheetsPage: React.FC = () => {
43
43
  return (
44
44
  <div className="min-h-screen flex flex-col">
45
45
  <Header />
46
- <main className="flex-grow container mx-auto px-4 py-8">
46
+ <main className="flex-grow container mx-auto px-4 py-8 min-h-[80vh]">
47
47
  <div className="mb-8 max-w-3xl">
48
48
  <div className="flex items-center gap-2 mb-3">
49
49
  <h1 className="text-4xl font-bold text-gray-900">Datasheets</h1>
@@ -126,7 +126,7 @@ export const DatasheetsPage: React.FC = () => {
126
126
  </p>
127
127
  {searchQuery && (
128
128
  <button
129
- className="mt-2 px-4 py-2 bg-blue-500 text-white rounded"
129
+ className="mt-2 px-4 py-2 bg-blue-600 text-white rounded"
130
130
  onClick={() =>
131
131
  createDatasheet.mutate({ chip_name: searchQuery })
132
132
  }
@@ -58,9 +58,9 @@ const LatestPage: React.FC = () => {
58
58
  ?.sort((a, b) => b.created_at.localeCompare(a.created_at))
59
59
 
60
60
  return (
61
- <div className="min-h-screen flex flex-col bg-gray-50">
61
+ <div className="min-h-screen flex flex-col">
62
62
  <Header />
63
- <main className="flex-grow container mx-auto px-4 py-8">
63
+ <main className="flex-grow container mx-auto px-4 py-8 min-h-[80vh]">
64
64
  <div className="mb-8 max-w-3xl">
65
65
  <div className="flex items-center gap-2 mb-3">
66
66
  <h1 className="text-4xl font-bold text-gray-900">
@@ -91,7 +91,7 @@ export const SearchPage = () => {
91
91
  return (
92
92
  <div className="min-h-screen flex flex-col">
93
93
  <Header />
94
- <main className="flex-grow bg-gray-50 pb-12">
94
+ <main className="flex-grow pb-12 min-h-[80vh]">
95
95
  <div className="container mx-auto px-4 py-8">
96
96
  <div className="max-w-8xl mx-auto">
97
97
  <div className="mb-6">
@@ -87,9 +87,9 @@ const TrendingPage: React.FC = () => {
87
87
  })
88
88
 
89
89
  return (
90
- <div className="min-h-screen flex flex-col bg-gray-50">
90
+ <div className="min-h-screen flex flex-col">
91
91
  <Header />
92
- <main className="flex-grow container mx-auto px-4 py-8">
92
+ <main className="flex-grow container mx-auto px-4 py-8 min-h-[80vh]">
93
93
  <div className="mb-8 max-w-3xl">
94
94
  <h1 className="text-4xl font-bold text-gray-900 mb-3">
95
95
  Trending Packages
package/vite.config.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import "dotenv/config"
1
2
  import { createDatabase } from "./fake-snippets-api/lib/db/db-client"
2
3
  import { defineConfig, Plugin, UserConfig } from "vite"
3
4
  import type { PluginOption } from "vite"