From c55973fac0ae3c799ad86ffa60349c4216c11ce3 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Tue, 4 Jun 2024 18:25:46 +0200 Subject: [PATCH] :children_crossing: (onboarding) Introduce new onboarding floating videos mechanism --- apps/builder/src/components/icons.tsx | 17 ++ .../editor/components/BoardMenuButton.tsx | 10 +- .../features/editor/components/EditorPage.tsx | 5 +- .../editor/components/GettingStartedModal.tsx | 174 ------------------ .../editor/components/TypebotHeader.tsx | 2 +- .../folders/components/CreateBotButton.tsx | 4 +- .../folders/components/FolderContent.tsx | 1 - .../nodes/block/SettingsHoverBar.tsx | 26 ++- .../nodes/block/SettingsPopoverContent.tsx | 73 +++++--- .../components/OnboardingPage.tsx | 2 +- .../VideoOnboardingFloatingWindow.tsx | 68 +++++++ .../components/VideoOnboardingPopover.tsx | 76 ++++++++ .../onboarding/components/YoutubeIframe.tsx | 60 ++++++ apps/builder/src/features/onboarding/data.ts | 32 ++++ .../onboarding/helpers/hasOnboardingVideo.ts | 13 ++ .../hooks/useOnboardingDisclosure.ts | 65 +++++++ .../components/CreateNewTypebotButtons.tsx | 12 -- apps/builder/src/pages/onboarding.tsx | 2 +- packages/forge/core/types.ts | 4 + 19 files changed, 412 insertions(+), 234 deletions(-) delete mode 100644 apps/builder/src/features/editor/components/GettingStartedModal.tsx rename apps/builder/src/features/{auth => onboarding}/components/OnboardingPage.tsx (99%) create mode 100644 apps/builder/src/features/onboarding/components/VideoOnboardingFloatingWindow.tsx create mode 100644 apps/builder/src/features/onboarding/components/VideoOnboardingPopover.tsx create mode 100644 apps/builder/src/features/onboarding/components/YoutubeIframe.tsx create mode 100644 apps/builder/src/features/onboarding/data.ts create mode 100644 apps/builder/src/features/onboarding/helpers/hasOnboardingVideo.ts create mode 100644 apps/builder/src/features/onboarding/hooks/useOnboardingDisclosure.ts diff --git a/apps/builder/src/components/icons.tsx b/apps/builder/src/components/icons.tsx index 89938d9afc..e9a1990e92 100644 --- a/apps/builder/src/components/icons.tsx +++ b/apps/builder/src/components/icons.tsx @@ -678,3 +678,20 @@ export const BracesIcon = (props: IconProps) => ( ) + +export const VideoPopoverIcon = (props: IconProps) => ( + + + + +) diff --git a/apps/builder/src/features/editor/components/BoardMenuButton.tsx b/apps/builder/src/features/editor/components/BoardMenuButton.tsx index cc83822108..b5e47c2666 100644 --- a/apps/builder/src/features/editor/components/BoardMenuButton.tsx +++ b/apps/builder/src/features/editor/components/BoardMenuButton.tsx @@ -18,27 +18,19 @@ import { SettingsIcon, } from '@/components/icons' import { useTypebot } from '../providers/TypebotProvider' -import React, { useEffect, useState } from 'react' +import React, { useState } from 'react' import { EditorSettingsModal } from './EditorSettingsModal' import { parseDefaultPublicId } from '@/features/publish/helpers/parseDefaultPublicId' import { useTranslate } from '@tolgee/react' -import { useUser } from '@/features/account/hooks/useUser' -import { useRouter } from 'next/router' import { RightPanel, useEditor } from '../providers/EditorProvider' export const BoardMenuButton = (props: StackProps) => { - const { query } = useRouter() const { typebot, currentUserMode } = useTypebot() - const { user } = useUser() const [isDownloading, setIsDownloading] = useState(false) const { isOpen, onOpen, onClose } = useDisclosure() const { t } = useTranslate() const { setRightPanel } = useEditor() - useEffect(() => { - if (user && !user.graphNavigation && !query.isFirstBot) onOpen() - }, [onOpen, query.isFirstBot, user, user?.graphNavigation]) - const downloadFlow = () => { assert(typebot) setIsDownloading(true) diff --git a/apps/builder/src/features/editor/components/EditorPage.tsx b/apps/builder/src/features/editor/components/EditorPage.tsx index 514a3dd2ff..80c03c63af 100644 --- a/apps/builder/src/features/editor/components/EditorPage.tsx +++ b/apps/builder/src/features/editor/components/EditorPage.tsx @@ -8,7 +8,6 @@ import { import { useTypebot } from '../providers/TypebotProvider' import { BlocksSideBar } from './BlocksSideBar' import { BoardMenuButton } from './BoardMenuButton' -import { GettingStartedModal } from './GettingStartedModal' import { PreviewDrawer } from '@/features/preview/components/PreviewDrawer' import { TypebotHeader } from './TypebotHeader' import { Graph } from '@/features/graph/components/Graph' @@ -19,6 +18,7 @@ import { TypebotNotFoundPage } from './TypebotNotFoundPage' import { SuspectedTypebotBanner } from './SuspectedTypebotBanner' import { useWorkspace } from '@/features/workspace/WorkspaceProvider' import { VariablesDrawer } from '@/features/preview/components/VariablesDrawer' +import { VideoOnboardingFloatingWindow } from '@/features/onboarding/components/VideoOnboardingFloatingWindow' export const EditorPage = () => { const { typebot, currentUserMode, is404 } = useTypebot() @@ -32,11 +32,12 @@ export const EditorPage = () => { const isSuspicious = typebot?.riskLevel === 100 && !workspace?.isVerified if (is404) return + return ( - + {isSuspicious && } { - const { t } = useTranslate() - const { query } = useRouter() - const { isOpen, onOpen, onClose } = useDisclosure() - - useEffect(() => { - if (query.isFirstBot) onOpen() - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []) - - return ( - - - - - - - - {t('editor.gettingStartedModal.editorBasics.heading')} - - - - - 1 - - - {t('editor.gettingStartedModal.editorBasics.list.one.label')} - - - - - 2 - - - {t('editor.gettingStartedModal.editorBasics.list.two.label')} - - - - - 3 - - - {t( - 'editor.gettingStartedModal.editorBasics.list.three.label' - )} - - - - - 4 - - - {t('editor.gettingStartedModal.editorBasics.list.four.label')} - - - - - - {t('editor.gettingStartedModal.editorBasics.list.label')} - - - {t('editor.gettingStartedModal.seeAction.label')} ({`<`}{' '} - {t('editor.gettingStartedModal.seeAction.time')}) - -