[Components][s]: Update UI components to include validation
This commit is contained in:
59
src/components/ui/Nav.js
Normal file
59
src/components/ui/Nav.js
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import Link from 'next/link';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays a navigation bar with logo and menu links
|
||||||
|
* @param {Object} props object with the following properties:
|
||||||
|
* {
|
||||||
|
* logo: The relative url to the logo image
|
||||||
|
* navMenu: An array of objects with menu items. E.g : [{ title: 'Blog', path: '/blog' },{ title: 'Search', path: '/search' }]
|
||||||
|
* }
|
||||||
|
* @returns React Component
|
||||||
|
*/
|
||||||
|
const Nav = ({ logo, navMenu }) => {
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const handleClick = (event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
setOpen(!open);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<nav className="flex items-center justify-between flex-wrap bg-white p-4 border-b border-gray-200">
|
||||||
|
<div className="flex items-center flex-shrink-0 text-gray-700 mr-6">
|
||||||
|
<img src={logo} alt="portal logo" width="40" />
|
||||||
|
</div>
|
||||||
|
<div className="block lg:hidden mx-4">
|
||||||
|
<button
|
||||||
|
onClick={handleClick}
|
||||||
|
className="flex items-center px-3 py-2 border rounded text-gray-700 border-orange-400 hover:text-black hover:border-black"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
className="fill-current h-3 w-3"
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<title>Menu</title>
|
||||||
|
<path d="M0 3h20v2H0V3zm0 6h20v2H0V9zm0 6h20v2H0v-2z" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div className={`${open ? `block` : `hidden`} lg:block`}>
|
||||||
|
{navMenu.map((menu, index) => {
|
||||||
|
return (<Link href={menu.path} key={index}>
|
||||||
|
<a className="block mt-4 lg:inline-block lg:mt-0 active:bg-primary-background text-gray-700 hover:text-black mr-6">
|
||||||
|
{menu.title}
|
||||||
|
</a>
|
||||||
|
</Link>)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
Nav.propTypes = {
|
||||||
|
logo: PropTypes.string.isRequired,
|
||||||
|
navMenu: PropTypes.string
|
||||||
|
}
|
||||||
|
export default Nav;
|
||||||
51
src/components/ui/Recent.js
Normal file
51
src/components/ui/Recent.js
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import Link from 'next/link';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays a list of recent datasets
|
||||||
|
* @param {object} props
|
||||||
|
* datasets = {
|
||||||
|
* organization: {name: <some name>, title: <some title> },
|
||||||
|
* title: <Data package title>
|
||||||
|
* name: <Data package name>
|
||||||
|
* description: <description of data package>
|
||||||
|
* notes: <Notes associated with the data package>
|
||||||
|
* }
|
||||||
|
* @returns React Component
|
||||||
|
*/
|
||||||
|
const Recent = ({datasets}) => {
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section className="my-10 mx-4 lg:my-20">
|
||||||
|
<h1 className="text-2xl font-thin mb-4">Recent Datasets</h1>
|
||||||
|
<div className="recent flex flex-col lg:flex-row">
|
||||||
|
{datasets.map((dataset, index) => (
|
||||||
|
<div
|
||||||
|
key={index}
|
||||||
|
className="border px-4 mb-4 mr-3 border-gray-100 w-5/6 shadow-sm"
|
||||||
|
>
|
||||||
|
<h1 className="text-2xl font-thin">{dataset.title}</h1>
|
||||||
|
<p className="text-gray-500">
|
||||||
|
{dataset.organization && dataset.organization.description}
|
||||||
|
</p>
|
||||||
|
<Link
|
||||||
|
href={`/@${dataset.organization ? dataset.organization.name : 'dataset'
|
||||||
|
}/${dataset.name}`}
|
||||||
|
>
|
||||||
|
<a className="pt-3 flex justify-end text-orange-500">
|
||||||
|
View Dataset
|
||||||
|
</a>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
Recent.propTypes = {
|
||||||
|
datasets: PropTypes.object.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Recent;
|
||||||
Reference in New Issue
Block a user