-
Notifications
You must be signed in to change notification settings - Fork 13
feat: guided tour component #842
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
rohanchkrabrty
wants to merge
2
commits into
main
Choose a base branch
from
guided-tour
base: main
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
2 commits
Select commit
Hold shift + click to select a range
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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 @@ | ||
| 'use client'; | ||
|
|
||
| import { BellIcon, GearIcon, HomeIcon } from '@radix-ui/react-icons'; | ||
| import { | ||
| Button, | ||
| Flex, | ||
| IconButton, | ||
| Text, | ||
| Tour, | ||
| type TourActions, | ||
| type TourStep | ||
| } from '@raystack/apsara'; | ||
| import { useRef } from 'react'; | ||
| import PlaygroundLayout from './playground-layout'; | ||
|
|
||
| const steps: TourStep[] = [ | ||
| { | ||
| id: 'welcome', | ||
| title: 'Welcome', | ||
| content: 'A centered, detached step to open the tour.' | ||
| }, | ||
| { | ||
| id: 'home', | ||
| target: '[data-pg-tour="home"]', | ||
| title: 'Home', | ||
| content: 'Anchored to the home button, popover below.', | ||
| side: 'bottom' | ||
| }, | ||
| { | ||
| id: 'settings', | ||
| target: '[data-pg-tour="settings"]', | ||
| title: 'Settings', | ||
| content: 'Anchored on the right with a pill spotlight.', | ||
| side: 'bottom', | ||
| spotlightRadius: 999, | ||
| spotlightPadding: 6 | ||
| }, | ||
| { | ||
| id: 'alerts', | ||
| target: '[data-pg-tour="alerts"]', | ||
| title: 'Alerts', | ||
| content: 'Last step — Finish closes the tour.', | ||
| side: 'left' | ||
| } | ||
| ]; | ||
|
|
||
| export function TourExamples() { | ||
| const actionsRef = useRef<TourActions>(null); | ||
|
|
||
| return ( | ||
| <PlaygroundLayout title='Tour'> | ||
| <Flex direction='column' gap={7}> | ||
| <Flex gap={3} align='center'> | ||
| <IconButton data-pg-tour='home' size={4} aria-label='Home'> | ||
| <HomeIcon /> | ||
| </IconButton> | ||
| <IconButton data-pg-tour='settings' size={4} aria-label='Settings'> | ||
| <GearIcon /> | ||
| </IconButton> | ||
| <IconButton data-pg-tour='alerts' size={4} aria-label='Alerts'> | ||
| <BellIcon /> | ||
| </IconButton> | ||
| </Flex> | ||
|
|
||
| <Flex direction='column' gap={3} align='start'> | ||
| <Text>Default card, four steps:</Text> | ||
| <Button onClick={() => actionsRef.current?.start()}> | ||
| Start tour | ||
| </Button> | ||
| </Flex> | ||
|
|
||
| <Tour steps={steps} actionsRef={actionsRef} /> | ||
| </Flex> | ||
| </PlaygroundLayout> | ||
| ); | ||
| } | ||
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,95 @@ | ||
| 'use client'; | ||
|
|
||
| import { BarChartIcon, BellIcon, RocketIcon } from '@radix-ui/react-icons'; | ||
| import { | ||
| Button, | ||
| Flex, | ||
| IconButton, | ||
| Search, | ||
| Text, | ||
| Tour, | ||
| type TourActions, | ||
| type TourStep | ||
| } from '@raystack/apsara'; | ||
| import { useRef } from 'react'; | ||
|
|
||
| const panel: React.CSSProperties = { | ||
| padding: 'var(--rs-space-5)', | ||
| border: '1px solid var(--rs-color-border-base-primary)', | ||
| borderRadius: 'var(--rs-radius-3)', | ||
| backgroundColor: 'var(--rs-color-background-base-primary)' | ||
| }; | ||
|
|
||
| const steps: TourStep[] = [ | ||
| { | ||
| id: 'welcome', | ||
| title: 'Welcome aboard', | ||
| content: | ||
| 'A quick tour of the workspace. Use Next to move on, or press Escape to leave any time.' | ||
| }, | ||
| { | ||
| id: 'search', | ||
| target: '[data-tour="search"]', | ||
| title: 'Search anything', | ||
| content: 'Jump to any resource from here. Try typing while the tour runs.', | ||
| side: 'bottom', | ||
| spotlightClicks: true | ||
| }, | ||
| { | ||
| id: 'analytics', | ||
| target: '[data-tour="analytics"]', | ||
| title: 'Track usage', | ||
| content: 'Analytics break down usage across your whole workspace.', | ||
| side: 'bottom' | ||
| }, | ||
| { | ||
| id: 'notifications', | ||
| target: '[data-tour="notifications"]', | ||
| title: 'Stay in the loop', | ||
| content: 'Unread alerts land on the bell. That is the whole tour!', | ||
| side: 'left', | ||
| spotlightRadius: 999, | ||
| spotlightPadding: 6 | ||
| } | ||
| ]; | ||
|
|
||
| export default function TourDemo() { | ||
| const actionsRef = useRef<TourActions>(null); | ||
|
|
||
| return ( | ||
| <Flex direction='column' gap={5} style={{ width: '100%', maxWidth: 640 }}> | ||
| <Flex justify='between' align='center' gap={3} style={panel}> | ||
| <div data-tour='search' style={{ flex: 1, maxWidth: 280 }}> | ||
| <Search size='small' placeholder='Search…' /> | ||
| </div> | ||
| <Flex gap={2} align='center'> | ||
| <IconButton data-tour='analytics' size={4} aria-label='Analytics'> | ||
| <BarChartIcon /> | ||
| </IconButton> | ||
| <IconButton | ||
| data-tour='notifications' | ||
| size={4} | ||
| aria-label='Notifications' | ||
| > | ||
| <BellIcon /> | ||
| </IconButton> | ||
| </Flex> | ||
| </Flex> | ||
|
|
||
| <Flex direction='column' gap={3} align='start' style={panel}> | ||
| <Text size='regular' weight='medium'> | ||
| Guided tour | ||
| </Text> | ||
| <Text size='small' variant='secondary'> | ||
| Four steps: a centered welcome, then the search box, analytics, and | ||
| notifications — each anchored and spotlighted. | ||
| </Text> | ||
| <Button onClick={() => actionsRef.current?.start()}> | ||
| <RocketIcon /> Start tour | ||
| </Button> | ||
| </Flex> | ||
|
|
||
| <Tour steps={steps} actionsRef={actionsRef} /> | ||
| </Flex> | ||
| ); | ||
| } |
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,6 @@ | ||
| 'use client'; | ||
|
|
||
| export const preview = { | ||
| type: 'code', | ||
| code: `<TourDemo />` | ||
| }; |
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Step description doesn't match configured
side.The
settingsstep content claims the popover is "Anchored on the right", butside: 'bottom'places it below the target. This is a reference example for docs, so the mismatch could mislead consumers aboutside/spotlightRadiususage.✏️ Proposed fix
{ id: 'settings', target: '[data-pg-tour="settings"]', title: 'Settings', - content: 'Anchored on the right with a pill spotlight.', - side: 'bottom', + content: 'Anchored below with a pill spotlight.', + side: 'bottom', spotlightRadius: 999, spotlightPadding: 6 },📝 Committable suggestion
🤖 Prompt for AI Agents