-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5401 from novuhq/feature/onb-exp-v2-modal
feat: add modal on get started page for onboarding experiment v2
- Loading branch information
Showing
6 changed files
with
157 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const OnboardingExperimentV2ModalKey = 'nv_onboarding_modal'; |
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
125 changes: 125 additions & 0 deletions
125
apps/web/src/pages/quick-start/components/OnboardingExperimentModal.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,125 @@ | ||
import { useState } from 'react'; | ||
import { Modal, useMantineTheme, Grid } from '@mantine/core'; | ||
|
||
import styled from '@emotion/styled'; | ||
import { colors, shadows, Title, Button } from '@novu/design-system'; | ||
import { useAuthContext, useSegment } from '@novu/shared-web'; | ||
import { useCreateOnboardingExperimentWorkflow } from '../../../api/hooks/notification-templates/useCreateOnboardingExperimentWorkflow'; | ||
import { OnboardingExperimentV2ModalKey } from '../../../constants/experimentsConstants'; | ||
import { OnBoardingAnalyticsEnum } from '../consts'; | ||
|
||
export function OnboardingExperimentModal() { | ||
const [opened, setOpened] = useState(true); | ||
const theme = useMantineTheme(); | ||
const segment = useSegment(); | ||
const { currentOrganization } = useAuthContext(); | ||
const { | ||
createOnboardingExperimentWorkflow, | ||
isLoading: IsCreateOnboardingExpWorkflowLoading, | ||
isDisabled: isIsCreateOnboardingExpWorkflowDisabled, | ||
} = useCreateOnboardingExperimentWorkflow(); | ||
const handleOnClose = () => { | ||
setOpened(true); | ||
}; | ||
|
||
return ( | ||
<Modal | ||
opened={opened} | ||
overlayColor={theme.colorScheme === 'dark' ? colors.BGDark : colors.BGLight} | ||
overlayOpacity={0.7} | ||
styles={{ | ||
modal: { | ||
backgroundColor: theme.colorScheme === 'dark' ? colors.B15 : colors.white, | ||
width: '700px', | ||
}, | ||
body: { | ||
paddingTop: '5px', | ||
paddingInline: '8px', | ||
}, | ||
}} | ||
title={<Title size={2}>What would you like to do first?</Title>} | ||
sx={{ backdropFilter: 'blur(10px)' }} | ||
shadow={theme.colorScheme === 'dark' ? shadows.dark : shadows.medium} | ||
radius="md" | ||
size="lg" | ||
onClose={handleOnClose} | ||
centered | ||
withCloseButton={false} | ||
> | ||
<Grid> | ||
<Grid.Col xs={12} md={6} mb={20}> | ||
<ChannelCard> | ||
<TitleRow> Send test notification</TitleRow> | ||
<Description>Learn how to setup a workflow and send your first email notification.</Description> | ||
<StyledButton | ||
loading={IsCreateOnboardingExpWorkflowLoading} | ||
disabled={isIsCreateOnboardingExpWorkflowDisabled} | ||
pulse={true} | ||
variant="gradient" | ||
onClick={async () => { | ||
segment.track(OnBoardingAnalyticsEnum.ONBOARDING_EXPERIMENT_TEST_NOTIFICATION, { | ||
action: 'Modal - Send test notification', | ||
experiment_id: '2024-w15-onb', | ||
_organization: currentOrganization?._id, | ||
}); | ||
localStorage.removeItem(OnboardingExperimentV2ModalKey); | ||
createOnboardingExperimentWorkflow(); | ||
}} | ||
> | ||
Send test notification now | ||
</StyledButton> | ||
</ChannelCard> | ||
</Grid.Col> | ||
<Grid.Col xs={12} md={6} mb={20}> | ||
<ChannelCard> | ||
<TitleRow> Look around</TitleRow> | ||
<Description>Start exploring the Novu app on your own terms</Description> | ||
<StyledButton | ||
variant="outline" | ||
onClick={async () => { | ||
segment.track(OnBoardingAnalyticsEnum.ONBOARDING_EXPERIMENT_TEST_NOTIFICATION, { | ||
action: 'Modal - Get started', | ||
experiment_id: '2024-w15-onb', | ||
_organization: currentOrganization?._id, | ||
}); | ||
localStorage.removeItem(OnboardingExperimentV2ModalKey); | ||
setOpened(false); | ||
}} | ||
> | ||
Get started | ||
</StyledButton> | ||
</ChannelCard> | ||
</Grid.Col> | ||
</Grid> | ||
</Modal> | ||
); | ||
} | ||
|
||
const ChannelCard = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
flex-direction: column; | ||
max-width: 230px; | ||
`; | ||
|
||
const TitleRow = styled.div` | ||
display: flex; | ||
align-items: center; | ||
font-size: 20px; | ||
line-height: 32px; | ||
margin-bottom: 8px; | ||
`; | ||
|
||
const Description = styled.div` | ||
flex: auto; | ||
font-size: 16px; | ||
line-height: 20px; | ||
margin-bottom: 20px; | ||
color: ${colors.B60}; | ||
height: 60px; | ||
`; | ||
|
||
const StyledButton = styled(Button)` | ||
width: fit-content; | ||
outline: none; | ||
`; |
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
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