From 0ed37002ed9c95efaa9f5f2fb553d97f43bff2b8 Mon Sep 17 00:00:00 2001 From: Martin Wagner Date: Fri, 14 May 2021 20:52:08 +0200 Subject: [PATCH] Worked on #37 Mani and I figured out how to align the Label and the button of the productGrid. --- .../src/components/cards/MiniCardComponent.js | 17 ++--- .../components/productGrid/LabelComponent.js | 18 +++++ .../productGrid/ModelDropdownComponent.js | 4 +- .../productGrid/ProductGridComponent.js | 69 ++++++++++++------- 4 files changed, 73 insertions(+), 35 deletions(-) create mode 100644 frontend/src/components/productGrid/LabelComponent.js diff --git a/frontend/src/components/cards/MiniCardComponent.js b/frontend/src/components/cards/MiniCardComponent.js index d7a5b64e..5d55ade9 100644 --- a/frontend/src/components/cards/MiniCardComponent.js +++ b/frontend/src/components/cards/MiniCardComponent.js @@ -1,5 +1,5 @@ import React from 'react'; -import { Column } from 'simple-flexbox'; +import { Column, Row } from 'simple-flexbox'; import { createUseStyles, useTheme } from 'react-jss'; //reconfiguration of the dropdown boxes @@ -10,7 +10,7 @@ const useStyles = createUseStyles((theme) => ({ border: `3px solid ${theme.color.lightGrayishBlue2}`, borderRadius: 4, cursor: 'pointer', - maxWidth: 200, + maxWidth: 300, maxHeight:150, marginTop:50, padding: '8px 16px 8px 16px', @@ -46,14 +46,11 @@ function MiniCardComponent({ className = '', title, value, path }) { const composedClassName = [classes.container, className].join(' '); return ( - {/* Resize the image on the cards (product images) */} -
- {/* define the image path */} - -
- {title} - {value} - + {/* Resize the image on the cards (product images) */} +
+ {/* define the image path */} + +
); } diff --git a/frontend/src/components/productGrid/LabelComponent.js b/frontend/src/components/productGrid/LabelComponent.js new file mode 100644 index 00000000..1486fd5d --- /dev/null +++ b/frontend/src/components/productGrid/LabelComponent.js @@ -0,0 +1,18 @@ +import React, {useContext} from 'react'; + +/** + * Displaying a label. + * + * @author Mani + * @author Martin Wagner + */ + +function LabelComponent({productName}) { + return ( + + {productName} + + ); +} + +export default LabelComponent; diff --git a/frontend/src/components/productGrid/ModelDropdownComponent.js b/frontend/src/components/productGrid/ModelDropdownComponent.js index 02be21b3..09c26346 100644 --- a/frontend/src/components/productGrid/ModelDropdownComponent.js +++ b/frontend/src/components/productGrid/ModelDropdownComponent.js @@ -13,7 +13,7 @@ import {Container, Row, Col } from 'react-grid-system'; * This component creates the dropdownboxes for the related products * * @returns the model properties of the related product depending on the model values from getModels func from interface/simaProInterface - * @author parham, Martin Wagner, Irem Toroslu + * @author parham, Martin Wagner, Irem Toroslu, Mani Anand */ const ModelDropdownComponent = (props) => { @@ -30,7 +30,7 @@ const ModelDropdownComponent = (props) => { - +
diff --git a/frontend/src/components/productGrid/ProductGridComponent.js b/frontend/src/components/productGrid/ProductGridComponent.js index bb0b2e14..3821c534 100644 --- a/frontend/src/components/productGrid/ProductGridComponent.js +++ b/frontend/src/components/productGrid/ProductGridComponent.js @@ -5,11 +5,11 @@ * /** * * @returns the product and model properties - * @author Irem Toroslu + * @author Irem Toroslu, Martin Wagner, Mani Anand */ import React, {useContext} from 'react'; -//import {Column, Row} from 'simple-flexbox'; +import {Column, Row} from 'simple-flexbox'; import {createUseStyles} from 'react-jss'; import MiniCardComponent from 'components/cards/MiniCardComponent'; import {getProducts} from 'interface/simaProInterface' @@ -17,58 +17,81 @@ import ProductDropdown from './ModelDropdownComponent' import SLUGS from 'resources/slugs'; import {Link} from 'react-router-dom'; import {PrivateSectionContext} from 'hooks/PrivateSectionContext'; -import {Container, Row, Col } from 'react-grid-system'; +import { Component } from 'react'; +import LabelComponent from './LabelComponent' +const myStyles = createUseStyles((theme) => ({ + title: { + ...theme.typography.cardTitle, + color: theme.color.grayishBlue2, + marginBottom: 12, + minWidth: 205, + textAlign: 'center' + }, + value: { + color: theme.color.veryDarkGrayishBlue, + fontWeight: 'bold', + fontSize: 20, + letterSpacing: '1px', + lineHeight: '50px', + textAlign: 'center' + } +})); -function ProductGridComponent() { - const [ selectedProducts, setSelectedProducts ] = useContext(PrivateSectionContext); - const NewSelectedProducts = - [{ +function ProductGridComponent() { + const [selectedProducts, setSelectedProducts] = useContext(PrivateSectionContext); + const NewSelectedProducts = [ + { productID: selectedProducts.productID, productName: selectedProducts.productName, modelID: selectedProducts.modelID, modelName: selectedProducts.modelName - }] - + } + ]; const products = getProducts(); const classes = useStyles(); return ( - - + - {products.map((product, index) => - + {products.map((product, index) => ( + { // Save selection to ContextProvider NewSelectedProducts[0].productID = product.productID; NewSelectedProducts[0].productName = product.productName; }} - to={{ // Link to the next page - pathname: SLUGS.details, - }}> + to={{ + // Link to the next page + pathname: SLUGS.details + }} + > - - - )} + + + + ))} - - + ); } @@ -115,4 +138,4 @@ const useStyles = createUseStyles({ } }); -export default ProductGridComponent; +export default ProductGridComponent; \ No newline at end of file