-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
preview 2.0 UI changes #34440
preview 2.0 UI changes #34440
Changes from 7 commits
67482bf
31737ea
0fc7509
de6be17
09050a8
96b9116
636dc98
52a141b
ad93c03
a03144f
dab41d4
728a861
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import React, { useState } from "react" | ||
import { IndicatorButtonTooltip } from "../tooltips" | ||
import { spinnerIcon } from "../icons" | ||
import { spinnerIcon, exitIcon } from "../icons" | ||
import { props } from "bluebird" | ||
|
||
export default function IndicatorButton({ | ||
buttonIndex, | ||
|
@@ -13,13 +14,12 @@ export default function IndicatorButton({ | |
testId, | ||
onMouseEnter, | ||
hoverable, | ||
exitButton, | ||
}) { | ||
const [showTooltip, setShowTooltip] = useState(false) | ||
const isFirstButton = buttonIndex === 0 | ||
const marginTop = isFirstButton ? `0px` : `8px` | ||
|
||
const onMouseLeave = () => setShowTooltip(false) | ||
|
||
return ( | ||
<> | ||
<button | ||
|
@@ -32,15 +32,27 @@ export default function IndicatorButton({ | |
> | ||
<div | ||
data-testid={`${testId}-button`} | ||
onClick={ | ||
hoverable | ||
? onClick | ||
: () => { | ||
setShowTooltip(!showTooltip) | ||
} | ||
Comment on lines
+39
to
+41
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. Just a nit but not a huge fan of inlining functions like this with a ternary op, I think it makes it harder to read even if they're straightforward |
||
} | ||
onMouseEnter={() => { | ||
setShowTooltip(true) | ||
if (hoverable) { | ||
setShowTooltip(true) | ||
|
||
if (onMouseEnter) { | ||
onMouseEnter() | ||
if (onMouseEnter) { | ||
onMouseEnter() | ||
} | ||
} | ||
}} | ||
onMouseLeave={() => { | ||
if (hoverable) { | ||
setShowTooltip(false) | ||
} | ||
}} | ||
onMouseLeave={onMouseLeave} | ||
onClick={active ? onClick : null} | ||
> | ||
{iconSvg} | ||
{showSpinner && ( | ||
|
@@ -51,6 +63,18 @@ export default function IndicatorButton({ | |
{tooltipContent && ( | ||
<IndicatorButtonTooltip | ||
tooltipContent={tooltipContent} | ||
iconExit={ | ||
exitButton && ( | ||
<button | ||
onClick={() => { | ||
setShowTooltip(false) | ||
}} | ||
data-gatsby-preview-indicator="tooltip-link" | ||
> | ||
{exitIcon} | ||
</button> | ||
) | ||
} | ||
overrideShowTooltip={overrideShowTooltip} | ||
showTooltip={showTooltip} | ||
buttonIndex={buttonIndex} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,24 @@ import { formatDistance } from "date-fns" | |
import trackEvent from "../../utils/trackEvent" | ||
|
||
import IndicatorButton from "./IndicatorButton" | ||
import { infoIcon } from "../icons" | ||
import { infoIcon, infoIconActive } from "../icons" | ||
import { | ||
BuildErrorTooltipContent, | ||
BuildSuccessTooltipContent, | ||
} from "../tooltips" | ||
|
||
const getButtonProps = props => { | ||
const { createdAt, buildStatus } = props | ||
const { | ||
createdAt, | ||
buildStatus, | ||
erroredBuildId, | ||
isOnPrettyUrl, | ||
sitePrefix, | ||
siteId, | ||
buildId, | ||
orgId, | ||
} = props | ||
|
||
switch (buildStatus) { | ||
case `UPTODATE`: { | ||
return { | ||
|
@@ -16,13 +30,48 @@ const getButtonProps = props => { | |
{ includeSeconds: true } | ||
)} ago`, | ||
active: true, | ||
exitButton: false, | ||
hoverable: true, | ||
} | ||
} | ||
case `SUCCESS`: { | ||
return { | ||
tooltipContent: ( | ||
<BuildSuccessTooltipContent | ||
isOnPrettyUrl={isOnPrettyUrl} | ||
sitePrefix={sitePrefix} | ||
buildId={buildId} | ||
siteId={siteId} | ||
orgId={orgId} | ||
/> | ||
), | ||
active: true, | ||
showInfo: true, | ||
smthomas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
exitButton: true, | ||
hoverable: false, | ||
} | ||
} | ||
case `ERROR`: { | ||
return { | ||
tooltipContent: ( | ||
<BuildErrorTooltipContent | ||
siteId={siteId} | ||
orgId={orgId} | ||
buildId={erroredBuildId} | ||
/> | ||
), | ||
active: true, | ||
showInfo: true, | ||
exitButton: true, | ||
hoverable: false, | ||
} | ||
} | ||
case `SUCCESS`: | ||
case `ERROR`: | ||
case `BUILDING`: | ||
default: { | ||
return {} | ||
return { | ||
active: true, | ||
hoverable: false, | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -39,14 +88,12 @@ export default function InfoIndicatorButton(props) { | |
name: `info hover`, | ||
}) | ||
} | ||
|
||
return ( | ||
<IndicatorButton | ||
testId="info" | ||
iconSvg={infoIcon} | ||
onMouseEnter={buttonProps?.active && trackHover} | ||
iconSvg={buttonProps?.showInfo ? infoIconActive : infoIcon} | ||
onClick={buttonProps?.active && trackHover} | ||
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. Does this make sense? We're tracking the hover when the button is being clicked now? |
||
buttonIndex={props.buttonIndex} | ||
hoverable={true} | ||
{...buttonProps} | ||
/> | ||
) | ||
|
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.
What's this for? we don't use it anywhere