From 36a838d5653c339dad456e997f2d51a86ea158a2 Mon Sep 17 00:00:00 2001 From: willyb321 Date: Tue, 12 Jun 2018 09:09:05 +1000 Subject: [PATCH] add material shopping list --- src/app/components/ModalShoppingList.jsx | 57 ++++++++++++++++++++++++ src/app/i18n/en.json | 1 + src/app/pages/OutfittingPage.jsx | 37 ++++++++++++++- 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 src/app/components/ModalShoppingList.jsx diff --git a/src/app/components/ModalShoppingList.jsx b/src/app/components/ModalShoppingList.jsx new file mode 100644 index 00000000..7c53732a --- /dev/null +++ b/src/app/components/ModalShoppingList.jsx @@ -0,0 +1,57 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import TranslatedComponent from './TranslatedComponent'; +import ShortenUrl from '../utils/ShortenUrl'; + +/** + * Permalink modal + */ +export default class ModalShoppingList extends TranslatedComponent { + + static propTypes = { + mats: PropTypes.object.isRequired + }; + + /** + * Constructor + * @param {Object} props React Component properties + */ + constructor(props) { + super(props); + + this.state = { + mats: props.mats, + matsList: '' + }; + } + + /** + * Convert mats object to string + */ + renderMats() { + let matsString = ''; + for (const i in this.state.mats) { + if (!this.state.mats.hasOwnProperty(i)) { + continue; + } + matsString += `${i}: ${this.state.mats[i]}\n`; + } + this.setState({ matsList: matsString }); + } + + /** + * Render the modal + * @return {React.Component} Modal Content + */ + render() { + let translate = this.context.language.translate; + this.renderMats(); + return
e.stopPropagation() }> +

{translate('PHRASE_SHOPPING_MATS')}

+
+