[catalog][m]: re-implemented search page using TailwindUI.
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
import { Item } from 'portal';
|
||||
|
||||
const SearchItem: React.FC<{ datapackage: any }> = ({ datapackage }) => {
|
||||
return <Item dataset={datapackage} />;
|
||||
};
|
||||
|
||||
export default SearchItem;
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useQuery } from '@apollo/react-hooks';
|
||||
import Item from './Item';
|
||||
import Link from 'next/link';
|
||||
import * as timeago from 'timeago.js';
|
||||
import { ErrorMessage } from '../_shared';
|
||||
import { SEARCH_QUERY } from '../../graphql/queries';
|
||||
|
||||
@@ -16,9 +17,53 @@ const List: React.FC<{ variables: any }> = ({ variables }) => {
|
||||
if (loading) return <div>Loading</div>;
|
||||
const { result } = data.search;
|
||||
return (
|
||||
<ul>
|
||||
{result.results.map((pkg, index) => (
|
||||
<Item datapackage={pkg} key={index} />
|
||||
<ul className="divide-y divide-gray-200">
|
||||
{result.results.map((dataset, index) => (
|
||||
<li
|
||||
key={index}
|
||||
className="relative bg-white py-5 px-4 hover:bg-gray-50 focus-within:ring-2 focus-within:ring-inset focus-within:ring-indigo-600"
|
||||
>
|
||||
<div className="flex justify-between space-x-3">
|
||||
<div className="min-w-0 flex-1">
|
||||
<Link
|
||||
href={`/@${
|
||||
dataset.organization ? dataset.organization.name : 'dataset'
|
||||
}/${dataset.name}`}
|
||||
>
|
||||
{/*
|
||||
Linting fails because href is required for anchor tags and it
|
||||
ignores NextJS's Link API. Please, see this issue for details:
|
||||
https://github.com/vercel/next.js/issues/5533
|
||||
*/}
|
||||
{/* eslint-disable-next-line */}
|
||||
<a className="block focus:outline-none">
|
||||
<span className="absolute inset-0" aria-hidden="true" />
|
||||
<p className="text-sm font-medium text-gray-900">
|
||||
{dataset.title}
|
||||
</p>
|
||||
<p className="text-sm text-gray-500 truncate">
|
||||
{dataset.organization
|
||||
? dataset.organization.title
|
||||
: 'dataset'}{' '}
|
||||
/ {dataset.name}
|
||||
</p>
|
||||
</a>
|
||||
</Link>
|
||||
</div>
|
||||
<time
|
||||
dateTime={dataset.metadata_modified}
|
||||
className="flex-shrink-0 whitespace-nowrap text-sm text-gray-500"
|
||||
>
|
||||
Updated {timeago.format(dataset.metadata_modified)}
|
||||
</time>
|
||||
</div>
|
||||
<div className="mt-1">
|
||||
<p className="line-clamp-2 text-sm text-gray-600">
|
||||
{dataset.description ||
|
||||
"This dataset doesn't have a description."}
|
||||
</p>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user