{
+ setShowTooltip(!showTooltip)
+ }
+ }
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 && (
@@ -53,6 +64,18 @@ export default function IndicatorButton({
{tooltipContent && (
{
+ setShowTooltip(false)
+ }}
+ data-gatsby-preview-indicator="tooltip-link"
+ >
+ {exitIcon}
+
+ )
+ }
overrideShowTooltip={overrideShowTooltip}
showTooltip={showTooltip}
elementRef={buttonRef}
diff --git a/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/InfoIndicatorButton.js b/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/InfoIndicatorButton.js
index 4113c0d37ad66..55f7bf11e4e27 100644
--- a/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/InfoIndicatorButton.js
+++ b/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/InfoIndicatorButton.js
@@ -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,55 @@ const getButtonProps = props => {
{ includeSeconds: true }
)} ago`,
active: true,
+ showInfo: false,
+ hoverable: true,
+ }
+ }
+ case `SUCCESS`: {
+ return {
+ tooltipContent: (
+
+ ),
+ active: true,
+ showInfo: true,
+ hoverable: false,
+ }
+ }
+ case `ERROR`: {
+ return {
+ tooltipContent: (
+
+ ),
+ active: true,
+ showInfo: true,
+ hoverable: false,
+ }
+ }
+ case `BUILDING`: {
+ return {
+ tooltipContent: `Building a new preview`,
+ showSpinner: true,
+ overrideShowTooltip: true,
+ showInfo: false,
+ hoverable: true,
}
}
- case `SUCCESS`:
- case `ERROR`:
- case `BUILDING`:
default: {
- return {}
+ return {
+ active: true,
+ showInfo: false,
+ hoverable: false,
+ }
}
}
}
@@ -30,6 +86,15 @@ const getButtonProps = props => {
export default function InfoIndicatorButton(props) {
const { orgId, siteId, buildId } = props
const buttonProps = getButtonProps(props)
+ const trackClick = () => {
+ trackEvent({
+ eventType: `PREVIEW_INDICATOR_CLICK`,
+ orgId,
+ siteId,
+ buildId,
+ name: `info click`,
+ })
+ }
const trackHover = () => {
trackEvent({
eventType: `PREVIEW_INDICATOR_HOVER`,
@@ -39,14 +104,13 @@ export default function InfoIndicatorButton(props) {
name: `info hover`,
})
}
-
return (
)
diff --git a/packages/gatsby-plugin-gatsby-cloud/src/components/icons.js b/packages/gatsby-plugin-gatsby-cloud/src/components/icons.js
index be2f23b40fe31..fdc68332dbff1 100644
--- a/packages/gatsby-plugin-gatsby-cloud/src/components/icons.js
+++ b/packages/gatsby-plugin-gatsby-cloud/src/components/icons.js
@@ -89,6 +89,96 @@ export const successIcon = (
)
+export const exitIcon = (
+
+)
+
+export const infoIconActive = (
+
+)
+
+export const notificationIcon = (
+
+)
+
export const spinnerIcon = (
)
}