From fe1d1037594e9507e4c2ddc4dc4d2b721cf6c72e Mon Sep 17 00:00:00 2001 From: wrzesinski-hubert Date: Sun, 20 Sep 2020 20:23:46 +0200 Subject: [PATCH] split groups at schedule and other stuff --- src/components/SchedulerRow.tsx | 37 ++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/src/components/SchedulerRow.tsx b/src/components/SchedulerRow.tsx index b673b1f..fd4f5da 100644 --- a/src/components/SchedulerRow.tsx +++ b/src/components/SchedulerRow.tsx @@ -1,4 +1,4 @@ -import React, { MouseEvent } from 'react'; +import React, { MouseEvent, useEffect, useState } from 'react'; import { Group } from '../types'; import styled from 'styled-components/macro'; import Popover from '@material-ui/core/Popover'; @@ -12,6 +12,8 @@ const useStyles = makeStyles((theme: Theme) => }, paper: { padding: theme.spacing(1), + marginLeft: 5, + textAlign:"center" }, }), ); @@ -38,6 +40,10 @@ const Classes = styled.div` border-radius: 10px; padding-left: 5px; background-color: rgb(100, 181, 246); + width: ${({ cellWidth }) => (cellWidth * 2.5) / 3}px; + height: ${({ cellHeight }) => (cellHeight * 2 * 3) / 4}px; + margin-right:5px; + text-align:center; `; interface SchedulerRowProps { @@ -51,18 +57,25 @@ interface SchedulerRowProps { export const SchedulerRow = ({ groups, indexRow, cellTop, cellWidth, cellHeight }: SchedulerRowProps) => { const classes = useStyles(); const [anchorEl, setAnchorEl] = React.useState(null); - + const [popoverId, setPopoverId] = useState(null); + //looks weird const handlePopoverOpen = (event: MouseEvent) => { setAnchorEl(event.currentTarget); + setPopoverId(event.currentTarget.id) }; const handlePopoverClose = () => { setAnchorEl(null); + setPopoverId(null); }; const open = Boolean(anchorEl); + useEffect(()=>{ + console.log("1231312"+popoverId); + },[popoverId]) + return ( <> {[...Array(5)].map((_, eventIndex) => ( @@ -83,35 +96,35 @@ export const SchedulerRow = ({ groups, indexRow, cellTop, cellWidth, cellHeight cellTop={cellTop} cellWidth={cellWidth} cellHeight={cellHeight} - id={`eventRow${indexRow}eventCol${eventIndex}`} + id={`eventRow${indexRow}eventCol${eventIndex}${index}`} key={index} - aria-owns={open ? 'mouse-over-popover' : undefined} + aria-owns={open ? `mouse-over-popover` : undefined} aria-haspopup="true" - onMouseEnter={handlePopoverOpen} + onMouseEnter={(e) => handlePopoverOpen(e)} onMouseLeave={handlePopoverClose} > - {groups[index].name} + {groups[index].name}

{groups[index].room}

- I use Popover. +

{groups[index].name}

{groups[index].lecturer}

{groups[index].room}

),