-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: decompose main.js monolithic file (#85) #117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add modeColumn, guidanceColumn, and controlsColumn property declarations to GramFrame constructor to resolve TypeScript compilation errors after UI module extraction.
✅ Deploy Preview for gramframe ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Refactors the monolithic src/main.js
file by extracting UI creation and viewport management functionality into dedicated modules to improve maintainability and separation of concerns.
- Extracted UI layout creation logic to
src/components/MainUI.js
- Extracted zoom/pan viewport functionality to
src/core/viewport.js
- Updated event handling to use the extracted functions
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/types.js | Added JSDoc type definitions for new UI column properties |
src/main.js | Refactored to use extracted modules, removing inline UI and viewport code |
src/core/viewport.js | New module containing all zoom/pan/resize functionality |
src/core/events.js | Updated to import and use extracted MainUI functions |
src/components/MainUI.js | New module containing unified layout creation and UI management |
prompts/tasks/Task_Issue_85.md | Added task documentation for the refactoring work |
package.json | Version bump from 0.1.1 to 0.1.2 |
Memory_Bank.md | Added log entry documenting the completed refactoring |
.claude/settings.local.json | Added git tag bash command to allowed operations |
* @property {HTMLDivElement|null} [middleColumn] - Middle column layout | ||
* @property {HTMLDivElement|null} [rightColumn] - Right column layout | ||
* @property {HTMLDivElement|null} [modeColumn] - Mode buttons column | ||
* @property {HTMLDivElement|null} [guidanceColumn] - Guidance text column |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an extra space at the end of the line after 'column'.
* @property {HTMLDivElement|null} [guidanceColumn] - Guidance text column | |
* @property {HTMLDivElement|null} [guidanceColumn] - Guidance text column |
Copilot uses AI. Check for mistakes.
colorPicker.querySelector('.gram-frame-color-picker-label').textContent = 'Color' | ||
controlsColumn.appendChild(colorPicker) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The colorPicker creation and subsequent querySelector operation should be documented or validated. If createColorPicker can return null or if the querySelector might fail, this should be handled appropriately.
colorPicker.querySelector('.gram-frame-color-picker-label').textContent = 'Color' | |
controlsColumn.appendChild(colorPicker) | |
if (colorPicker) { | |
const labelElem = colorPicker.querySelector('.gram-frame-color-picker-label'); | |
if (labelElem) { | |
labelElem.textContent = 'Color'; | |
} else { | |
console.warn('Color picker label element not found.'); | |
} | |
controlsColumn.appendChild(colorPicker); | |
} else { | |
console.warn('Failed to create color picker.'); | |
} |
Copilot uses AI. Check for mistakes.
Summary
Decomposed the monolithic
src/main.js
file from 695 lines to 492 lines (203-line reduction) by extracting UI creation and viewport management into dedicated modules while preserving all functionality and maintaining backward compatibility.Changes
src/components/MainUI.js
(224 lines) - UI layout creation functions includingcreateUnifiedLayout()
,updateUniversalCursorReadouts()
, andupdatePersistentPanels()
src/core/viewport.js
(107 lines) - All zoom/pan functionality includingzoomIn()
,zoomOut()
,setZoom()
,handleResize()
, andupdateAxes()
src/core/events.js
- Updated to use extracted MainUI functions while maintaining event delegation patternsArchitecture Improvements
Test Results
Test Plan
Closes #85