Repository navigation
Enhancement: Complete base package scaffolding - #16
ViewFromTheBox merged 1 commit into
Conversation
Add feedback component category directory with barrel export, tsup entry point, and package.json sub-path export. Create ThemeProvider context and useTheme hook for color scheme management (light/dark/system with media query listener). Export ColorScheme and ThemeContextValue types. Fix test-setup.ts hoisting issue with @testing-library/jest-dom. Add 8 tests covering all ThemeProvider behavior. Closes #3
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThis pull request introduces a new theme management system via a React context-based Changes
Sequence DiagramsequenceDiagram
participant Component
participant ThemeProvider
participant ThemeContext as Context<ThemeContextValue>
participant MediaQuery as window.matchMedia
Component->>ThemeProvider: Mount with optional defaultColorScheme
ThemeProvider->>MediaQuery: Call matchMedia('(prefers-color-scheme: dark)')
MediaQuery-->>ThemeProvider: Return MediaQueryList with matches state
ThemeProvider->>ThemeContext: Initialize with resolvedColorScheme based on matches
ThemeProvider->>MediaQuery: Subscribe to 'change' events
ThemeProvider-->>Component: Provide context (colorScheme, resolvedColorScheme, setColorScheme)
alt System Preference Change
MediaQuery->>ThemeProvider: Emit change event
ThemeProvider->>ThemeContext: Update resolvedColorScheme (if colorScheme === 'system')
ThemeContext-->>Component: Re-render with new resolvedColorScheme
end
alt Manual Color Scheme Switch
Component->>ThemeProvider: Call setColorScheme('dark')
ThemeProvider->>ThemeContext: Update colorScheme, unsubscribe from matchMedia
ThemeContext-->>Component: Re-render with new values
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Description
Completes the remaining items from the base package scaffolding (issue #3): adds the feedback component category directory, creates shared hooks and context providers (ThemeProvider + useTheme), and fixes a pre-existing test setup issue.
Closes: #3
Type of Change
Related Issue
Issue: #3
Motivation and Context
Issue #3 was mostly complete but missing two items: the feedback component category directory and shared hooks/context providers (ThemeProvider). These are needed before individual component work can begin.
Changes Made
feedback/component category with barrel export, tsup entry point, and@artisanpack-ui/react/feedbacksub-path exportThemeProvidercontext anduseThemehook supporting light/dark/system color schemes withprefers-color-schememedia query listenerThemeProvider,useTheme,ThemeContextValue, andColorSchemefrom package indextest-setup.ts— resolved npm workspace hoisting issue where@testing-library/jest-dom/vitestcouldn't resolve vitest from hoisted location; switched to explicit matcher extensionHow Has This Been Tested?
Testing Environment:
Tests Performed:
npm testfrom monorepo root — all 82 tests pass (74 tokens + 8 react)npm run lint— cleannpm run format:checkon react package files — cleanAccessibility Tests Run
Details: N/A — no UI components in this PR (foundational code only)
Tests Added
Test details: 8 tests in
use-theme.test.tsxcovering: default system scheme, initial dark system preference detection, custom default scheme, manual switching, system preference media query changes, manual override ignoring system changes, switching back to system mode, error when used outside providerDocumentation
Documentation details: JSDoc comments on all exported types, interfaces, and functions. README/wiki updates deferred to component implementation PRs.
Pre-Submission Checklist
Summary by CodeRabbit
New Features
ThemeProvidercomponent anduseThemehook supporting light, dark, and system color scheme preferences.Tests
Chores