How gilbarbara/react-joyride works
Project type and purpose
• React Joyride is an open-source React UI library for building guided tours and product onboarding flows.
• It provides reusable components (beacons, tooltips, overlays, spotlights) and core logic (step management, state store, DOM targeting).
File structure
• Top-level directories:
• src/ – all library source code: components, modules, types, styles, defaults
• docs/ – markdown docs for end users
• e2e/ – end-to-end tests (Playwright CT)
• test/ – unit tests and fixtures (Vitest)
• scripts/ – build & maintenance scripts (e.g., fix-cjs)
• .github/, husky/, CI config – continuous integration & quality gating
• Configuration files: package.json, tsconfig.json, Playwright and Vitest configs, Sonar & lint settings.
README for additional insights
• Usage example showing how an application imports Joyride, passes a steps array, and renders the component.
• References to react-floater for positioning and optional polyfills for legacy browser support.
• Development flow: npm link, watch builds, demo app integration.
Main components
a. Consumer application (the host app)
b. Joyride entry point (src/index.tsx → Joyride component)
c. Internal modules / logic layer (src/modules: store, dom, step, helpers, scope)
d. UI components (src/components: Beacon, Overlay, Spotlight, Tooltip, Portal)
e. Styling & defaults (src/styles.ts, src/defaults.ts)
f. External dependencies: React, react-floater, scrollingelement polyfill
g. Build & packaging pipeline (scripts/fix-cjs, bundler, watch, output to dist/)
h. Test suites: unit tests (Vitest), e2e tests (Playwright CT)
i. Documentation site (docs/, book.json, docs build)
Relationships and interactions
• Consumer App → imports Joyride → passes steps & config props
• Joyride component → initializes module layer (store, scope, step controller)
• Module layer → computes current step, listens for events, reads DOM targets via dom module
• Joyride → renders UI components via React Portal into document.body
• UI components → Beacon & Spotlight highlight target elements, Overlay dims background, Tooltip renders content (using react-floater)
• Styling definitions & default props feed into components
• Build pipeline transforms src/ → distributed package; CI runs tests & publishes docs.
Architectural patterns & design principles
• Unidirectional data flow: props → store → modules → render
• Component composition: Joyride wraps modular pieces (Beacon, Overlay, Tooltip)
• Separation of concerns: logic (modules/) vs. presentation (components/) vs. types vs. styles
• Extensibility: custom components via props, external polyfills support legacy browsers