diff --git a/docs/walkthrough.md b/docs/walkthrough.md new file mode 100644 index 0000000..6850019 --- /dev/null +++ b/docs/walkthrough.md @@ -0,0 +1,47 @@ +# Grid-Sight Walkthrough Feature + +This document describes the interactive walkthrough feature implemented for the Grid-Sight demo. + +## Overview + +The walkthrough is a guided tour that introduces new users to Grid-Sight's key features. It consists of three steps: + +1. **Introduction**: A centered modal that introduces Grid-Sight and its purpose. +2. **G-S Toggle**: Highlights the Grid-Sight toggle button and prompts the user to click it. +3. **Plus Icons**: Highlights the plus icons and encourages the user to interact with the enrichment menu. + +## Implementation Details + +The walkthrough is implemented using [Shepherd.js](https://shepherdjs.dev/), a lightweight JavaScript library for creating guided tours. The implementation is contained in the demo file (`public/index.html`) and includes: + +- A "Start Walkthrough" button in the header +- Custom styling for the tour to match Grid-Sight's UI +- Event-based advancement that waits for user actions before proceeding +- A custom event listener for the enrichment menu selection + +## Key Features + +- **Event-Based Advancement**: The walkthrough waits for specific user actions before moving to the next step. +- **Interactive Elements**: Users must click the G-S toggle and interact with the plus icons to complete the tour. +- **Custom Styling**: The walkthrough UI is styled to match Grid-Sight's design language. + +## How to Use + +1. Open the Grid-Sight demo page +2. Click the "Start Walkthrough" button in the header +3. Follow the instructions in each step to learn about Grid-Sight's features + +## Technical Notes + +- The walkthrough uses Shepherd.js loaded via CDN +- It listens for custom events (`gridsight:enrichmentSelected`) to detect user interactions +- The tour is configured to use a modal overlay to focus attention on highlighted elements +- Each step includes a `beforeShowPromise` to ensure target elements are available before showing + +## Customization + +To modify the walkthrough: + +1. Edit the `createWalkthrough` function in `public/index.html` +2. Adjust the step content, target elements, or styling as needed +3. Update the event listeners if the interaction model changes diff --git a/package.json b/package.json index 07e418f..973bb87 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ }, "dependencies": { "@types/react": "^19.1.8", + "shepherd.js": "^14.5.0", "simple-statistics": "^7.8.8" } } diff --git a/public/index.html b/public/index.html index 299eb74..22616ec 100644 --- a/public/index.html +++ b/public/index.html @@ -4,6 +4,12 @@ Grid-Sight Demo + + +

Grid-Sight Demo

This page demonstrates the Grid-Sight library automatically processing tables on page load.

+
@@ -158,7 +222,7 @@

Browser Console

- + ' ); + + // Make sure Shepherd.js paths are correct + content = content.replace( + /\s*' + ); // Also update any other relative paths if needed content = content.replace( - /(href|src)="(\.\.?\/)?(assets|images|styles)/g, - '$1="$3"' + /(href|src)="(\.\.?\/)?(?!(http|shepherd))(assets|images|styles)/g, + '$1="$4"' ); await fs.writeFile(demoHtmlPath, content, 'utf8'); console.log('✅ Updated script paths in demo HTML'); diff --git a/src/types/shepherd.d.ts b/src/types/shepherd.d.ts new file mode 100644 index 0000000..452d3cf --- /dev/null +++ b/src/types/shepherd.d.ts @@ -0,0 +1,82 @@ +/** + * Type declarations for Shepherd.js + */ + +declare module 'shepherd.js' { + namespace Shepherd { + interface StepOptions { + id?: string + text?: string | HTMLElement | (() => string | HTMLElement) + title?: string + attachTo?: { + element: string | HTMLElement + on: string + } + beforeShowPromise?: () => Promise + buttons?: Array<{ + text: string + action?: () => void + classes?: string + secondary?: boolean + }> + advanceOn?: { + selector: string + event: string + } + classes?: string + highlightClass?: string + scrollTo?: boolean + cancelIcon?: { + enabled: boolean + } + when?: { + [event: string]: () => void | (() => void) + } + } + + interface TourOptions { + defaultStepOptions?: Partial + useModalOverlay?: boolean + confirmCancel?: boolean + confirmCancelMessage?: string + exitOnEsc?: boolean + keyboardNavigation?: boolean + stepsContainer?: HTMLElement + modalContainer?: string | HTMLElement + steps?: StepOptions[] + } + + class Tour { + constructor(options: TourOptions) + addStep(options: StepOptions): Tour + addStep(id: string, options: StepOptions): Tour + addSteps(steps: StepOptions[]): Tour + back(): void + cancel(): void + complete(): void + getById(id: string): Step + getCurrentStep(): Step + hide(): void + next: () => void + on(event: string, handler: (...args: any[]) => void): void + off(event: string): void + once(event: string, handler: (...args: any[]) => void): void + removeStep(id: string): void + show(id?: string): void + start(): void + } + + class Step { + constructor(tour: Tour, options: StepOptions) + hide(): void + show(): void + isOpen(): boolean + complete(): void + cancel(): void + scrollTo(): void + destroy(): void + } + } + + export default Shepherd +} diff --git a/yarn.lock b/yarn.lock index 6e843f2..793202d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -223,6 +223,26 @@ resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.25.5.tgz#7fc114af5f6563f19f73324b5d5ff36ece0803d1" integrity sha512-TXv6YnJ8ZMVdX+SXWVBo/0p8LTcrUYngpWjvm91TMjjBQii7Oz11Lw5lbDV5Y0TzuhSJHwiH4hEtC1I42mMS0g== +"@floating-ui/core@^1.7.1": + version "1.7.1" + resolved "https://registry.yarnpkg.com/@floating-ui/core/-/core-1.7.1.tgz#1abc6b157d4a936174f9dbd078278c3a81c8bc6b" + integrity sha512-azI0DrjMMfIug/ExbBaeDVJXcY0a7EPvPjb2xAJPa4HeimBX+Z18HK8QQR3jb6356SnDDdxx+hinMLcJEDdOjw== + dependencies: + "@floating-ui/utils" "^0.2.9" + +"@floating-ui/dom@^1.6.12": + version "1.7.1" + resolved "https://registry.yarnpkg.com/@floating-ui/dom/-/dom-1.7.1.tgz#76a4e3cbf7a08edf40c34711cf64e0cc8053d912" + integrity sha512-cwsmW/zyw5ltYTUeeYJ60CnQuPqmGwuGVhG9w0PRaRKkAyi38BT5CKrpIbb+jtahSwUl04cWzSx9ZOIxeS6RsQ== + dependencies: + "@floating-ui/core" "^1.7.1" + "@floating-ui/utils" "^0.2.9" + +"@floating-ui/utils@^0.2.9": + version "0.2.9" + resolved "https://registry.yarnpkg.com/@floating-ui/utils/-/utils-0.2.9.tgz#50dea3616bc8191fb8e112283b49eaff03e78429" + integrity sha512-MDWhGtE+eHw5JW7lq4qhc5yRLS11ERl1c7Z6Xd0a58DozHES6EnNNwUWbMiG4J9Cgj053Bhk8zvlhFYKVhULwg== + "@isaacs/cliui@^8.0.2": version "8.0.2" resolved "https://registry.yarnpkg.com/@isaacs/cliui/-/cliui-8.0.2.tgz#b37667b7bc181c168782259bab42474fbf52b550" @@ -404,6 +424,11 @@ resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.43.0.tgz#42a88207659e404e8ffa655cae763cbad94906ab" integrity sha512-SnGhLiE5rlK0ofq8kzuDkM0g7FN1s5VYY+YSMTibP7CqShxCQvqtNxTARS4xX4PFJfHjG0ZQYX9iGzI3FQh5Aw== +"@scarf/scarf@^1.4.0": + version "1.4.0" + resolved "https://registry.yarnpkg.com/@scarf/scarf/-/scarf-1.4.0.tgz#3bbb984085dbd6d982494538b523be1ce6562972" + integrity sha512-xxeapPiUXdZAE3che6f3xogoJPeZgig6omHEy1rIY5WVsB3H2BHNnZH+gHG6x91SCWyQCzWGsuL2Hh3ClO5/qQ== + "@storybook/addon-backgrounds@9.0.0-alpha.12": version "9.0.0-alpha.12" resolved "https://registry.yarnpkg.com/@storybook/addon-backgrounds/-/addon-backgrounds-9.0.0-alpha.12.tgz#ad75263d15dbe19a69be35e38afa331bce1b6fd0" @@ -1023,6 +1048,11 @@ deep-eql@^5.0.1: resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-5.0.2.tgz#4b756d8d770a9257300825d52a2c2cff99c3a341" integrity sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q== +deepmerge-ts@^7.1.1: + version "7.1.5" + resolved "https://registry.yarnpkg.com/deepmerge-ts/-/deepmerge-ts-7.1.5.tgz#ff818564007f5c150808d2b7b732cac83aa415ab" + integrity sha512-HOJkrhaYsweh+W+e74Yn7YStZOilkoPb6fycpwNLKzSPtruFs48nYis0zy5yJz1+ktUhHxoRDJ27RQAWLIJVJw== + define-lazy-prop@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz#3f7ae421129bcaaac9bc74905c98a0009ec9ee7f" @@ -1633,6 +1663,15 @@ shebang-regex@^3.0.0: resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== +shepherd.js@^14.5.0: + version "14.5.0" + resolved "https://registry.yarnpkg.com/shepherd.js/-/shepherd.js-14.5.0.tgz#200a77ac7197ef0ae2ecc74afbf99569222cca7e" + integrity sha512-23yBjWnrEeaCHFVUukPNol/K0pdvq6NgyqxDeq1qfJuNhxTHpiAvqTB9ULUogndBcGxfkyTRud95PpUyZwGAGQ== + dependencies: + "@floating-ui/dom" "^1.6.12" + "@scarf/scarf" "^1.4.0" + deepmerge-ts "^7.1.1" + siginfo@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/siginfo/-/siginfo-2.0.0.tgz#32e76c70b79724e3bb567cb9d543eb858ccfaf30"