diff --git a/package-lock.json b/package-lock.json index cb8c10f..51cf6ef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@code4ro/taskforce-fe-components", - "version": "1.0.0", + "version": "1.0.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/components/filtered-list/filtered-list-item/filtered-list-item.js b/src/components/filtered-list/filtered-list-item/filtered-list-item.js new file mode 100644 index 0000000..ee30e86 --- /dev/null +++ b/src/components/filtered-list/filtered-list-item/filtered-list-item.js @@ -0,0 +1,30 @@ +import React from "react"; +import PropTypes from "prop-types"; +import "./filtered-list-item.styles.scss"; +import CaretSvg from "../../../images/icons/caret.svg"; + +export const FilteredListItem = ({ listItem }) => ( +
+ {listItem.label &&
{listItem.label}
} +
+
+ {listItem.rows.map((row, index) => ( +
+ {row.value} +
+ ))} +
+
listItem.clickHandler(listItem.data)} + style={{ background: listItem.styles.iconSectionColor }} + > + +
+
+
+); + +FilteredListItem.propTypes = { + listItem: PropTypes.object +}; diff --git a/src/components/filtered-list/filtered-list-item/filtered-list-item.styles.scss b/src/components/filtered-list/filtered-list-item/filtered-list-item.styles.scss new file mode 100644 index 0000000..e84f9f3 --- /dev/null +++ b/src/components/filtered-list/filtered-list-item/filtered-list-item.styles.scss @@ -0,0 +1,35 @@ + +.__filtered-list-item-container { + .label { + margin-bottom: 4px; + margin-left: 4px; + } +} + +.__filtered-list-item { + background-color: white; + box-shadow: 0 4px 4px rgba(0, 0, 0, 0.25); + display: flex; + + + + .content-section { + padding: 10px; + flex: 1; + } + + .row { + margin-bottom: 4px; + } + + .icon-section { + width: 50px; + display: flex; + justify-content: center; + align-items: center; + + &:hover { + cursor: pointer; + } + } +} diff --git a/src/components/filtered-list/filtered-list.js b/src/components/filtered-list/filtered-list.js new file mode 100644 index 0000000..a1baa4e --- /dev/null +++ b/src/components/filtered-list/filtered-list.js @@ -0,0 +1,63 @@ +import React from "react"; +import PropTypes from "prop-types"; +import "./filtered-list.styles.scss"; +import { FilteredListItem } from "./filtered-list-item/filtered-list-item"; + +export class FilteredList extends React.Component { + constructor(props) { + super(props); + if (this.props.config.filter) { + this.state = { filterValue: props.config.filter.options[0].value }; + } + } + + handleChange = event => { + this.props.config.filter.onSelect(event.target.value); + this.setState({ filterValue: event.target.value }); + }; + + render() { + const { config } = this.props; + return ( +
+
+ {config.filter && ( +
+ +
+
+ +
+
+
+ )} + {this.props.children} +
+
+ {config.listItems && + config.listItems.map((li, index) => ( + + ))} +
+
+ ); + } +} + +FilteredList.defaultProps = { + config: {} +}; + +FilteredList.propTypes = { + config: PropTypes.object, + children: PropTypes.element +}; diff --git a/src/components/filtered-list/filtered-list.stories.js b/src/components/filtered-list/filtered-list.stories.js new file mode 100644 index 0000000..f3348b8 --- /dev/null +++ b/src/components/filtered-list/filtered-list.stories.js @@ -0,0 +1,67 @@ +import React from "react"; +import "./../../styles.scss"; +import { FilteredList } from "./filtered-list"; + +export default { title: "FilteredList" }; + +const config = { + filter: { + onSelect: value => console.log("Selected: ", value), + label: "View for:", + placeholder: "Select a person", + options: [ + { + label: "John Doe", + value: "John Doe" + }, + { + label: "Bob", + value: "Bob" + } + ] + }, + listItems: [ + { + data: { somedata: "123" }, + clickHandler: data => console.log(data), + styles: { + iconSectionColor: "blue" + }, + label: "28.03.2020", + rows: [ + { + value: "Rezultat formular - esti in siguratna daca ramai acasa" + }, + { + value: "Simptome - nu prezinti simptome specifice COVID-19" + } + ] + }, + { + data: { somedata: "234" }, + clickHandler: data => console.log(data), + styles: { + iconSectionColor: "red" + }, + label: "28.03.2020", + rows: [ + { + value: "Rezultat formular - esti in siguratna daca ramai acasa" + }, + { + value: "Simptome - nu prezinti simptome specifice COVID-19" + } + ] + } + ] +}; + +export const example = () => ( +
+ + + +
+); diff --git a/src/components/filtered-list/filtered-list.styles.scss b/src/components/filtered-list/filtered-list.styles.scss new file mode 100644 index 0000000..bba95a0 --- /dev/null +++ b/src/components/filtered-list/filtered-list.styles.scss @@ -0,0 +1,18 @@ +.__filtered-list { + border: 1px solid black; + padding: 15px 25px 15px 15px; + display: flex; + flex-direction: column; + + .__filtered-list-item { + margin-bottom: 20px; + } + + .filter-section { + margin-bottom: 20px; + display: flex; + justify-content: space-between; + align-items: flex-end; + flex: 1; + } +} diff --git a/src/images/icons/caret.svg b/src/images/icons/caret.svg new file mode 100644 index 0000000..def5ddc --- /dev/null +++ b/src/images/icons/caret.svg @@ -0,0 +1,3 @@ + + +