aboutsummaryrefslogtreecommitdiff
path: root/react-frontend/src/components/Hub.js
diff options
context:
space:
mode:
author9308233900 <reagan_hunt@brown.edu>2021-04-20 10:24:34 -0700
committer9308233900 <reagan_hunt@brown.edu>2021-04-20 10:24:34 -0700
commit2e3243bb52b23571df529697d841f883846a8954 (patch)
tree315eda2621ddc65d96472e2fc29548356d25425b /react-frontend/src/components/Hub.js
parent564295d2ac6b40e349a1cbc3e3bd329989e9ec82 (diff)
parent4411ae1564d716e5aa063e4c47302ffc907a078a (diff)
Merge branch 'master' of https://github.com/cs0320-2021/term-project-cohwille-jmccaul3-mfoiani-rhunt2master
Diffstat (limited to 'react-frontend/src/components/Hub.js')
-rw-r--r--react-frontend/src/components/Hub.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/react-frontend/src/components/Hub.js b/react-frontend/src/components/Hub.js
index 8a3ac1c..1906684 100644
--- a/react-frontend/src/components/Hub.js
+++ b/react-frontend/src/components/Hub.js
@@ -10,12 +10,25 @@ import '../css/UserCheckin.css';
* @returns {import('react').HtmlHTMLAttributes} A list element holding a checkin's info.
*/
function Hub(props) {
- // State - toggled
+ const LEN_NAME = 15;
+
+ const [isHover, setIsHover] = useState(false);
+
+ const formatName = name => {
+ if (name.length >= LEN_NAME) {
+ return props.name.substring(0, LEN_NAME - 3) + '...';
+ }
+ return props.name;
+ }
return (
<li className='Checkin'>
<div className="Img-flex">
- <span className="Clickable-name" onClick= {() => console.log(props.id)}>{props.name}</span>
+ <span
+ className="Clickable-name"
+ onMouseOver = {() => setIsHover(true)}
+ onMouseLeave = {() => setIsHover(false)}
+ onClick = {() => props.setSelectedId(props.id)}>{isHover || props.searching ? props.name : formatName(props.name)}</span>
<span>{props.value.toFixed(3)}</span>
</div>
</li>);