diff --git a/client/src/app.js b/client/src/app.js index 9b6da66..425f571 100644 --- a/client/src/app.js +++ b/client/src/app.js @@ -3,6 +3,7 @@ import axios from 'axios'; import Box from './box'; import api from './api'; import Modal from './modal'; +import Color from './color'; import './styles/app.css'; function App() { @@ -12,7 +13,7 @@ function App() { const [boxID, setBoxID] = useState(undefined); const [boxName, setBoxName] = useState(''); const [boxDescription, setBoxDescription] = useState(''); - const [boxColor, setBoxColor] = useState(0); + const [boxColor, setBoxColor] = useState('WHITE'); const [showModalBox, setShowModalBox] = useState(false); const [showModalItem, setShowModalItem] = useState(false); @@ -25,7 +26,7 @@ function App() { const [itemName, setItemName] = useState(''); const [itemDescription, setItemDescription] = useState(''); const [itemQuantity, setItemQuantity] = useState(1); - + const [filter, setFilter] = useState(''); const [filteredData, setFilteredData] = useState([]); @@ -118,7 +119,7 @@ function App() { } const handleColorBox = (event) => { - setBoxColor(parseInt(event.target.value)); + setBoxColor(event.target.value); } const handleSubmitBox = (event) => { @@ -193,7 +194,7 @@ function App() { setMoveItemBoxID(null); setMoveItemID(null); setIsMoving(false); - await moveItem(moveItemID,boxData._id); + await moveItem(moveItemID, boxData._id); } const boxHandler = { @@ -219,7 +220,7 @@ function App() { const response = await axios.post(`${api.baseApiUrl}/item/${itemID}/${boxIDTarget}`); setData(response.data); } - catch(error) { + catch (error) { console.log(error); } } @@ -353,19 +354,25 @@ function App() { setFilter(''); } - const colors = { - default: 0, - red: 1, - green: 2, - }; + //these colors are all wrong + const colors = [ + { + title: 'WHITE', + defaultStyle: { backgroundColor: 'white' }, + hoverStyle: { backgroundColor: '#EBEBEB' } + }, + { + title: 'BLUE', + defaultStyle: { backgroundColor: '#084B83' }, + hoverStyle: { backgroundColor: '#0B64AD' } + } + ]; + const colorSelector =
- - + {colors.map((color) => + + )}
; const boxForm = @@ -404,7 +411,7 @@ function App() {

{itemName}

{itemDescription}

- + return ( <> {} @@ -420,21 +427,21 @@ function App() { {}
- +
- + ); } diff --git a/client/src/color.js b/client/src/color.js new file mode 100644 index 0000000..b1f8e74 --- /dev/null +++ b/client/src/color.js @@ -0,0 +1,17 @@ +import React, { useState } from 'react'; + +const Color = ({ colorData, handler, boxColor }) => { + const [style, setStyle] = useState(colorData.defaultStyle); + + const handleHover = (isHover) => { + setStyle(isHover ? colorData.hoverStyle : colorData.defaultStyle); + } + + return ( + + ) +} + +export default Color; \ No newline at end of file diff --git a/client/src/styles/app.css b/client/src/styles/app.css index 6fd3ef2..bfe02c1 100644 --- a/client/src/styles/app.css +++ b/client/src/styles/app.css @@ -300,14 +300,17 @@ button.button:hover { .color-selector-container { - display: grid; + display: grid; + grid-auto-flow: column; + width: fit-content; } .color-selector-container > .color { border-radius: 50%; - background-color: red; + border: 2px solid black; width: 2em; height: 2em; } + .color-selector-container > .color.selected { border: 1px solid black; } diff --git a/server/server.js b/server/server.js index d1b07ed..1aeda10 100644 --- a/server/server.js +++ b/server/server.js @@ -33,7 +33,12 @@ var boxSchema = new mongoose.Schema({ description: String, item: [itemSchema], sort: Number, - color: Number, + color: { + type: String, + enum: ['WHITE', 'RED', 'GREEN'], + default: 0 + } + //these colors are wrong }); //compile schema into model