-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
11
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
11 commits
Select commit
Hold shift + click to select a range
6721d44
feat: add product tour
adithyaakrishna a7636ca
chore: updated modals
adithyaakrishna 4cec083
chore: fix the tour
adithyaakrishna 2129225
chore: Tour Updates
adithyaakrishna 67aa975
chore: fix review changes
adithyaakrishna cf8d9a8
chore: fix review changes
adithyaakrishna 9b0910d
chore: fix review changes
adithyaakrishna 338f884
chore: fix review changes
adithyaakrishna fd51d05
chore: fix review changes
adithyaakrishna 3d4b5ba
minor improvements
waleedlatif1 9078913
chore(tour): address PR review comments
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, | ||
| }, | ||
| ] |
99 changes: 99 additions & 0 deletions
99
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,99 @@ | ||
| 'use client' | ||
|
|
||
| import { useMemo } from 'react' | ||
| import { createLogger } from '@sim/logger' | ||
| 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 { | ||
| TourStateContext, | ||
| TourTooltipAdapter, | ||
| } from '@/app/workspace/[workspaceId]/components/product-tour/tour-shared' | ||
| import { useTour } from '@/app/workspace/[workspaceId]/components/product-tour/use-tour' | ||
|
|
||
| const logger = createLogger('NavTour') | ||
|
|
||
| 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} | ||
| 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: 8, | ||
| boxShadow: '0 0 0 9999px rgba(0, 0, 0, 0.55)', | ||
| position: 'fixed' as React.CSSProperties['position'], | ||
| 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)', | ||
| }, | ||
| 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'], | ||
| }, | ||
| }} | ||
| /> | ||
| </TourStateContext.Provider> | ||
| ) | ||
| } | ||
114 changes: 114 additions & 0 deletions
114
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,114 @@ | ||
| 'use client' | ||
|
|
||
| import { createContext, useCallback, useContext, useEffect, useRef, 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) | ||
| const hasSetRef = useRef(false) | ||
|
|
||
| useEffect(() => { | ||
| hasSetRef.current = false | ||
| 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 (!hasSetRef.current && tooltipProps.ref) { | ||
| ;(tooltipProps.ref as React.RefCallback<HTMLDivElement>)(node) | ||
| hasSetRef.current = true | ||
| } | ||
| }, | ||
| [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} | ||
| /> | ||
| </> | ||
| ) | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused
loggervariable creates dead codeLow Severity
createLoggeris imported andloggeris created at module scope on line 15, butloggeris never referenced anywhere in the file. TheuseTourhook already creates its own internal logger, making this one entirely dead code.