astro-tractstack 2.0.0-rc.43 → 2.0.0-rc.44

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-tractstack",
3
- "version": "2.0.0-rc.43",
3
+ "version": "2.0.0-rc.44",
4
4
  "description": "Astro integration for TractStack - redeeming the web from boring experiences",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -78,7 +78,7 @@ export default function SearchModal({
78
78
  >
79
79
  <Portal>
80
80
  <Dialog.Backdrop className="fixed inset-0 z-50 bg-black bg-opacity-50 backdrop-blur-sm" />
81
- <Dialog.Positioner className="fixed inset-0 z-50 mx-auto max-w-3xl p-2 pt-16 md:p-4">
81
+ <Dialog.Positioner className="fixed inset-0 z-50 mx-auto max-w-5xl p-2 pt-16 md:p-4">
82
82
  <Dialog.Content
83
83
  className="bg-mywhite mx-auto w-full overflow-hidden rounded-lg shadow-2xl"
84
84
  style={{ height: '80vh' }}
@@ -1,9 +1,12 @@
1
1
  import { useState, useMemo } from 'react';
2
2
  import { Pagination } from '@ark-ui/react/pagination';
3
- import { ChevronLeftIcon, ChevronRightIcon } from '@heroicons/react/24/outline';
4
3
  import type { SearchResults as SearchResultsType } from '@/hooks/useSearch';
5
4
  import type { FullContentMapItem } from '@/types/tractstack';
6
- import { getResourceUrl, getResourceImage } from '@/utils/customHelpers';
5
+ import {
6
+ getResourceUrl,
7
+ getResourceImage,
8
+ getResourceDescription,
9
+ } from '@/utils/customHelpers';
7
10
 
8
11
  interface SearchResultsProps {
9
12
  results: SearchResultsType;
@@ -84,12 +87,18 @@ export default function SearchResults({
84
87
  item.slug,
85
88
  item.categorySlug || ''
86
89
  );
90
+ const description = getResourceDescription(
91
+ item.id,
92
+ item.slug,
93
+ item.categorySlug || ''
94
+ );
87
95
 
88
96
  items.push({
89
97
  id: item.id,
90
98
  type: 'Resource',
91
99
  title: item.title,
92
100
  slug: item.slug,
101
+ description: description || undefined,
93
102
  categorySlug: item.categorySlug || undefined,
94
103
  url: resourceUrl,
95
104
  imageSrc: resourceImage,
@@ -114,8 +123,8 @@ export default function SearchResults({
114
123
  startIndex + ITEMS_PER_PAGE
115
124
  );
116
125
 
117
- const handlePageChange = (page: number) => {
118
- setCurrentPage(page);
126
+ const handlePageChange = (details: { page: number }) => {
127
+ setCurrentPage(details.page);
119
128
  };
120
129
 
121
130
  const getResultBadge = (type: string, categorySlug?: string) => {
@@ -170,14 +179,32 @@ export default function SearchResults({
170
179
  <a href={item.url} onClick={onResultClick} className="group block">
171
180
  <div className="flex items-start gap-4">
172
181
  <div
173
- className="bg-mydarkgrey hidden flex-shrink-0 overflow-hidden rounded-lg md:block"
174
- style={{ width: '120px', height: '67.5px' }}
182
+ className="bg-mydarkgrey flex-shrink-0 overflow-hidden rounded-lg p-1 md:hidden"
183
+ style={{
184
+ width: '100px',
185
+ height: '56px',
186
+ }}
187
+ data-mobile-size="100x56"
188
+ >
189
+ <img
190
+ src={item.imageSrc}
191
+ alt={item.title}
192
+ className="h-full w-full rounded object-contain"
193
+ />
194
+ </div>
195
+
196
+ <div
197
+ className="bg-mydarkgrey hidden flex-shrink-0 overflow-hidden rounded-lg p-1 md:block"
198
+ style={{
199
+ width: '240px',
200
+ height: '135px',
201
+ }}
202
+ data-desktop-size="240x135"
175
203
  >
176
204
  <img
177
205
  src={item.imageSrc}
178
206
  alt={item.title}
179
- className="h-full w-full object-contain"
180
- style={{ width: '100%', height: '100%' }}
207
+ className="h-full w-full rounded object-contain"
181
208
  />
182
209
  </div>
183
210
 
@@ -190,11 +217,13 @@ export default function SearchResults({
190
217
  </h3>
191
218
  </div>
192
219
 
193
- {item.type === 'StoryFragment' && item.description && (
194
- <p className="mb-2 line-clamp-2 text-sm text-gray-600">
195
- {item.description}
196
- </p>
197
- )}
220
+ {(item.type === 'StoryFragment' ||
221
+ item.type === 'Resource') &&
222
+ item.description && (
223
+ <p className="mb-2 line-clamp-2 text-sm text-gray-600">
224
+ {item.description}
225
+ </p>
226
+ )}
198
227
 
199
228
  {item.topics && item.topics.length > 0 && (
200
229
  <div className="mb-2 flex flex-wrap gap-1">
@@ -217,6 +246,11 @@ export default function SearchResults({
217
246
  <p className="truncate text-xs text-gray-500">
218
247
  {item.url}
219
248
  </p>
249
+
250
+ {/* Mobile badge row */}
251
+ <div className="mt-2 block md:hidden">
252
+ {getResultBadge(item.type, item.categorySlug)}
253
+ </div>
220
254
  </div>
221
255
 
222
256
  <div className="hidden flex-shrink-0 text-right md:block">
@@ -233,47 +267,42 @@ export default function SearchResults({
233
267
  </div>
234
268
 
235
269
  {totalPages > 1 && (
236
- <div className="flex items-center space-x-1">
270
+ <div className="mt-8 flex justify-center">
237
271
  <Pagination.Root
238
272
  count={allResultItems.length}
239
273
  pageSize={ITEMS_PER_PAGE}
240
274
  page={currentPage}
241
- onPageChange={(details) => handlePageChange(details.page)}
275
+ siblingCount={1}
276
+ onPageChange={handlePageChange}
277
+ className="flex flex-wrap items-center gap-2"
242
278
  >
243
- <Pagination.PrevTrigger className="text-mydarkgrey flex items-center rounded-md border border-gray-300 px-3 py-2 text-sm hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50">
244
- <ChevronLeftIcon className="mr-1 h-4 w-4" />
245
- Previous
246
- </Pagination.PrevTrigger>
247
-
248
279
  <Pagination.Context>
249
280
  {(pagination) =>
250
281
  pagination.pages.map((page, index) =>
251
282
  page.type === 'page' ? (
252
283
  <Pagination.Item
253
284
  key={index}
254
- value={page.value}
255
- type="page"
285
+ {...page}
256
286
  className={`cursor-pointer rounded-md px-3 py-2 text-sm ${
257
287
  page.value === currentPage
258
- ? 'bg-myblue text-white'
259
- : 'text-mydarkgrey hover:bg-gray-50'
288
+ ? 'bg-gray-900 text-white'
289
+ : 'border border-gray-300 bg-white text-gray-700 hover:bg-gray-50'
260
290
  }`}
261
291
  >
262
292
  {page.value}
263
293
  </Pagination.Item>
264
294
  ) : (
265
- <span key={index} className="px-2 text-gray-400">
266
- ...
267
- </span>
295
+ <Pagination.Ellipsis
296
+ key={index}
297
+ index={index}
298
+ className="px-3 py-2 text-sm text-gray-500"
299
+ >
300
+
301
+ </Pagination.Ellipsis>
268
302
  )
269
303
  )
270
304
  }
271
305
  </Pagination.Context>
272
-
273
- <Pagination.NextTrigger className="text-mydarkgrey flex items-center rounded-md border border-gray-300 px-3 py-2 text-sm hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50">
274
- Next
275
- <ChevronRightIcon className="ml-1 h-4 w-4" />
276
- </Pagination.NextTrigger>
277
306
  </Pagination.Root>
278
307
  </div>
279
308
  )}
@@ -22,6 +22,15 @@ export function getResourceImage(
22
22
  return '/static.jpg';
23
23
  }
24
24
 
25
+ export function getResourceDescription(
26
+ id: string,
27
+ slug: string,
28
+ category: string
29
+ ): string | null {
30
+ console.log(`please define getResourceDescription`, id, slug, category);
31
+ return null;
32
+ }
33
+
25
34
  // Initialize search data - override in custom implementation
26
35
  export function initSearch(): void {
27
36
  // Default implementation does nothing