@tscircuit/fake-snippets 0.0.94 → 0.0.96

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.
@@ -0,0 +1,130 @@
1
+ import React, { useState } from "react"
2
+ import { useQuery } from "react-query"
3
+ import { useAxios } from "@/hooks/use-axios"
4
+ import Header from "@/components/Header"
5
+ import Footer from "@/components/Footer"
6
+ import { Input } from "@/components/ui/input"
7
+ import { Search } from "lucide-react"
8
+ import { Link } from "wouter"
9
+
10
+ interface DatasheetSummary {
11
+ datasheet_id: string
12
+ chip_name: string
13
+ }
14
+
15
+ export const DatasheetsPage: React.FC = () => {
16
+ const axios = useAxios()
17
+ const [searchQuery, setSearchQuery] = useState("")
18
+
19
+ const {
20
+ data: datasheets,
21
+ isLoading,
22
+ error,
23
+ } = useQuery(
24
+ ["datasheetList", searchQuery],
25
+ async () => {
26
+ const params = new URLSearchParams()
27
+ if (searchQuery) {
28
+ params.append("chip_name", searchQuery)
29
+ } else {
30
+ params.append("is_popular", "true")
31
+ }
32
+ const { data } = await axios.get(`/datasheets/list?${params.toString()}`)
33
+ return data.datasheets as DatasheetSummary[]
34
+ },
35
+ { keepPreviousData: true },
36
+ )
37
+
38
+ return (
39
+ <div className="min-h-screen flex flex-col">
40
+ <Header />
41
+ <main className="flex-grow container mx-auto px-4 py-8">
42
+ <div className="mb-8 max-w-3xl">
43
+ <div className="flex items-center gap-2 mb-3">
44
+ <h1 className="text-4xl font-bold text-gray-900">Datasheets</h1>
45
+ </div>
46
+ <p className="text-lg text-gray-600 mb-4">
47
+ Explore datasheets for popular electronic components and chips.
48
+ Search to find specific ones.
49
+ </p>
50
+ </div>
51
+
52
+ <div className="mb-6">
53
+ <div className="flex flex-col sm:flex-row gap-4 mb-4">
54
+ <div className="relative flex-grow">
55
+ <Search className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 h-4 w-4" />
56
+ <Input
57
+ type="search"
58
+ placeholder="Search datasheets..."
59
+ className="pl-10"
60
+ value={searchQuery}
61
+ onChange={(e) => setSearchQuery(e.target.value)}
62
+ aria-label="Search datasheets"
63
+ role="searchbox"
64
+ />
65
+ </div>
66
+ </div>
67
+ </div>
68
+
69
+ {isLoading ? (
70
+ <div className="text-center py-12 px-4">
71
+ <div className="bg-slate-50 inline-flex rounded-full p-4 mb-4">
72
+ <Search className="w-8 h-8 text-slate-400" />
73
+ </div>
74
+ <h3 className="text-xl font-medium text-slate-900 mb-2">
75
+ Loading Datasheets
76
+ </h3>
77
+ <p className="text-slate-500 max-w-md mx-auto mb-6">
78
+ Please wait while we fetch the datasheets...
79
+ </p>
80
+ </div>
81
+ ) : error ? (
82
+ <div className="bg-red-50 border border-red-200 text-red-700 p-6 rounded-xl shadow-sm max-w-2xl mx-auto">
83
+ <div className="flex items-start">
84
+ <div className="mr-4 bg-red-100 p-2 rounded-full">
85
+ <Search className="w-6 h-6 text-red-600" />
86
+ </div>
87
+ <div>
88
+ <h3 className="text-lg font-semibold mb-2">
89
+ Error Loading Datasheets
90
+ </h3>
91
+ <p className="text-red-600">
92
+ We couldn't load the datasheets. Please try again later.
93
+ </p>
94
+ </div>
95
+ </div>
96
+ </div>
97
+ ) : datasheets && datasheets.length > 0 ? (
98
+ <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
99
+ {datasheets.map((ds) => (
100
+ <Link
101
+ key={ds.datasheet_id}
102
+ href={`/datasheets/${ds.chip_name}`}
103
+ className="block p-4 bg-white rounded-lg shadow hover:shadow-md transition-shadow"
104
+ >
105
+ <h3 className="font-semibold text-gray-900">{ds.chip_name}</h3>
106
+ </Link>
107
+ ))}
108
+ </div>
109
+ ) : (
110
+ <div className="text-center py-12 px-4">
111
+ <div className="bg-slate-50 inline-flex rounded-full p-4 mb-4">
112
+ <Search className="w-8 h-8 text-slate-400" />
113
+ </div>
114
+ <h3 className="text-xl font-medium text-slate-900 mb-2">
115
+ No Matching Datasheets
116
+ </h3>
117
+ <p className="text-slate-500 max-w-md mx-auto mb-6">
118
+ {searchQuery
119
+ ? `No datasheets match your search for "${searchQuery}".`
120
+ : "There are no popular datasheets at the moment."}
121
+ </p>
122
+ </div>
123
+ )}
124
+ </main>
125
+ <Footer />
126
+ </div>
127
+ )
128
+ }
129
+
130
+ export default DatasheetsPage