Step-by-step plan to migrate from single HTML file to TypeScript + Vite modular architecture with saved texts and small window optimization.
- Initialize npm project
- Install Vite and TypeScript
- Create folder structure
- Set up configuration files
- Verify build process works
- Create index.html shell
- Implement responsive layout CSS
- Create placeholder components
- Test small window display (300x400px)
- Implement collapsible sections
- Add vertical scrollbar for text input area
- Ensure proper overflow handling for main window
- Port Reader component
- Port text processing utilities
- Implement word display animation
- Add keyboard shortcuts
- Test reading functionality
- Port Controls component
- Implement Progress component
- Add speed controls
- Implement play/pause/navigation
- Optimize for touch/small screens
- Create SavedTexts component
- Implement storage utilities
- Add horizontal scrolling UI
- Implement save/load/delete
- Add resume position feature
- Create TextInput component
- Add collapse/expand functionality
- Implement auto-save drafts
- Add save shortcuts (Ctrl+S)
- Test with various text sizes
- Fine-tune small window layout
- Add loading states
- Implement error handling
- Performance optimization
- Cross-browser testing
- Create migration guide
- Build production version
- Test deployment
- Update documentation
- Archive old HTML version
npm init -ynpm install -D vite typescript @types/nodemkdir -p src/{components,utils}
touch src/{main.ts,types.ts,styles.css}
touch index.html vite.config.ts tsconfig.json// tsconfig.json
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"strict": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true
},
"include": ["src"]
}// vite.config.ts
import { defineConfig } from 'vite'
export default defineConfig({
server: {
port: 3000
}
}){
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
}
}- Minimal HTML shell
- Viewport meta for mobile
- Link to main.ts
- CSS Grid for main layout
- Mobile-first approach
- CSS custom properties for theming
- Vertical scrollbar for text input area (overflow-y: auto)
- Prevent main window scrolling (overflow: hidden on body)
- Ensure textarea is scrollable when content exceeds container
src/components/Layout.ts- Main container- Define component interfaces
- Set up event system
// src/types.ts
export interface ReaderState {
words: string[]
currentIndex: number
isPlaying: boolean
wpm: number
activeTextId?: string
}- Extract display logic from HTML
- Implement word positioning
- Add animation handling
- Move word splitting logic
- Add timing calculations
- Implement ORP if needed
- Play/pause button
- Speed slider
- Navigation buttons
- Compact layout for small screens
- Progress bar
- Time remaining
- Word count
- Minimal space usage
// src/utils/storage.ts
export const storage = {
save: (text: SavedText) => { /* ... */ },
load: () => { /* ... */ },
delete: (id: string) => { /* ... */ }
}- Horizontal scrolling container
- Text cards with titles
- Active state indication
- Delete functionality
- Save to localStorage
- Handle storage limits
- Implement FIFO eviction
- Textarea with auto-resize
- Collapse/expand toggle
- Character/word count
- Ctrl/Cmd+S to save
- Escape to collapse
- Tab navigation
- Debounce storage operations
- Optimize re-renders
- Lazy load saved texts
- ARIA labels
- Keyboard navigation
- Screen reader support
- Storage quota exceeded
- Invalid text handling
- Graceful degradation
npm run buildnpm run preview- Update README
- Create migration guide
- Update CLAUDE.md
Using simple callbacks to avoid complexity:
// Parent (main.ts)
const handleTextSelect = (text: SavedText) => {
state.words = splitText(text.content)
state.currentIndex = text.lastPosition || 0
reader.update(state)
}
// Child component
savedTexts.onSelect = handleTextSelectKeep it simple with a single state object:
let state: ReaderState = {
words: [],
currentIndex: 0,
isPlaying: false,
wpm: 300
}- Manual testing for UI/UX
- Focus on small window scenarios
- Test with real texts of various lengths
- Verify localStorage limits
Last Updated: 2025-06-22 Current Phase: Phase 7 Complete, Ready for Phase 8 Blockers: None Next Step: Migration guide and production deployment
- Created comprehensive small window optimization styles (300x400px target)
- Implemented loading states with visual feedback for async operations
- Added error handling system with user-friendly notifications
- Performance optimizations implemented:
- Debounced text input and save operations
- RAF-scheduled display updates for smooth animations
- Throttled position updates to reduce localStorage writes
- Cross-browser compatibility:
- Added browser-specific CSS fixes
- Implemented polyfills for older browsers
- Tested webkit, Firefox, Edge, and Safari specific issues
- Features added:
- Loading spinners for saved texts
- Success/error states for save operations
- Browser feature detection and warnings
- Print-friendly styles
- Dark mode support
- High contrast mode support
- Reduced motion support
- Created modular TextInput component with enhanced features
- Implemented smooth collapse/expand animation with visual feedback
- Added auto-save drafts with 2-second delay and localStorage persistence
- Integrated word/character count display
- Enhanced keyboard shortcuts (Ctrl/Cmd+S already working)
- Visual feedback for save operations
- Draft recovery on page reload
- Clear draft when saving or loading saved texts
- Features implemented:
- Responsive design for small screens
- Visual draft saved indicator
- Escape key to cancel title editing in saved texts
- Expand text area when creating new text
- Created SavedTexts component with horizontal scrolling UI
- Implemented StorageManager for localStorage persistence
- Added save/load/delete functionality with visual feedback
- Implemented resume position feature with throttled updates
- Added keyboard shortcut (Ctrl/Cmd+S) for saving texts
- Integrated saved texts with main application state
- Features implemented:
- Auto-generated titles from first line of text
- Progress tracking (percentage complete)
- FIFO eviction when storage limit reached (20 texts max)
- Active text indication
- Position updates while reading
- Created separate Controls and Progress components for better modularity
- Enhanced controls with proper button states and visual feedback
- Added touch gesture support for mobile/tablet users:
- Tap to play/pause
- Swipe left/right for navigation
- Swipe up/down for speed control
- Improved responsive design for small screens
- All controls properly styled with hover states and transitions