-
Notifications
You must be signed in to change notification settings - Fork 3.5k
feat(tour): added product tour #3703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
waleedlatif1
wants to merge
15
commits into
staging
Choose a base branch
from
feat/product-tour
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
68751f2
feat: add product tour
adithyaakrishna 6b26102
chore: updated modals
adithyaakrishna 8363177
chore: fix the tour
adithyaakrishna baa6799
chore: Tour Updates
adithyaakrishna 43a33d0
chore: fix review changes
adithyaakrishna 73b0f87
chore: fix review changes
adithyaakrishna bdcfd97
chore: fix review changes
adithyaakrishna 0522b2c
chore: fix review changes
adithyaakrishna f9a52fb
chore: fix review changes
adithyaakrishna bca0ece
minor improvements
waleedlatif1 d243120
chore(tour): address PR review comments
waleedlatif1 9c9c1f8
chore(tour): address remaining PR review comments
waleedlatif1 752d043
chore(tour): address second round of PR review comments
waleedlatif1 d71f1a8
chore(tour): extract shared Joyride config, fix popover arrow overflow
waleedlatif1 85577eb
lint
waleedlatif1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
apps/sim/app/workspace/[workspaceId]/components/product-tour/index.ts
This file contains hidden or 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,2 @@ | ||
| export { NavTour, START_NAV_TOUR_EVENT } from './product-tour' | ||
| export { START_WORKFLOW_TOUR_EVENT, WorkflowTour } from './workflow-tour' |
76 changes: 76 additions & 0 deletions
76
apps/sim/app/workspace/[workspaceId]/components/product-tour/nav-tour-steps.ts
This file contains hidden or 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,76 @@ | ||
| import type { Step } from 'react-joyride' | ||
|
|
||
| export const navTourSteps: Step[] = [ | ||
| { | ||
| target: '[data-item-id="home"]', | ||
| title: 'Home', | ||
| content: | ||
| 'Your starting point. Describe what you want to build in plain language or pick a template to get started.', | ||
| placement: 'right', | ||
| disableBeacon: true, | ||
| spotlightPadding: 0, | ||
| }, | ||
| { | ||
| target: '[data-item-id="search"]', | ||
| title: 'Search', | ||
| content: 'Quickly find workflows, blocks, and tools. Use Cmd+K to open it from anywhere.', | ||
| placement: 'right', | ||
| disableBeacon: true, | ||
| spotlightPadding: 0, | ||
| }, | ||
| { | ||
| target: '[data-item-id="tables"]', | ||
| title: 'Tables', | ||
| content: | ||
| 'Store and query structured data. Your workflows can read and write to tables directly.', | ||
| placement: 'right', | ||
| disableBeacon: true, | ||
| }, | ||
| { | ||
| target: '[data-item-id="files"]', | ||
| title: 'Files', | ||
| content: 'Upload and manage files that your workflows can process, transform, or reference.', | ||
| placement: 'right', | ||
| disableBeacon: true, | ||
| }, | ||
| { | ||
| target: '[data-item-id="knowledge-base"]', | ||
| title: 'Knowledge Base', | ||
| content: | ||
| 'Build knowledge bases from your documents. Set up connectors to give your agents realtime access to your data sources from sources like Notion, Drive, Slack, Confluence, and more.', | ||
| placement: 'right', | ||
| disableBeacon: true, | ||
| }, | ||
| { | ||
| target: '[data-item-id="scheduled-tasks"]', | ||
| title: 'Scheduled Tasks', | ||
| content: | ||
| 'View and manage background tasks. Set up new tasks, or view the tasks the Mothership is monitoring for upcoming or past executions.', | ||
| placement: 'right', | ||
| disableBeacon: true, | ||
| }, | ||
| { | ||
| target: '[data-item-id="logs"]', | ||
| title: 'Logs', | ||
| content: | ||
| 'Monitor every workflow execution. See inputs, outputs, errors, and timing for each run. View analytics on performance and costs, filter previous runs, and view snapshots of the workflow at the time of execution.', | ||
| placement: 'right', | ||
| disableBeacon: true, | ||
| }, | ||
| { | ||
| target: '.tasks-section', | ||
| title: 'Tasks', | ||
| content: | ||
| 'Tasks that work for you. Mothership can create, edit, and delete resource throughout the platform. It can also perform actions on your behalf, like sending emails, creating tasks, and more.', | ||
| placement: 'right', | ||
| disableBeacon: true, | ||
| }, | ||
| { | ||
| target: '.workflows-section', | ||
| title: 'Workflows', | ||
| content: | ||
| 'All your workflows live here. Create new ones with the + button and organize them into folders. Deploy your workflows as API, webhook, schedule, or chat widget. Then hit Run to test it out.', | ||
| placement: 'right', | ||
| disableBeacon: true, | ||
| }, | ||
| ] |
63 changes: 63 additions & 0 deletions
63
apps/sim/app/workspace/[workspaceId]/components/product-tour/product-tour.tsx
This file contains hidden or 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,63 @@ | ||
| 'use client' | ||
|
|
||
| import { useMemo } from 'react' | ||
| import dynamic from 'next/dynamic' | ||
| import { usePathname } from 'next/navigation' | ||
| import { navTourSteps } from '@/app/workspace/[workspaceId]/components/product-tour/nav-tour-steps' | ||
| import type { TourState } from '@/app/workspace/[workspaceId]/components/product-tour/tour-shared' | ||
| import { | ||
| getSharedJoyrideProps, | ||
| TourStateContext, | ||
| TourTooltipAdapter, | ||
| } from '@/app/workspace/[workspaceId]/components/product-tour/tour-shared' | ||
| import { useTour } from '@/app/workspace/[workspaceId]/components/product-tour/use-tour' | ||
|
|
||
| const Joyride = dynamic(() => import('react-joyride'), { | ||
| ssr: false, | ||
| }) | ||
|
|
||
| const NAV_TOUR_STORAGE_KEY = 'sim-nav-tour-completed-v1' | ||
| export const START_NAV_TOUR_EVENT = 'start-nav-tour' | ||
|
|
||
| export function NavTour() { | ||
| const pathname = usePathname() | ||
| const isWorkflowPage = /\/w\/[^/]+/.test(pathname) | ||
|
|
||
| const { run, stepIndex, tourKey, isTooltipVisible, isEntrance, handleCallback } = useTour({ | ||
| steps: navTourSteps, | ||
| storageKey: NAV_TOUR_STORAGE_KEY, | ||
| autoStartDelay: 1200, | ||
| resettable: true, | ||
| triggerEvent: START_NAV_TOUR_EVENT, | ||
| tourName: 'Navigation tour', | ||
| disabled: isWorkflowPage, | ||
| }) | ||
|
|
||
| const tourState = useMemo<TourState>( | ||
| () => ({ | ||
| isTooltipVisible, | ||
| isEntrance, | ||
| totalSteps: navTourSteps.length, | ||
| }), | ||
| [isTooltipVisible, isEntrance] | ||
| ) | ||
|
|
||
| return ( | ||
| <TourStateContext.Provider value={tourState}> | ||
| <Joyride | ||
| key={tourKey} | ||
| steps={navTourSteps} | ||
| run={run} | ||
| stepIndex={stepIndex} | ||
| callback={handleCallback} | ||
| continuous | ||
| disableScrolling | ||
| disableScrollParentFix | ||
| disableOverlayClose | ||
| spotlightPadding={4} | ||
| tooltipComponent={TourTooltipAdapter} | ||
| {...getSharedJoyrideProps({ spotlightBorderRadius: 8 })} | ||
| /> | ||
| </TourStateContext.Provider> | ||
| ) | ||
| } |
157 changes: 157 additions & 0 deletions
157
apps/sim/app/workspace/[workspaceId]/components/product-tour/tour-shared.tsx
This file contains hidden or 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,157 @@ | ||
| 'use client' | ||
|
|
||
| import { createContext, useCallback, useContext, useEffect, useState } from 'react' | ||
| import type { TooltipRenderProps } from 'react-joyride' | ||
| import { TourTooltip } from '@/components/emcn' | ||
|
|
||
| /** Shared state passed from the tour component to the tooltip adapter via context */ | ||
| export interface TourState { | ||
| isTooltipVisible: boolean | ||
| isEntrance: boolean | ||
| totalSteps: number | ||
| } | ||
|
|
||
| export const TourStateContext = createContext<TourState>({ | ||
| isTooltipVisible: true, | ||
| isEntrance: true, | ||
| totalSteps: 0, | ||
| }) | ||
|
|
||
| /** | ||
| * Maps Joyride placement strings to TourTooltip placement values. | ||
| */ | ||
| function mapPlacement(placement?: string): 'top' | 'right' | 'bottom' | 'left' | 'center' { | ||
| switch (placement) { | ||
| case 'top': | ||
| case 'top-start': | ||
| case 'top-end': | ||
| return 'top' | ||
| case 'right': | ||
| case 'right-start': | ||
| case 'right-end': | ||
| return 'right' | ||
| case 'bottom': | ||
| case 'bottom-start': | ||
| case 'bottom-end': | ||
| return 'bottom' | ||
| case 'left': | ||
| case 'left-start': | ||
| case 'left-end': | ||
| return 'left' | ||
| case 'center': | ||
| return 'center' | ||
| default: | ||
| return 'bottom' | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Adapter that bridges Joyride's tooltip render props to the EMCN TourTooltip component. | ||
| * Reads transition state from TourStateContext to coordinate fade animations. | ||
| */ | ||
| export function TourTooltipAdapter({ | ||
| step, | ||
| index, | ||
| isLastStep, | ||
| tooltipProps, | ||
| primaryProps, | ||
| backProps, | ||
| closeProps, | ||
| }: TooltipRenderProps) { | ||
| const { isTooltipVisible, isEntrance, totalSteps } = useContext(TourStateContext) | ||
| const [targetEl, setTargetEl] = useState<HTMLElement | null>(null) | ||
|
|
||
| useEffect(() => { | ||
| const { target } = step | ||
| if (typeof target === 'string') { | ||
| setTargetEl(document.querySelector<HTMLElement>(target)) | ||
| } else if (target instanceof HTMLElement) { | ||
| setTargetEl(target) | ||
| } else { | ||
| setTargetEl(null) | ||
| } | ||
| }, [step]) | ||
|
|
||
| const refCallback = useCallback( | ||
| (node: HTMLDivElement | null) => { | ||
| if (tooltipProps.ref) { | ||
| ;(tooltipProps.ref as React.RefCallback<HTMLDivElement>)(node) | ||
| } | ||
| }, | ||
| [tooltipProps.ref] | ||
| ) | ||
|
|
||
| const placement = mapPlacement(step.placement) | ||
|
|
||
| return ( | ||
| <> | ||
| <div | ||
| ref={refCallback} | ||
| role={tooltipProps.role} | ||
| aria-modal={tooltipProps['aria-modal']} | ||
| style={{ position: 'absolute', opacity: 0, pointerEvents: 'none', width: 0, height: 0 }} | ||
| /> | ||
| <TourTooltip | ||
| title={step.title as string} | ||
| description={step.content} | ||
| step={index + 1} | ||
| totalSteps={totalSteps} | ||
| placement={placement} | ||
| targetEl={targetEl} | ||
| isFirst={index === 0} | ||
| isLast={isLastStep} | ||
| isVisible={isTooltipVisible} | ||
| isEntrance={isEntrance && index === 0} | ||
| onNext={primaryProps.onClick as () => void} | ||
| onBack={backProps.onClick as () => void} | ||
| onClose={closeProps.onClick as () => void} | ||
| /> | ||
| </> | ||
| ) | ||
| } | ||
|
|
||
| const SPOTLIGHT_TRANSITION = | ||
| 'top 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94), left 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94), width 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94), height 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94)' | ||
|
|
||
| /** | ||
| * Returns the shared Joyride floaterProps and styles config used by both tours. | ||
| * Only `spotlightPadding` and spotlight `borderRadius` differ between tours. | ||
| */ | ||
| export function getSharedJoyrideProps(overrides: { spotlightBorderRadius: number }) { | ||
| return { | ||
| floaterProps: { | ||
| disableAnimation: true, | ||
| hideArrow: true, | ||
| styles: { | ||
| floater: { | ||
| filter: 'none', | ||
| opacity: 0, | ||
| pointerEvents: 'none' as React.CSSProperties['pointerEvents'], | ||
| width: 0, | ||
| height: 0, | ||
| }, | ||
| }, | ||
| }, | ||
| styles: { | ||
| options: { | ||
| zIndex: 10000, | ||
| }, | ||
| spotlight: { | ||
| backgroundColor: 'transparent', | ||
| border: '1px solid rgba(255, 255, 255, 0.1)', | ||
| borderRadius: overrides.spotlightBorderRadius, | ||
| boxShadow: '0 0 0 9999px rgba(0, 0, 0, 0.55)', | ||
| position: 'fixed' as React.CSSProperties['position'], | ||
| transition: SPOTLIGHT_TRANSITION, | ||
| }, | ||
| overlay: { | ||
| backgroundColor: 'transparent', | ||
| mixBlendMode: 'unset' as React.CSSProperties['mixBlendMode'], | ||
| position: 'fixed' as React.CSSProperties['position'], | ||
| height: '100%', | ||
| overflow: 'visible', | ||
| pointerEvents: 'none' as React.CSSProperties['pointerEvents'], | ||
| }, | ||
| }, | ||
| } as const | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.