From 44cdced1a6e407a159f49bc423a96bdca7484c7a Mon Sep 17 00:00:00 2001 From: Rising Odegua Date: Mon, 3 May 2021 15:19:33 +0100 Subject: [PATCH] [Components][s]: Add components for creating search page --- src/components/search/Form.js | 62 ++++++++++++++++++++++++++++++++++ src/components/search/Item.js | 55 ++++++++++++++++++++++++++++++ src/components/search/Total.js | 25 ++++++++++++++ 3 files changed, 142 insertions(+) create mode 100644 src/components/search/Form.js create mode 100644 src/components/search/Item.js create mode 100644 src/components/search/Total.js diff --git a/src/components/search/Form.js b/src/components/search/Form.js new file mode 100644 index 00000000..61b4aeda --- /dev/null +++ b/src/components/search/Form.js @@ -0,0 +1,62 @@ +import React from 'react' +import PropTypes from 'prop-types'; + +/** + * Search component form that can be customized with change and submit handlers + * @param {object} props + * { + * handleChange: A form input change event handler. This function is executed when the + * search input or order by input changes. + * handleSubmit: A form submit event handler. This function is executed when the + * search form is submitted. + * } + * @returns + */ +const Form = ({ handleChange, handleSubmit }) => { + + return ( +
+
+ + +
+
+ + +
+
+ ); +}; + +Form.propTypes = { + handleChange: PropTypes.func.isRequired, + handleSubmit: PropTypes.func.isRequired +} + +export default Form; diff --git a/src/components/search/Item.js b/src/components/search/Item.js new file mode 100644 index 00000000..1d47183b --- /dev/null +++ b/src/components/search/Item.js @@ -0,0 +1,55 @@ +import React from 'react' +import Link from 'next/link'; +import PropTypes from 'prop-types'; + +/** + * Single item from a search result showing info about a dataset. + * @param {object} props data package with the following format: + * { + * organization: {name: , title: }, + * title: + * name: + * description: + * notes: + * } + * @returns React Component + */ +const Item = ({ dataset }) => { + return ( + + ); +}; + +Item.propTypes = { + dataset: PropTypes.object.isRequired +} + +export default Item; diff --git a/src/components/search/Total.js b/src/components/search/Total.js new file mode 100644 index 00000000..6bf83e17 --- /dev/null +++ b/src/components/search/Total.js @@ -0,0 +1,25 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +/** + * Displays the total search result + * @param {object} props + * { + * count: The total number of search results + * } + * @returns React Component + */ +const Total = ({ count }) => { + + return ( +

+ {count} results found +

+ ); +}; + +Total.propTypes = { + count: PropTypes.number.isRequired +} + +export default Total;