Enhance heat map with additional token probability, add storybook #100
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.
Add Storybook Support for Heatmap Components
Overview
This PR introduces Storybook integration to the project, enabling isolated development and testing of UI components. The initial focus is on the Heatmap visualization components used by Logit Lens, with comprehensive stories and mock providers to support interactive development.
Key Changes
Storybook Setup
Configuration: Added
.storybook/directory with:main.ts: Storybook configuration using@storybook/nextjs-viteframeworkpreview.tsx: Global decorators and parameters for all storiesvitest.setup.ts: Test setup for Storybook integrationdb-client.ts,dotenv.ts)Addons: Integrated essential Storybook addons:
@chromatic-com/storybook- Visual testing@storybook/addon-vitest- Component testing@storybook/addon-a11y- Accessibility testing@storybook/addon-docs- Documentation@storybook/addon-onboarding- Getting started guideVite Configuration: Custom Vite plugin to mock server-side dependencies (
better-sqlite3,postgres,dotenv) that aren't compatible with browser environmentsHeatmap Component Stories
Heatmap.stories.tsx: Standalone Heatmap component stories with various data configurations
HeatmapCard.stories.tsx: Full HeatmapCard stories with all context providers
Mock Providers: Created Storybook-specific mock providers:
MockHeatmapDataProvider- Provides mock heatmap dataMockHeatmapCanvasProvider- Handles canvas overlay functionalityMockHeatmapHoverProvider- Manages hover stateMockViewProvider- Mocks view persistence (no backend required)StorybookHeatmapCard- Wrapper component for Storybook storiesStorybookTokenPopover- Storybook version of TokenPopoverMock Data: Comprehensive mock data generator (
mockData.ts) for testing various heatmap scenariosMock Hooks: Custom hooks for Storybook (
useMockSelection.tsx,useMockAnnotationSelection.ts)Component Updates
TokenPopover: New component replacing the simpler
TooltipcomponentmaxTokensprop (default: 10)Heatmap.tsx: Minor updates to support Storybook integration
Testing Infrastructure
vitest.config.tswith Storybook test integrationScripts
npm run storybook- Start Storybook dev server on port 6006npm run build-storybook- Build static Storybook siteOther Changes
.gitignoreto exclude Storybook build artifactsButton,Header,Page) from Storybook onboardingNext steps