Skip to content

Commit

Permalink
Create slots on Timeline click
Browse files Browse the repository at this point in the history
Refactor candidate placeholder

Co-authored-by: Tomas Roun <tomas.roun@cern.ch>

Fix tooltips and hide placeholder when x button is hovered
  • Loading branch information
renefs committed Nov 18, 2024
1 parent aaf9c29 commit b546167
Show file tree
Hide file tree
Showing 5 changed files with 333 additions and 128 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from 'react';
import PropTypes from 'prop-types';
import {Popup} from 'semantic-ui-react';
/**
* Displays a placeholder for a candidate time slot when the Timeline is hovered.
*/
export default function CandidatePlaceholder({visible, left, width, time}) {
if (!visible) {
return null;
}

return (
<Popup
content={time}
open={true}
position="top center"
trigger={
<div
style={{
boxSizing: 'border-box',
position: 'absolute',
left: `${left}%`,
width: `${width}%`,
top: 5,
height: 'calc(100% - 10px)',
zIndex: 1000,
background: 'rgba(0, 0, 0, 0.2)',
borderRadius: '3px',
display: 'block',
pointerEvents: 'none',
}}
/>
}
/>
);
}

CandidatePlaceholder.propTypes = {
visible: PropTypes.bool.isRequired,
width: PropTypes.number.isRequired,
left: PropTypes.number.isRequired,
time: PropTypes.string.isRequired,
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function SlotEditWidget({startTime, onChange, isValidTime, slot}) {
<Popup
className={styles['timepicker-popup']}
on="click"
onClick={e => e.stopPropagation()}
content={
<>
<TimePicker
Expand Down Expand Up @@ -63,11 +64,14 @@ export default function CandidateSlot({
endTime,
onDelete,
onChangeSlotTime,
onMouseEnter,
onMouseLeave,
isValidTime,
text,
}) {
const slot = (
<Slot
onClick={e => e.stopPropagation()}
width={width}
pos={pos}
moreStyles={styles['candidate']}
Expand All @@ -82,6 +86,8 @@ export default function CandidateSlot({
name="times circle outline"
onClick={onDelete}
className={`${styles['clickable']} ${styles['delete-btn']}`}
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
/>
</Slot>
);
Expand All @@ -102,6 +108,8 @@ CandidateSlot.propTypes = {
endTime: PropTypes.string.isRequired,
onDelete: PropTypes.func.isRequired,
onChangeSlotTime: PropTypes.func.isRequired,
onMouseEnter: PropTypes.func.isRequired,
onMouseLeave: PropTypes.func.isRequired,
isValidTime: PropTypes.func.isRequired,
text: PropTypes.string,
};
Expand Down
Loading

0 comments on commit b546167

Please # to comment.