Skip to content

Commit 38b91f7

Browse files
refactor: move match score to bottom right
1 parent 3bfece8 commit 38b91f7

File tree

1 file changed

+49
-53
lines changed

1 file changed

+49
-53
lines changed

components/SearchResults.tsx

Lines changed: 49 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -162,62 +162,58 @@ function SearchResultCard({ result }: { result: SearchResult }) {
162162
const templateItem = isTemplate ? item as any : null
163163

164164
return (
165-
<div className="bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg p-6 hover:shadow-md transition-shadow">
166-
<div className="flex items-start justify-between">
167-
<div className="flex-1">
168-
<div className="flex items-center gap-2 mb-2">
169-
<span className="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200">
170-
{item.type}
171-
</span>
172-
<span className="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-200">
173-
{item.category}
174-
</span>
175-
{isTemplate && templateItem?.subtype && (
176-
<span className="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200">
177-
{templateItem.subtype}
178-
</span>
179-
)}
180-
</div>
181-
182-
<h3 className="text-lg font-semibold text-gray-900 dark:text-white mb-2">
183-
{item.name}
184-
</h3>
185-
186-
{item.description && (
187-
<p className="text-gray-600 dark:text-gray-400 mb-3 line-clamp-2">
188-
{item.description}
189-
</p>
190-
)}
191-
192-
{isTemplate && templateItem?.installCommand && (
193-
<div className="bg-gray-50 dark:bg-gray-800 rounded p-3 mb-3">
194-
<code className="text-sm text-gray-800 dark:text-gray-200">
195-
{templateItem.installCommand}
196-
</code>
197-
</div>
198-
)}
199-
200-
<div className="flex items-center text-sm text-gray-500 dark:text-gray-400">
201-
{'path' in item && <span>Path: {item.path}</span>}
202-
{isTemplate && templateItem?.files && (
203-
<span className={`${'path' in item ? 'ml-4' : ''}`}>
204-
{templateItem.files.length} file{templateItem.files.length !== 1 ? 's' : ''}
205-
</span>
206-
)}
207-
{isTemplate && templateItem?.id && !('path' in item) && (
208-
<span>ID: {templateItem.id}</span>
209-
)}
210-
</div>
165+
<div className="bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg p-6 hover:shadow-md transition-shadow relative">
166+
<div className="flex items-center gap-2 mb-2">
167+
<span className="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200">
168+
{item.type}
169+
</span>
170+
<span className="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-200">
171+
{item.category}
172+
</span>
173+
{isTemplate && templateItem?.subtype && (
174+
<span className="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200">
175+
{templateItem.subtype}
176+
</span>
177+
)}
178+
</div>
179+
180+
<h3 className="text-lg font-semibold text-gray-900 dark:text-white mb-2">
181+
{item.name}
182+
</h3>
183+
184+
{item.description && (
185+
<p className="text-gray-600 dark:text-gray-400 mb-3 line-clamp-2">
186+
{item.description}
187+
</p>
188+
)}
189+
190+
{isTemplate && templateItem?.installCommand && (
191+
<div className="bg-gray-50 dark:bg-gray-800 rounded p-3 mb-3">
192+
<code className="text-sm text-gray-800 dark:text-gray-200">
193+
{templateItem.installCommand}
194+
</code>
211195
</div>
212-
213-
{result.score && (
214-
<div className="ml-4 text-right">
215-
<div className="text-sm text-gray-500 dark:text-gray-400">
216-
Match: {((1 - result.score) * 100).toFixed(0)}%
217-
</div>
218-
</div>
196+
)}
197+
198+
<div className="flex items-center text-sm text-gray-500 dark:text-gray-400 mb-8">
199+
{'path' in item && <span>Path: {item.path}</span>}
200+
{isTemplate && templateItem?.files && (
201+
<span className={`${'path' in item ? 'ml-4' : ''}`}>
202+
{templateItem.files.length} file{templateItem.files.length !== 1 ? 's' : ''}
203+
</span>
204+
)}
205+
{isTemplate && templateItem?.id && !('path' in item) && (
206+
<span>ID: {templateItem.id}</span>
219207
)}
220208
</div>
209+
210+
{result.score && (
211+
<div className="absolute bottom-4 right-4">
212+
<div className="text-sm text-gray-500 dark:text-gray-400">
213+
Match: {((1 - result.score) * 100).toFixed(0)}%
214+
</div>
215+
</div>
216+
)}
221217
</div>
222218
)
223219
}

0 commit comments

Comments
 (0)