|
1 |
| -import { Button, ExternalLink } from "@fiftyone/components"; |
2 |
| -import React from "react"; |
| 1 | +import { Button, ExternalLink, useTheme } from "@fiftyone/components"; |
| 2 | +import AutoAwesomeIcon from "@mui/icons-material/AutoAwesome"; |
| 3 | +import { |
| 4 | + Box, |
| 5 | + Button as MuiButton, |
| 6 | + Popover, |
| 7 | + Stack, |
| 8 | + Typography, |
| 9 | + useColorScheme, |
| 10 | +} from "@mui/material"; |
| 11 | +import React, { useCallback, useEffect, useState } from "react"; |
| 12 | +import styled, { css, keyframes } from "styled-components"; |
| 13 | + |
| 14 | +const ENTERPRISE_TOOLTIP_LS = "fiftyone-enterprise-tooltip-seen"; |
| 15 | +const ENTERPRISE_BUTTON_ID = "fo-cta-enterprise-button"; |
| 16 | + |
| 17 | +const DARK_BG_COLOR = "#333333"; |
| 18 | +const LIGHT_BG_COLOR = "#FFFFFF"; |
| 19 | + |
| 20 | +const GRADIENT_START_COLOR = "#FF6D04"; |
| 21 | +const GRADIENT_END_COLOR = "#B681FF"; |
| 22 | + |
| 23 | +// subtle pulse animation for the sparkles icon |
| 24 | +const pulse = keyframes` |
| 25 | + 0% { |
| 26 | + transform: scale(1); |
| 27 | + opacity: 1; |
| 28 | + } |
| 29 | + 50% { |
| 30 | + transform: scale(1.1); |
| 31 | + opacity: 0.9; |
| 32 | + } |
| 33 | + 100% { |
| 34 | + transform: scale(1); |
| 35 | + opacity: 1; |
| 36 | + } |
| 37 | +`; |
| 38 | + |
| 39 | +// styles that will be applied to the icon container |
| 40 | +const pulseAnimation = css` |
| 41 | + animation: ${pulse} 1.5s ease-in-out infinite; |
| 42 | +`; |
| 43 | + |
| 44 | +const IconContainer = styled.div` |
| 45 | + display: flex; |
| 46 | + align-items: center; |
| 47 | + transition: all 0.3s ease; |
| 48 | +`; |
| 49 | + |
| 50 | +// https://stackoverflow.com/questions/65282139/adding-a-linear-gradient-to-material-ui-icon |
| 51 | +const GradientAutoAwesomeIcon = () => ( |
| 52 | + <> |
| 53 | + <svg width={0} height={0} aria-label="Gradient" aria-labelledby="gradient"> |
| 54 | + <title>Gradient</title> |
| 55 | + <defs> |
| 56 | + <linearGradient id="gradient1" x1="0%" y1="0%" x2="100%" y2="100%"> |
| 57 | + <stop |
| 58 | + offset="0%" |
| 59 | + style={{ stopColor: GRADIENT_START_COLOR, stopOpacity: 1 }} |
| 60 | + /> |
| 61 | + <stop |
| 62 | + offset="100%" |
| 63 | + style={{ stopColor: GRADIENT_END_COLOR, stopOpacity: 1 }} |
| 64 | + /> |
| 65 | + </linearGradient> |
| 66 | + </defs> |
| 67 | + </svg> |
| 68 | + <IconContainer className="fo-teams-cta-pulse-animation"> |
| 69 | + <AutoAwesomeIcon |
| 70 | + sx={{ |
| 71 | + fontSize: { xs: 16, sm: 20 }, |
| 72 | + mr: 1, |
| 73 | + fill: "url(#gradient1)", |
| 74 | + }} |
| 75 | + /> |
| 76 | + </IconContainer> |
| 77 | + </> |
| 78 | +); |
| 79 | + |
| 80 | +const ButtonContainer = styled.div<{ bgColor: string }>` |
| 81 | + background-color: ${({ bgColor }) => bgColor}; |
| 82 | + border-radius: 16px; |
| 83 | +
|
| 84 | + &:hover { |
| 85 | + background-color: transparent; |
| 86 | + } |
| 87 | +`; |
| 88 | + |
| 89 | +const StyledExternalLink = styled(ExternalLink)` |
| 90 | + text-decoration: none; |
| 91 | +
|
| 92 | + &:hover { |
| 93 | + text-decoration: none; |
| 94 | + } |
| 95 | +`; |
| 96 | + |
| 97 | +const BaseEnterpriseButton = styled(Button)<{ |
| 98 | + borderColor: string; |
| 99 | + isLightMode?: boolean; |
| 100 | +}>` |
| 101 | + background: linear-gradient(45deg, #ff6d04 0%, #b681ff 100%); |
| 102 | + background-clip: text; |
| 103 | + -webkit-background-clip: text; |
| 104 | + text-fill-color: transparent; |
| 105 | + -webkit-text-fill-color: transparent; |
| 106 | + display: flex; |
| 107 | + align-items: center; |
| 108 | + gap: 2px; |
| 109 | + padding: 6px 12px; |
| 110 | + border-radius: 16px; |
| 111 | + font-weight: 500; |
| 112 | + text-transform: none; |
| 113 | + transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); |
| 114 | + text-decoration: none; |
| 115 | + font-size: 16px; |
| 116 | + position: relative; |
| 117 | + overflow: hidden; |
| 118 | + border: 1px solid ${({ borderColor }) => borderColor}; |
| 119 | + outline: none; |
| 120 | + box-shadow: none; |
| 121 | +
|
| 122 | + @media (max-width: 767px) { |
| 123 | + font-size: 14px; |
| 124 | + padding: 4px 10px; |
| 125 | + } |
| 126 | +
|
| 127 | + &:before { |
| 128 | + content: ""; |
| 129 | + position: absolute; |
| 130 | + top: 0; |
| 131 | + left: -100%; |
| 132 | + width: ${({ isLightMode }) => (isLightMode ? "150%" : "100%")}; |
| 133 | + height: 100%; |
| 134 | + background: linear-gradient( |
| 135 | + 90deg, |
| 136 | + rgba(255, 255, 255, 0) 0%, |
| 137 | + rgba(255, 255, 255, ${({ isLightMode }) => (isLightMode ? "0.3" : "0.2")}) |
| 138 | + 50%, |
| 139 | + rgba(255, 255, 255, 0) 100% |
| 140 | + ); |
| 141 | + transition: all ${({ isLightMode }) => (isLightMode ? "0.8s" : "0.6s")} ease; |
| 142 | + z-index: 1; |
| 143 | + } |
| 144 | +
|
| 145 | + &:hover, |
| 146 | + &:focus, |
| 147 | + &:active { |
| 148 | + transform: scale(1.03); |
| 149 | + text-decoration: none; |
| 150 | + border: 1px solid ${({ borderColor }) => borderColor} !important; |
| 151 | + outline: none; |
| 152 | + box-shadow: none; |
| 153 | +
|
| 154 | + background: linear-gradient(45deg, #ff6d04 0%, #b681ff 100%) !important; |
| 155 | + background-clip: text !important; |
| 156 | + -webkit-background-clip: text !important; |
| 157 | + text-fill-color: transparent !important; |
| 158 | + -webkit-text-fill-color: transparent !important; |
| 159 | +
|
| 160 | + &:before { |
| 161 | + left: 100%; |
| 162 | + background: linear-gradient( |
| 163 | + 90deg, |
| 164 | + rgba(255, 255, 255, 0) 0%, |
| 165 | + rgba( |
| 166 | + 255, |
| 167 | + 255, |
| 168 | + 255, |
| 169 | + ${({ isLightMode }) => (isLightMode ? "0.6" : "0.2")} |
| 170 | + ) |
| 171 | + 50%, |
| 172 | + rgba(255, 255, 255, 0) 100% |
| 173 | + ); |
| 174 | + } |
| 175 | +
|
| 176 | + .fo-teams-cta-pulse-animation { |
| 177 | + ${pulseAnimation} |
| 178 | + } |
| 179 | + } |
| 180 | +`; |
| 181 | + |
| 182 | +const PopoverContent = styled(Box)` |
| 183 | + padding: 16px; |
| 184 | + width: 310px; |
| 185 | + position: relative; |
| 186 | + display: flex; |
| 187 | + flex-direction: column; |
| 188 | + gap: 12px; |
| 189 | +`; |
| 190 | + |
| 191 | +const PopoverHeading = styled(Typography)` |
| 192 | + display: flex; |
| 193 | + align-items: center; |
| 194 | + gap: 8px; |
| 195 | + font-weight: 600; |
| 196 | + margin-bottom: 12px; |
| 197 | +`; |
| 198 | + |
| 199 | +const PopoverBody = styled(Typography)` |
| 200 | + position: relative; |
| 201 | + color: var(--fo-palette-text-secondary); |
| 202 | + font-size: 15px !important; |
| 203 | +`; |
| 204 | + |
| 205 | +const PopoverFooter = styled(Stack)` |
| 206 | + margin-top: 16px; |
| 207 | +`; |
| 208 | + |
| 209 | +export default function Teams({ |
| 210 | + disablePopover = false, |
| 211 | +}: { disablePopover?: boolean }) { |
| 212 | + const [showPopover, setShowPopover] = useState(false); |
| 213 | + |
| 214 | + const { mode } = useColorScheme(); |
| 215 | + const theme = useTheme(); |
| 216 | + |
| 217 | + const bgColor = mode === "light" ? LIGHT_BG_COLOR : DARK_BG_COLOR; |
| 218 | + |
| 219 | + useEffect(() => { |
| 220 | + const hasSeenTooltip = window.localStorage.getItem(ENTERPRISE_TOOLTIP_LS); |
| 221 | + |
| 222 | + // don't show intro popoverif we're in playwright |
| 223 | + const isPlaywright = window["IS_PLAYWRIGHT"]; |
| 224 | + |
| 225 | + if (!hasSeenTooltip && !isPlaywright) { |
| 226 | + setShowPopover(true); |
| 227 | + } |
| 228 | + }, []); |
| 229 | + |
| 230 | + const markTooltipSeen = useCallback(() => { |
| 231 | + localStorage.setItem(ENTERPRISE_TOOLTIP_LS, "true"); |
| 232 | + }, []); |
| 233 | + |
| 234 | + const handlePopoverClose = useCallback(() => { |
| 235 | + markTooltipSeen(); |
| 236 | + setShowPopover(false); |
| 237 | + }, [markTooltipSeen]); |
| 238 | + |
| 239 | + const handleExplore = useCallback(() => { |
| 240 | + markTooltipSeen(); |
| 241 | + setShowPopover(false); |
| 242 | + window.open( |
| 243 | + "https://voxel51.com/why-upgrade?utm_source=FiftyOneApp", |
| 244 | + "_blank" |
| 245 | + ); |
| 246 | + }, [markTooltipSeen]); |
3 | 247 |
|
4 |
| -export default function Teams() { |
5 | 248 | return (
|
6 |
| - <ExternalLink |
7 |
| - href={"https://voxel51.com/book-a-demo/?utm_source=FiftyOneApp"} |
8 |
| - > |
9 |
| - <Button>Have a Team?</Button> |
10 |
| - </ExternalLink> |
| 249 | + <> |
| 250 | + <ButtonContainer bgColor={mode === "light" ? "transparent" : bgColor}> |
| 251 | + <StyledExternalLink href="https://voxel51.com/why-upgrade?utm_source=FiftyOneApp"> |
| 252 | + <BaseEnterpriseButton |
| 253 | + borderColor={mode === "dark" ? DARK_BG_COLOR : theme.divider} |
| 254 | + isLightMode={mode === "light"} |
| 255 | + id={ENTERPRISE_BUTTON_ID} |
| 256 | + > |
| 257 | + <GradientAutoAwesomeIcon /> |
| 258 | + Explore Enterprise |
| 259 | + </BaseEnterpriseButton> |
| 260 | + </StyledExternalLink> |
| 261 | + </ButtonContainer> |
| 262 | + |
| 263 | + {showPopover && !disablePopover && ( |
| 264 | + <Popover |
| 265 | + open |
| 266 | + anchorEl={document.getElementById(ENTERPRISE_BUTTON_ID)} |
| 267 | + onClose={handlePopoverClose} |
| 268 | + anchorOrigin={{ |
| 269 | + vertical: "bottom", |
| 270 | + horizontal: "center", |
| 271 | + }} |
| 272 | + transformOrigin={{ |
| 273 | + vertical: -12, |
| 274 | + horizontal: "center", |
| 275 | + }} |
| 276 | + elevation={3} |
| 277 | + > |
| 278 | + <PopoverContent |
| 279 | + style={{ |
| 280 | + backgroundColor: |
| 281 | + mode === "light" ? LIGHT_BG_COLOR : DARK_BG_COLOR, |
| 282 | + }} |
| 283 | + > |
| 284 | + <PopoverHeading variant="h6"> |
| 285 | + <GradientAutoAwesomeIcon /> |
| 286 | + <Typography variant="h6" letterSpacing={0.3}> |
| 287 | + Accelerate your workflow |
| 288 | + </Typography> |
| 289 | + </PopoverHeading> |
| 290 | + |
| 291 | + <PopoverBody variant="body2"> |
| 292 | + With FiftyOne Enterprise you can connect to your data lake, |
| 293 | + automate your data curation and model analysis tasks, securely |
| 294 | + collaborate with your team, and more. |
| 295 | + </PopoverBody> |
| 296 | + |
| 297 | + <PopoverFooter direction="row" spacing={2}> |
| 298 | + <MuiButton |
| 299 | + variant="contained" |
| 300 | + onClick={handleExplore} |
| 301 | + size="large" |
| 302 | + sx={{ |
| 303 | + boxShadow: "none", |
| 304 | + }} |
| 305 | + > |
| 306 | + Explore Enterprise |
| 307 | + </MuiButton> |
| 308 | + <MuiButton |
| 309 | + variant="outlined" |
| 310 | + color="secondary" |
| 311 | + onClick={handlePopoverClose} |
| 312 | + size="large" |
| 313 | + sx={{ |
| 314 | + boxShadow: "none", |
| 315 | + }} |
| 316 | + > |
| 317 | + Dismiss |
| 318 | + </MuiButton> |
| 319 | + </PopoverFooter> |
| 320 | + </PopoverContent> |
| 321 | + </Popover> |
| 322 | + )} |
| 323 | + </> |
11 | 324 | );
|
12 | 325 | }
|
0 commit comments