-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🪟🧪 [Experiment] Incentivize speedy first connection (aka activation) (#…
…17593) * 🪟🧪 [Experiment] Incentivize speedy first connection (aka activation)
- Loading branch information
1 parent
a71b7ca
commit 5466a68
Showing
18 changed files
with
410 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...s/cloud/components/experiments/SpeedyConnection/CountDownTimer/CountDownTimer.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@use "../../../../../../../src/scss/variables"; | ||
@use "../../../../../../../src/scss/colors"; | ||
|
||
.countDownTimerContainer { | ||
display: flex; | ||
gap: variables.$spacing-md; | ||
} | ||
|
||
.countDownTimerItem { | ||
color: colors.$orange; | ||
font-size: 16px; | ||
line-height: 28px; | ||
font-weight: 700; | ||
} |
15 changes: 15 additions & 0 deletions
15
.../packages/cloud/components/experiments/SpeedyConnection/CountDownTimer/CountDownTimer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Text } from "components/ui/Text"; | ||
|
||
import styles from "./CountDownTimer.module.scss"; | ||
import { useCountdown } from "./useCountdown"; | ||
export const CountDownTimer: React.FC<{ expiredOfferDate: string }> = ({ expiredOfferDate }) => { | ||
const [hours, minutes, seconds] = useCountdown(expiredOfferDate); | ||
|
||
return ( | ||
<div className={styles.countDownTimerContainer}> | ||
<Text className={styles.countDownTimerItem}>{hours.toString().padStart(2, "0")}h</Text> | ||
<Text className={styles.countDownTimerItem}>{minutes.toString().padStart(2, "0")}m</Text> | ||
<Text className={styles.countDownTimerItem}>{seconds.toString().padStart(2, "0")}s</Text> | ||
</div> | ||
); | ||
}; |
1 change: 1 addition & 0 deletions
1
...webapp/src/packages/cloud/components/experiments/SpeedyConnection/CountDownTimer/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./CountDownTimer"; |
26 changes: 26 additions & 0 deletions
26
...src/packages/cloud/components/experiments/SpeedyConnection/CountDownTimer/useCountdown.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useEffect, useState } from "react"; | ||
|
||
export const useCountdown = (targetDate: string) => { | ||
const countDownDate = new Date(targetDate).getTime(); | ||
|
||
const [countDown, setCountDown] = useState(countDownDate - new Date().getTime()); | ||
|
||
useEffect(() => { | ||
const interval = setInterval(() => { | ||
setCountDown(countDownDate - new Date().getTime()); | ||
}, 1000); | ||
|
||
return () => clearInterval(interval); | ||
}, [countDownDate]); | ||
|
||
return getReturnValues(countDown); | ||
}; | ||
|
||
const getReturnValues = (countDown: number): number[] => { | ||
// calculate time left | ||
const hours = Math.floor((countDown % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); | ||
const minutes = Math.floor((countDown % (1000 * 60 * 60)) / (1000 * 60)); | ||
const seconds = Math.floor((countDown % (1000 * 60)) / 1000); | ||
|
||
return [hours, minutes, seconds]; | ||
}; |
39 changes: 39 additions & 0 deletions
39
...ts/experiments/SpeedyConnection/SpeedyConnectionBanner/SpeedyConnectionBanner.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
@use "../../../../../../../src/scss/variables"; | ||
@use "../../../../../../../src/scss/colors"; | ||
|
||
.container { | ||
height: 43px; | ||
width: 100%; | ||
position: fixed; | ||
top: 0; | ||
z-index: 3; | ||
font-size: 12px; | ||
line-height: 15px; | ||
color: colors.$black; | ||
padding: 8px; | ||
display: flex; | ||
align-items: center; | ||
background-color: colors.$beige-100; | ||
|
||
@media (min-width: 1280px) { | ||
height: 50px; | ||
} | ||
} | ||
|
||
.innerContainer { | ||
display: flex; | ||
width: 80%; | ||
flex-direction: row; | ||
gap: variables.$spacing-md; | ||
justify-content: center; | ||
align-items: center; | ||
margin: auto; | ||
} | ||
|
||
.linkCta { | ||
color: colors.$dark-blue; | ||
} | ||
|
||
.textDecorationNone { | ||
text-decoration: none; | ||
} |
51 changes: 51 additions & 0 deletions
51
...components/experiments/SpeedyConnection/SpeedyConnectionBanner/SpeedyConnectionBanner.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import classnames from "classnames"; | ||
import classNames from "classnames"; | ||
import { FormattedMessage } from "react-intl"; | ||
import { Link, useLocation } from "react-router-dom"; | ||
|
||
import { Text } from "components/ui/Text"; | ||
|
||
import { useExperiment } from "hooks/services/Experiment"; | ||
import { CountDownTimer } from "packages/cloud/components/experiments/SpeedyConnection/CountDownTimer"; | ||
import { StepType } from "pages/OnboardingPage/types"; | ||
import { RoutePaths } from "pages/routePaths"; | ||
|
||
import { useExperimentSpeedyConnection } from "../hooks/useExperimentSpeedyConnection"; | ||
import credits from "./credits.svg"; | ||
import styles from "./SpeedyConnectionBanner.module.scss"; | ||
|
||
export const SpeedyConnectionBanner = () => { | ||
const { expiredOfferDate } = useExperimentSpeedyConnection(); | ||
const location = useLocation(); | ||
const hideOnboardingExperiment = useExperiment("onboarding.hideOnboarding", false); | ||
|
||
return ( | ||
<div className={classnames(styles.container)}> | ||
<div className={styles.innerContainer}> | ||
<img src={credits} alt="" /> | ||
|
||
<FormattedMessage | ||
id="experiment.speedyConnection" | ||
defaultMessage="<link>Set up your first connection</link> in the next <timer></timer> and get <b>100 additonal credits</b> for your trial" | ||
values={{ | ||
link: (link: React.ReactNode[]) => ( | ||
<Link | ||
className={classNames(styles.linkCta, { | ||
[styles.textDecorationNone]: location.pathname.includes("onboarding"), | ||
})} | ||
to={hideOnboardingExperiment ? RoutePaths.Connections : RoutePaths.Onboarding} | ||
state={{ | ||
step: StepType.CREATE_SOURCE, | ||
}} | ||
> | ||
<Text bold>{link}</Text> | ||
</Link> | ||
), | ||
timer: () => <CountDownTimer expiredOfferDate={expiredOfferDate} />, | ||
}} | ||
/> | ||
<img src={credits} alt="" /> | ||
</div> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.