Merged
Conversation
Contributor
Author
|
@mijinummi can you review the pr please |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🎨 Theming Engine for BridgeWise dApp Integration
Overview
Implements a comprehensive theming system for BridgeWise that enables external developers to easily customize UI components through CSS variables and Tailwind configuration injection. This addresses Issue #4 - Theming Engine for 'Plug-and-Play' dApp Integration.
📋 Summary of Changes
Core Features Delivered
✅ Dark Mode Support - System preference detection with manual override capability
✅ Headless Components - Unstyled component versions for maximum customization
✅ Type-Safe Theme API - Full TypeScript support with intelligent autocomplete
✅ SSR Ready - No flash of unstyled content on page load
✅ Framework Agnostic - CSS variables work with any styling approach
🏗️ Architecture
1. Theme Infrastructure (
libs/ui-components/src/theme/)Token System - Two-tier semantic design tokens
Token Categories:
colors- Background, foreground, borders, status, component-specificspacing- Consistent spacing scale (xs → 2xl)typography- Font families, sizes, weights, line heightsshadows- Elevation effects (sm → xl)radii- Border radius values (none → full)transitions- Animation timing and easingType System (
types.ts)DeepPartial<Theme>utility type for partial theme customizationUtilities (
utils/)merge-theme.ts- Deep merge function for combining themescss-vars.ts- Generates CSS custom properties from theme tokens2. ThemeProvider Component
Location:
libs/ui-components/src/theme/ThemeProvider.tsxFeatures:
prefers-color-schemebridgewise-theme-mode)suppressHydrationWarningclassordata-theme)Props API:
3. SSR Flash Prevention
Location:
libs/ui-components/src/theme/ThemeScript.tsxInline script component that runs before React hydration to:
<html>element immediately4. Global Styling
Location:
libs/ui-components/src/styles/globals.css@media (prefers-color-scheme: dark)fallback styles--bw-*prefix)@theme inlinedirective🧩 Component Migration
TransactionHeartbeat - Complete Refactor
Migrated existing component to ui-components library with three versions:
1. Styled Version (Default Export)
File:
libs/ui-components/src/components/TransactionHeartbeat/TransactionHeartbeat.tsxstyle={{ backgroundColor: 'var(--bw-colors-transaction-background)' }}2. Headless Version (Maximum Flexibility)
File:
libs/ui-components/src/components/TransactionHeartbeat/TransactionHeartbeat.headless.tsxstate,clearState,updateState,startTransaction,isSuccess,isFailed,isPendingUsage Example:
3. Context Provider
File:
libs/ui-components/src/components/TransactionHeartbeat/TransactionContext.tsxuseTransactionhook for accessing state anywhere in the app📦 Package Structure
Updated
libs/ui-components/package.jsonwith proper exports:{ "exports": { ".": "./src/index.ts", // Main exports "./theme": "./src/theme/index.ts", // Theme system "./headless": "./src/components/headless/index.ts", // Headless components "./styles/globals.css": "./src/styles/globals.css" // CSS variables } }🔧 Integration Changes
Web App Updates
Layout (
apps/web/app/layout.tsx)Global Styles (
apps/web/app/globals.css)Component Imports (
apps/web/app/page.tsx)📚 Documentation & Examples
Created comprehensive examples in
/examples:1. Custom Theme Configuration (
custom-theme.example.tsx)Shows how to customize colors, spacing, and typography:
2. Headless Components (
headless-component.example.tsx)Three different custom notification styles:
3. Theme Toggle Controls (
theme-toggle.example.tsx)Five different theme switcher implementations:
🎯 Developer Experience
For External Developers
Basic Integration
Custom Theme
CSS Variable Overrides
TypeScript Support
Full type safety with autocomplete for:
✅ Testing & Verification
Build Status
Manual Testing Checklist
<html>elementBrowser Testing
Tested and verified on:
🔄 Migration Path
Backwards Compatibility
Deprecated (to be removed in future)
/apps/web/components/ui-lib/TransactionHeartbeat.tsx/apps/web/components/ui-lib/context/TransactionContext.tsx/apps/web/components/ui-lib/hooks/useTransactionPersistence.tsNote: These files should be removed after confirming all references use the new
@bridgewise/ui-componentsimports.📊 File Changes Summary
New Files (16)
Theme System:
libs/ui-components/src/theme/tokens/primitives.tslibs/ui-components/src/theme/tokens/defaults.tslibs/ui-components/src/theme/tokens/dark.tslibs/ui-components/src/theme/tokens/index.tslibs/ui-components/src/theme/types.tslibs/ui-components/src/theme/utils/merge-theme.tslibs/ui-components/src/theme/utils/css-vars.tslibs/ui-components/src/theme/utils/index.tslibs/ui-components/src/theme/ThemeProvider.tsxlibs/ui-components/src/theme/ThemeScript.tsxlibs/ui-components/src/theme/hooks/useTheme.tslibs/ui-components/src/theme/index.tsComponents:
libs/ui-components/src/components/TransactionHeartbeat/TransactionHeartbeat.tsxlibs/ui-components/src/components/TransactionHeartbeat/TransactionHeartbeat.headless.tsxlibs/ui-components/src/components/TransactionHeartbeat/TransactionContext.tsxlibs/ui-components/src/components/TransactionHeartbeat/index.tsStyles:
libs/ui-components/src/styles/globals.cssExports:
libs/ui-components/src/index.tslibs/ui-components/src/components/headless/index.tsExamples:
examples/custom-theme.example.tsxexamples/headless-component.example.tsxexamples/theme-toggle.example.tsxModified Files (4)
libs/ui-components/package.json- Added exports configurationapps/web/app/layout.tsx- Integrated ThemeProvider and TransactionProviderapps/web/app/globals.css- Import ui-components stylesapps/web/app/page.tsx- Updated imports to use new package🚀 Future Enhancements
Short Term
Long Term
📝 Breaking Changes
None - This is a purely additive change with full backwards compatibility.
🙏 Acknowledgments
🔗 Related Links
Close #4