Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | 3x 17x 132x 21x 97x 85x 85x | /**
* Product walkthrough content: which help panels exist and where they show.
*
* Each step is a help panel shown once per user (its id is stored in the
* user's seenSteps). Steps highlight an element tagged with a matching
* `data-tour` attribute; a step whose element is absent or hidden (no active
* flow, missing permission, mobile layout...) is skipped without being marked
* seen, so it shows up the first time the element is there.
*
* Step ids are persisted: renaming one shows its panel again to everyone.
*/
export interface WalkthroughStep {
id: string
/** `data-tour` value of the highlighted element; none = centered panel */
target?: string
/** i18n key prefix: `${key}.title` and `${key}.description` */
key: string
side?: 'top' | 'right' | 'bottom' | 'left'
}
export interface WalkthroughTour {
id: string
/** Route names the tour shows on; '*' = any page of the app */
routes: string[] | '*'
steps: WalkthroughStep[]
}
export const WALKTHROUGH_TOURS: WalkthroughTour[] = [
{
// The app tour: shown first, on whatever page the user lands on
id: 'welcome',
routes: '*',
steps: [
{ id: 'welcome.intro', key: 'walkthrough.steps.welcome' },
{
id: 'welcome.flowSwitcher',
target: 'flow-switcher',
key: 'walkthrough.steps.flowSwitcher',
side: 'right'
},
{ id: 'welcome.navigation', target: 'navigation', key: 'walkthrough.steps.navigation' },
{
id: 'welcome.messages',
target: 'messages',
key: 'walkthrough.steps.messages',
side: 'bottom'
},
{
id: 'welcome.notifications',
target: 'notifications',
key: 'walkthrough.steps.notifications',
side: 'bottom'
},
{
id: 'welcome.account',
target: 'account-menu',
key: 'walkthrough.steps.account',
side: 'bottom'
},
{
id: 'welcome.pageInfo',
target: 'page-info',
key: 'walkthrough.steps.pageInfo',
side: 'bottom'
}
]
},
{
id: 'flows',
routes: ['flows'],
steps: [
{
id: 'flows.create',
target: 'flows-create',
key: 'walkthrough.steps.flowsCreate',
side: 'bottom'
}
]
},
{
id: 'entities',
routes: ['entities'],
steps: [
{
id: 'entities.create',
target: 'entities-create',
key: 'walkthrough.steps.entitiesCreate',
side: 'bottom'
},
{
id: 'entities.import',
target: 'entities-import',
key: 'walkthrough.steps.entitiesImport',
side: 'bottom'
}
]
},
{
id: 'items',
routes: ['entity-items'],
steps: [
{
id: 'items.create',
target: 'items-create',
key: 'walkthrough.steps.itemsCreate',
side: 'bottom'
},
{
id: 'items.export',
target: 'items-export',
key: 'walkthrough.steps.itemsExport',
side: 'bottom'
}
]
},
{
id: 'catalog',
routes: ['catalog'],
steps: [
{
id: 'catalog.search',
target: 'catalog-search',
key: 'walkthrough.steps.catalogSearch',
side: 'bottom'
}
]
},
{
id: 'moderation',
routes: ['moderation'],
steps: [
{
id: 'moderation.standing',
target: 'moderation-standing',
key: 'walkthrough.steps.moderationStanding',
side: 'bottom'
}
]
},
{
id: 'members',
routes: ['members'],
steps: [
{
id: 'members.invite',
target: 'members-invite',
key: 'walkthrough.steps.membersInvite',
side: 'bottom'
}
]
},
{
id: 'roles',
routes: ['roles'],
steps: [
{
id: 'roles.create',
target: 'roles-create',
key: 'walkthrough.steps.rolesCreate',
side: 'bottom'
}
]
},
{
id: 'profile',
routes: ['profile'],
steps: [
{
id: 'profile.walkthrough',
target: 'profile-walkthrough',
key: 'walkthrough.steps.profileWalkthrough',
side: 'top'
}
]
}
]
/** Steps that may show on a route, the app tour first, in tour order. */
export function stepsForRoute(
routeName: string | null | undefined,
tours: WalkthroughTour[] = WALKTHROUGH_TOURS
): WalkthroughStep[] {
return tours
.filter(
(tour) => tour.routes === '*' || (!!routeName && tour.routes.includes(String(routeName)))
)
.flatMap((tour) => tour.steps)
}
/** The element a step highlights, or null when absent or not visible. */
export function findStepElement(
step: WalkthroughStep,
root: ParentNode = document
): Element | null {
if (!step.target) return null
const candidates = Array.from(root.querySelectorAll(`[data-tour="${step.target}"]`))
// getClientRects() is empty for display:none elements and their descendants
return candidates.find((el) => el.getClientRects().length > 0) ?? null
}
|