-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Uptime] Expand synthetic journey step thumbnail on hover #89179
Changes from 2 commits
d6c5170
0b2341f
3e44990
0b4f4cd
872c75f
bd595f7
efbb775
519565e
c934044
b518415
2808ff3
1a14d65
d519c26
73cf9ad
349db31
0a52f97
44c5bb3
ad1ebbd
0dfd62d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,11 +9,13 @@ import { | |
EuiButtonIcon, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiLoadingSpinner, | ||
EuiImage, | ||
EuiPopover, | ||
EuiSpacer, | ||
EuiText, | ||
EuiLoadingSpinner, | ||
} from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import useIntersection from 'react-use/lib/useIntersection'; | ||
import moment from 'moment'; | ||
import styled from 'styled-components'; | ||
|
@@ -60,13 +62,21 @@ const StepDiv = styled.div` | |
} | ||
`; | ||
|
||
const POPOVER_IMG_HEIGHT = 360; | ||
const POPOVER_IMG_WIDTH = 640; | ||
|
||
interface Props { | ||
timestamp: string; | ||
ping: Ping; | ||
} | ||
|
||
const nextAriaLabel = i18n.translate('xpack.uptime.synthetics.nextButton.ariaLabel', { | ||
defaultMessage: 'Next', | ||
}); | ||
|
||
export const PingTimestamp = ({ timestamp, ping }: Props) => { | ||
const [stepNo, setStepNo] = useState(1); | ||
const [isImagePopoverOpen, setIsImagePopoverOpen] = useState(false); | ||
|
||
const [stepImages, setStepImages] = useState<string[]>([]); | ||
|
||
|
@@ -113,7 +123,7 @@ export const PingTimestamp = ({ timestamp, ping }: Props) => { | |
setStepNo(stepNo - 1); | ||
}} | ||
iconType="arrowLeft" | ||
aria-label="Next" | ||
aria-label={nextAriaLabel} | ||
/> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
|
@@ -127,7 +137,7 @@ export const PingTimestamp = ({ timestamp, ping }: Props) => { | |
setStepNo(stepNo + 1); | ||
}} | ||
iconType="arrowRight" | ||
aria-label="Next" | ||
aria-label={nextAriaLabel} | ||
/> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
|
@@ -140,17 +150,36 @@ export const PingTimestamp = ({ timestamp, ping }: Props) => { | |
); | ||
|
||
return ( | ||
<StepDiv ref={intersectionRef}> | ||
<StepDiv | ||
onMouseEnter={() => setIsImagePopoverOpen(true)} | ||
onMouseLeave={() => setIsImagePopoverOpen(false)} | ||
ref={intersectionRef} | ||
> | ||
{imgSrc ? ( | ||
<StepImage | ||
allowFullScreen={true} | ||
size="s" | ||
hasShadow | ||
caption={ImageCaption} | ||
alt={captionContent} | ||
url={imgSrc} | ||
data-test-subj="pingTimestampImage" | ||
/> | ||
<EuiPopover | ||
anchorPosition="rightCenter" | ||
button={ | ||
<StepImage | ||
allowFullScreen={true} | ||
alt={captionContent} | ||
caption={ImageCaption} | ||
data-test-subj="pingTimestampImage" | ||
hasShadow | ||
url={imgSrc} | ||
size="s" | ||
/> | ||
} | ||
closePopover={() => setIsImagePopoverOpen(false)} | ||
isOpen={isImagePopoverOpen} | ||
> | ||
<EuiImage | ||
alt={i18n.translate('xpack.uptime.synthetics.thumbnail.fullSize.alt', { | ||
defaultMessage: `A full-size screenshot for this journey step's thumbnail.`, | ||
})} | ||
url={imgSrc} | ||
style={{ height: POPOVER_IMG_HEIGHT, width: POPOVER_IMG_WIDTH, objectFit: 'contain' }} | ||
/> | ||
</EuiPopover> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems like this WDYT? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure I can refactor. This code was somewhat new to me as it was contributed in my absence, so I didn't want to do any significant restructuring. I'm happy to try to break it up a bit though! |
||
) : ( | ||
<EuiFlexGroup gutterSize="s" alignItems="center"> | ||
<EuiFlexItem> | ||
|
@@ -167,6 +196,7 @@ export const PingTimestamp = ({ timestamp, ping }: Props) => { | |
className="stepArrows" | ||
gutterSize="s" | ||
alignItems="center" | ||
onMouseEnter={() => setIsImagePopoverOpen(true)} | ||
style={{ position: 'absolute', bottom: 0, left: 30 }} | ||
> | ||
<EuiFlexItem grow={false}> | ||
|
@@ -178,7 +208,7 @@ export const PingTimestamp = ({ timestamp, ping }: Props) => { | |
setStepNo(stepNo - 1); | ||
}} | ||
iconType="arrowLeft" | ||
aria-label="Next" | ||
aria-label={nextAriaLabel} | ||
/> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
|
@@ -190,7 +220,7 @@ export const PingTimestamp = ({ timestamp, ping }: Props) => { | |
setStepNo(stepNo + 1); | ||
}} | ||
iconType="arrowRight" | ||
aria-label="Next" | ||
aria-label={nextAriaLabel} | ||
/> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,7 +98,7 @@ export const StepScreenshotDisplay: FC<StepScreenshotDisplayProps> = ({ | |
closePopover={() => setIsImagePopoverOpen(false)} | ||
isOpen={isImagePopoverOpen} | ||
> | ||
<img | ||
<EuiImage | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💯 |
||
alt={ | ||
stepName | ||
? i18n.translate('xpack.uptime.synthetics.screenshotDisplay.thumbnailAltText', { | ||
|
@@ -114,7 +114,7 @@ export const StepScreenshotDisplay: FC<StepScreenshotDisplayProps> = ({ | |
} | ||
) | ||
} | ||
src={imgSrc} | ||
url={imgSrc} | ||
style={{ width: POPOVER_IMG_WIDTH, height: POPOVER_IMG_HEIGHT, objectFit: 'contain' }} | ||
/> | ||
</EuiPopover> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This solution results in the popover displaying the larger image when the mouse enters the
figcaption
element that the image contains as well. I wasn't sure if this functionality would be an issue. I did explore a few avenues around this, but they weren't as simple as this. I also considered the notion that the caption should be semantically linked to theimg
itself as further justification.I've included a GIF in the description illustrating the caption hover triggering the display.