### Local Development Setup Source: https://github.com/baybreezy/nuxt-tour/blob/main/CONTRIBUTING.md Steps to clone the repository, install dependencies, build the module stub, and start the documentation development server for local testing. ```bash git clone https://github.com/BayBreezy/nuxt-tour.git cd nuxt-tour bun install bun run dev:prepare bun run dev ``` -------------------------------- ### Start Docs Development Server Directly Source: https://github.com/baybreezy/nuxt-tour/blob/main/docs/README.md Navigate to the docs directory, install dependencies, and start the docs development server. ```bash cd docs bun install bun run dev ``` -------------------------------- ### Install Dependencies and Build Module Source: https://github.com/baybreezy/nuxt-tour/blob/main/docs/README.md Install dependencies, build the module stub, and start the docs development server from the repository root. ```bash bun install bun run dev:prepare bun run dev ``` -------------------------------- ### Conditionally Start Tour Based on User State Source: https://github.com/baybreezy/nuxt-tour/blob/main/_autodocs/api-reference/use-tour-composable.md This example demonstrates how to conditionally start an onboarding tour only for new users who have not completed it before. It uses `onMounted` to check user state and `isPlayed` to ensure the tour isn't shown again. ```vue ``` -------------------------------- ### Highlight Example with VTour Source: https://github.com/baybreezy/nuxt-tour/blob/main/docs/content/02.examples/highlight.md This example demonstrates how to use the `VTour` component with the `highlight` and `backdrop` props enabled to visually focus the current target element. The tour automatically starts on page load and can be restarted. ```vue ``` -------------------------------- ### Start Docs Dev Server Source: https://github.com/baybreezy/nuxt-tour/blob/main/CLAUDE.md Start the documentation development server, which also serves as a playground for manual testing. ```bash # Start the docs dev server (docs/ is the playground for manual testing) bun run dev ``` -------------------------------- ### Install Nuxt Tour Source: https://github.com/baybreezy/nuxt-tour/blob/main/_autodocs/INDEX.md Install the nuxt-tour module using npm. ```bash npm install nuxt-tour ``` -------------------------------- ### CallbacksEmitsExample.vue Source: https://github.com/baybreezy/nuxt-tour/blob/main/docs/content/02.examples/callbacks-emits.md This example demonstrates how to listen to VTour lifecycle events using Vue's emit system. It displays notifications for tour start, end, skip, and step changes. The tour is automatically started on component mount. ```vue ``` -------------------------------- ### start() Source: https://github.com/baybreezy/nuxt-tour/blob/main/_autodocs/api-reference/use-tour-composable.md Starts the tour from the first step or resumes from a saved step. It respects localStorage completion status and TTL settings, automatically skipping the tour if already played and not expired. ```APIDOC ## start() ### Description Starts the tour from the first step or resumes from a saved step. It respects localStorage completion status and TTL settings, automatically skipping the tour if already played and not expired. ### Signature ```ts start(): Promise ``` ### Behavior - If called before the component mounts, sets `_pendingStart = true` and the component picks it up on mount. - If called after the component mounts, calls the component's `startTour()` directly. - Respects localStorage completion status and TTL settings. ### Example ```ts const { start, isPlayed } = useTour("onboarding"); const tourBtn = ref(null); onMounted(() => { if (!isPlayed.value) { await start(); } }); // Or via a button: const replayTour = async () => { await reset(); // Clear localStorage await start(); // Start fresh }; ``` ``` -------------------------------- ### Start Tour Before Component Mount Source: https://github.com/baybreezy/nuxt-tour/blob/main/_autodocs/errors.md Methods like `start()` can be called before the component mounts. They are queued and picked up upon mount. This is the intended pattern for initiating tours early. ```typescript const { start } = useTour('onboarding') // Calling before component mounts await start() // Sets _pendingStart = true, component picks it up on mount // Component mounts later // ``` -------------------------------- ### Custom Button Configuration Example Source: https://github.com/baybreezy/nuxt-tour/blob/main/docs/content/02.examples/button.md Demonstrates how to configure custom labels and icons for each tour button (skip, next, previous, finish) using the ButtonConfig object. This example shows a complete Vue component setup for a tour with these custom buttons. ```vue ``` -------------------------------- ### Storage Schema Example Source: https://github.com/baybreezy/nuxt-tour/blob/main/_autodocs/configuration.md Example of the structure for tour state stored in localStorage. ```json { "nt-onboarding": { "completed": true, "status": "completed", "completedAt": "2024-06-24T10:30:00.000Z", "lastStep": 4, "version": "v1" } } ``` -------------------------------- ### Vue Transition Example Source: https://github.com/baybreezy/nuxt-tour/blob/main/docs/content/02.examples/transition.md This Vue component demonstrates how to use the `transition` prop with Nuxt Tour. It allows users to select from various transition animations and preview them by starting a tour. The component includes buttons to select transitions, tour steps, and controls to start or reset the tour. ```vue ``` -------------------------------- ### Install Nuxt Tour with npm or bun Source: https://github.com/baybreezy/nuxt-tour/blob/main/README.md Install the nuxt-tour package using either npm or bun package managers. ```bash # npm npm install nuxt-tour # bun bun add nuxt-tour ``` -------------------------------- ### Start Tour via Template Ref Source: https://github.com/baybreezy/nuxt-tour/blob/main/docs/content/01.getting-started/5.methods.md Demonstrates starting a tour using a template ref on the VTour component. The `startTour` method is called from a button click event. ```vue ``` -------------------------------- ### Start Tour Source: https://github.com/baybreezy/nuxt-tour/blob/main/_autodocs/api-reference/use-tour-composable.md Starts the tour from the first step or resumes from a saved step. It respects localStorage completion status and TTL settings. Call before component mount to defer execution. ```typescript const { start, isPlayed } = useTour("onboarding"); const tourBtn = ref(null); onMounted(async () => { if (!isPlayed.value) { await start(); } }); // Or via a button: const replayTour = async () => { await reset(); // Clear localStorage await start(); // Start fresh }; ``` -------------------------------- ### Full Nuxt Tour Usage Example Source: https://github.com/baybreezy/nuxt-tour/blob/main/_autodocs/api-reference/tour-component.md A complete Vue.js component demonstrating the integration of the VTour component. It includes step definitions, event handlers for tour lifecycle, and template setup. ```vue ``` -------------------------------- ### Manual Tour Start with Button Source: https://github.com/baybreezy/nuxt-tour/blob/main/_autodocs/quick-reference.md Control tour initiation via a button click. Use `useTemplateRef` to get a reference to the VTour component and call its `startTour` method. ```vue ``` -------------------------------- ### Composable Tour Example Source: https://github.com/baybreezy/nuxt-tour/blob/main/docs/content/02.examples/composable.md Demonstrates how to use the `useTour()` composable to control a tour. It displays reactive tour state and provides buttons to start, end, and reset the tour. The tour steps are defined with targets, titles, and bodies, utilizing various elements within the component for interaction. ```vue ``` -------------------------------- ### Custom Progress Indicator with Slot Source: https://github.com/baybreezy/nuxt-tour/blob/main/docs/content/02.examples/progress.md This example shows how to use the `#progress` slot to create a fully custom progress indicator for the tour. It displays the current step, total steps, and a visual progress bar. The tour automatically starts on page load. ```vue ``` -------------------------------- ### Nuxt Tour: Start Tour Method Source: https://github.com/baybreezy/nuxt-tour/blob/main/_autodocs/api-reference/tour-component.md Use the `startTour` method to programmatically initialize and display the tour. It handles skipping if the tour was previously completed. ```typescript const tourRef = useTemplateRef("tour"); await tourRef.value?.startTour(); ``` -------------------------------- ### Conventional Commit Message Examples Source: https://github.com/baybreezy/nuxt-tour/blob/main/CONTRIBUTING.md Examples illustrating the Conventional Commits format for commit messages, including types and scopes. ```bash feat: add saveToLocalStorage prop fix: prevent useScrollLock crash in SSR docs: document useTour composable chore: bump @vueuse to v14.4.0 ``` -------------------------------- ### Custom Styles Example Source: https://github.com/baybreezy/nuxt-tour/blob/main/_autodocs/configuration.md Example of overriding default tour styles using CSS custom properties. ```css #nt-tooltip { --nt-bg: #1e1e2e; --nt-text: #cdd6f4; /* ... */ } ``` -------------------------------- ### Sequential Tours Source: https://github.com/baybreezy/nuxt-tour/blob/main/_autodocs/quick-reference.md Start tours one after another, ensuring the previous one is completed or played before proceeding. This is useful for guided user flows. ```typescript const tour1 = useTour("intro"); const tour2 = useTour("basics"); const startSequence = async () => { if (!tour1.isPlayed.value) { await tour1.start(); // tour1 emits tour:end when done } else if (!tour2.isPlayed.value) { await tour2.start(); } }; ``` -------------------------------- ### next() Source: https://github.com/baybreezy/nuxt-tour/blob/main/_autodocs/api-reference/use-tour-composable.md Moves the tour to the next step. If the tour is not currently running, it will be started first. ```APIDOC ## next() ### Description Moves the tour to the next step. If the tour is not currently running, it will be started first. ### Signature ```ts next(): Promise ``` ### Example ```ts const { next } = useTour("onboarding"); const handleKeyDown = (e: KeyboardEvent) => { if (e.key === 'ArrowRight') next(); }; ``` ``` -------------------------------- ### Start Tour via Composable Source: https://github.com/baybreezy/nuxt-tour/blob/main/docs/content/01.getting-started/3.create-tour.md Control tour playback using the `useTour` composable, allowing you to start, check play status, and reset tours from any component, even before the `` component mounts. ```vue ``` -------------------------------- ### Storage Entry After Version Update Source: https://github.com/baybreezy/nuxt-tour/blob/main/_autodocs/configuration.md Example of the localStorage entry after the `storageVersion` has been updated and a tour is replayed. ```json { "nt-onboarding": { "completed": true, "status": "completed", "completedAt": "2024-06-25T14:20:00.000Z", "lastStep": 4, "version": "v2" } } ``` -------------------------------- ### HTML Element Targeting Example Source: https://github.com/baybreezy/nuxt-tour/blob/main/docs/content/02.examples/html-elements.md This Vue component demonstrates how to use direct HTMLElement references for tour step targets. It assigns elements in `onMounted` and uses computed properties for tour steps. The tour automatically starts on page load. ```vue ``` -------------------------------- ### Nuxt Tour: Go To Step Method Source: https://github.com/baybreezy/nuxt-tour/blob/main/_autodocs/api-reference/tour-component.md Jump to a specific step by its zero-based index using `goToStep`. If the tour is not active, it will be started first. ```typescript await tourRef.value?.goToStep(2); ``` -------------------------------- ### Wait for DOM elements before starting VTour Source: https://github.com/baybreezy/nuxt-tour/blob/main/_autodocs/quick-reference.md Ensure tour elements are rendered before the tour starts, especially when using `auto-start`. Use `start-delay` or handle element rendering asynchronously. ```typescript // ❌ Tour may start before elements render // ✓ Wait for elements with async steps or delay ``` -------------------------------- ### Auto-start Tour on Mount Source: https://github.com/baybreezy/nuxt-tour/blob/main/docs/content/01.getting-started/3.create-tour.md Configure the VTour component to automatically start when the component mounts by using the `auto-start` prop. You can also specify a `start-delay` in milliseconds. ```vue ``` ```vue ``` -------------------------------- ### TourStep Usage Examples Source: https://github.com/baybreezy/nuxt-tour/blob/main/_autodocs/types.md Illustrates various ways to define TourStep objects, from minimal configurations to reactive targets, callbacks, custom slots, and Popper.js integration. ```typescript const steps: TourStep[] = [ // Minimal step { target: '.hero', title: 'Welcome', body: 'This is the hero section', }, // Centered step (no target) { title: 'Important', body: 'This message floats in the center', }, // Reactive target { target: computed(() => selectedElement.value ? '#' + selectedElement.value.id : null), title: 'Dynamic target', body: 'This follows a reactive element', }, // With callbacks { target: '.submit-btn', title: 'Submit', body: 'Click to submit the form', onNext: async () => { // Validate form before next step if (!await validateForm()) { return false // Abort step transition } }, onShow: () => { console.log('Step shown!') }, }, // Custom slots { target: '.card', title: 'Cards', body: 'Learn about cards', slot: 'cards', // Allows #cards-header, #cards-body slots }, // With Popper.js config { target: '.tooltip-me', title: 'Custom placement', body: 'This tooltip uses custom Popper config', popperConfig: { placement: 'left', modifiers: [ { name: 'offset', options: { offset: [0, 20] } }, ], }, }, ] ``` -------------------------------- ### Custom Actions Slot Example Source: https://github.com/baybreezy/nuxt-tour/blob/main/docs/content/01.getting-started/6.slots.md Replace all action buttons at once using the '#intro-actions' slot. It provides nextStep, prevStep, isLastStep, and endTour functions. ```vue ``` -------------------------------- ### Configuring Nuxt Tour with TypeScript Source: https://github.com/baybreezy/nuxt-tour/blob/main/_autodocs/configuration.md Example of how to configure Nuxt Tour using TypeScript, ensuring type safety with the `TourOptions` interface. This configuration is then passed to the Nuxt config. ```typescript import type { TourOptions } from "nuxt-tour"; const config: TourOptions = { prefix: "V", injectCSS: true, storagePrefix: "nt", storageVersion: "v1", }; export default defineNuxtConfig({ modules: ["nuxt-tour"], tour: config, }); ``` -------------------------------- ### Custom Body Slot Example Source: https://github.com/baybreezy/nuxt-tour/blob/main/docs/content/01.getting-started/6.slots.md Customize the main content area of the tour step using the '#intro-body' slot. It receives the step definition object. ```vue ``` -------------------------------- ### Example Usage of PopperConfig in TourStep Source: https://github.com/baybreezy/nuxt-tour/blob/main/_autodocs/types.md Demonstrates how to use the popperConfig property within a TourStep to customize the positioning and behavior of tooltips. This allows for fine-grained control over placement and fallback options. ```typescript const steps: TourStep[] = [ { target: '.element', title: 'Custom position', popperConfig: { placement: 'right', modifiers: [ { name: 'offset', options: { offset: [0, 20] } }, { name: 'flip', options: { fallbackPlacements: ['left', 'top'] } }, ], }, }, ] ``` -------------------------------- ### Tracking Tour Step Changes with Analytics Source: https://github.com/baybreezy/nuxt-tour/blob/main/docs/content/01.getting-started/7.emits.md An example of using the `@tour:step-change` event to track user progression through tour steps, sending data to an analytics service. ```vue ``` -------------------------------- ### Show Replay Button After Tour Completion Source: https://github.com/baybreezy/nuxt-tour/blob/main/_autodocs/api-reference/use-tour-composable.md This example shows how to display a 'Replay Tour' button only after a tour has been played and is no longer active. It utilizes `isPlayed` and `isActive` states from the composable. ```vue ``` -------------------------------- ### Build Module Stub Source: https://github.com/baybreezy/nuxt-tour/blob/main/CLAUDE.md Run this before anything else after a fresh clone to build the module stub. ```bash # Build the module stub (run this before anything else after a fresh clone) bun run dev:prepare ``` -------------------------------- ### Per-Step Transitions Example Source: https://github.com/baybreezy/nuxt-tour/blob/main/docs/content/02.examples/transition.md Demonstrates how to set individual transition properties for each step in a tour. Steps without a specific transition will fall back to the tour's default or the 'fade' transition. ```vue ``` -------------------------------- ### Vue Component for Autostart Tour Source: https://github.com/baybreezy/nuxt-tour/blob/main/docs/content/02.examples/autostart.md This Vue component demonstrates how to use the `auto-start` prop to initiate a tour automatically upon component mount. It includes tour steps and a button to manually restart the tour. ```vue ``` -------------------------------- ### Create a Tour Popper Instance Source: https://github.com/baybreezy/nuxt-tour/blob/main/_autodocs/api-reference/scroll-popper-utilities.md Initializes a new Popper.js instance for tour tooltips. Call `.update()` to reposition and `.destroy()` to clean up. ```typescript import { createTourPopper } from '#nuxt-tour/utils/popper' const tooltip = document.getElementById('nt-tooltip') const target = document.querySelector('.my-element') const popperInstance = createTourPopper(target, tooltip) // Later, update positioning await popperInstance.update() // Clean up popperInstance.destroy() ``` -------------------------------- ### Manage Multiple Tours Simultaneously Source: https://github.com/baybreezy/nuxt-tour/blob/main/_autodocs/api-reference/use-tour-composable.md This example illustrates how to manage multiple independent tours within an application. It shows how to instantiate `useTour` for different tour names and filter them based on their `isPlayed` status. ```vue ``` -------------------------------- ### Listening to Tour Events Source: https://github.com/baybreezy/nuxt-tour/blob/main/docs/content/01.getting-started/7.emits.md Demonstrates how to listen to various tour events such as start, end, skip, and step change using Vue's template syntax and corresponding handler functions in the script. ```vue ``` -------------------------------- ### Run All Tests Source: https://github.com/baybreezy/nuxt-tour/blob/main/CLAUDE.md Execute all tests for the project. ```bash # Run all tests bun run test ``` -------------------------------- ### Unit Test useTour Composable Source: https://github.com/baybreezy/nuxt-tour/blob/main/_autodocs/quick-reference.md Write unit tests for the `useTour` composable to verify its functionality, such as starting a tour or tracking its completion status. Note that starting a tour might require a mounted component. ```typescript import { useTour } from "#nuxt-tour/composables"; import { describe, it, expect } from "vitest"; describe("useTour", () => { it("starts a tour", async () => { const { isActive, start } = useTour("test"); expect(isActive.value).toBe(false); // await start(); // Note: requires component to be mounted }); it("tracks completion", () => { const { isPlayed, markPlayed, markUnplayed } = useTour("test"); markPlayed(); expect(isPlayed.value).toBe(true); markUnplayed(); expect(isPlayed.value).toBe(false); }); }); ```