-
Notifications
You must be signed in to change notification settings - Fork 1
feat: support high contrast mode via C toggle key #406
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
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
This PR adds high contrast mode functionality to the MAIDR system, triggered by the 'c' key toggle. The feature analyzes SVG elements and converts their colors to grayscale levels (defaulting to black and white) based on configurable contrast settings.
- Adds a new "High Contrast Levels" setting to control the number of contrast levels (defaults to 2 for black/white)
- Implements color-to-grayscale conversion with special handling for near-white colors to prevent background/foreground conflicts
- Integrates the toggle functionality into the existing keybinding system across all modes
Reviewed Changes
Copilot reviewed 13 out of 16 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ui/pages/Settings.tsx | Adds High Contrast Levels numeric input field to settings UI |
| src/type/settings.ts | Extends GeneralSettings interface with highContrastLevels property |
| src/state/viewModel/settingsViewModel.ts | Sets default value of 2 for highContrastLevels in initial state |
| src/service/settings.ts | Sets default value of 2 for highContrastLevels in settings service |
| src/service/keybinding.ts | Adds 'c' key mapping for TOGGLE_HIGH_CONTRAST across all modes |
| src/service/highlight.ts | Implements core high contrast functionality with color conversion logic |
| src/service/display.ts | Minor formatting changes to constructor parameters |
| src/model/context.ts | Changes instructionContext from private to public for high contrast access |
| src/controller.ts | Formatting improvements and adds settingsService to command context |
| src/command/toggle.ts | Adds ToggleHighContrast command class |
| src/command/factory.ts | Integrates ToggleHighContrast into command factory |
| src/command/command.ts | Adds settingsService to CommandContext interface |
| examples/lineplot.html | Adds CSS rules for high contrast mode styling |
Comments suppressed due to low confidence (1)
src/service/highlight.ts:120
- This method contains DOM manipulation logic that should be handled by the UI layer. According to the architectural guidelines, the Service layer should emit events for ViewModels to consume rather than directly manipulating the DOM.
svg.removeAttribute('style');
| fullWidth | ||
| type="number" | ||
| size="small" | ||
| value={generalSettings.highContrastLevels} |
Copilot
AI
Aug 6, 2025
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 numeric input for High Contrast Levels lacks validation constraints. Consider adding min/max values (e.g., min=2, max=255) to prevent invalid configurations.
|
This PR contains changes to files in the
If you need help running the tests, please refer to our testing documentation. |
|
This PR contains changes to files that affect the model layer and unit tests. Before merging, please ensure:
|
|
Issues still pending:
|
…/high-contrast
|
This PR contains changes to files in the
If you need help running the tests, please refer to our testing documentation. |
|
This PR contains changes to files that affect the model layer and unit tests. Before merging, please ensure:
|
|
@jooyoungseo @ellvix , High contrast mode toggle works fine outside the L scope. However, I see this error on console when I toggle high contrast mode |
|
This PR contains changes to files in the
If you need help running the tests, please refer to our testing documentation. |
|
This PR contains changes to files that affect the model layer and unit tests. Before merging, please ensure:
|
Pull Request Review: High Contrast Mode FeatureOverviewThis PR adds a comprehensive high contrast accessibility feature with keyboard toggle (C key), configurable contrast levels, and pattern support for differentiation. The implementation is substantial and well-architected overall. Code Quality & Architecture✅ Strengths
|
|
@nk1408 Could you please cross the finish line by fixing Claude suggestions? |
|
This PR contains changes to files in the
If you need help running the tests, please refer to our testing documentation. |
|
This PR contains changes to files that affect the model layer and unit tests. Before merging, please ensure:
|
|
@jooyoungseo , addressed the comments and merging it |
Pull Request Review - High Contrast Mode FeatureSummaryThis PR adds a comprehensive high contrast accessibility feature triggered by the 'C' key. The implementation includes support for multiple contrast levels, pattern overlays for differentiation, and automatic color transformation. Overall, this is a well-architected and thoughtful addition to the accessibility features. ✅ StrengthsArchitecture & Design
Code Quality
|
|
This PR contains changes to files in the
If you need help running the tests, please refer to our testing documentation. |
|
This PR contains changes to files that affect the model layer and unit tests. Before merging, please ensure:
|
Pull Request Review: High Contrast Mode FeatureThank you for this comprehensive accessibility feature! This is a significant enhancement that will greatly benefit users with visual impairments. Below is my detailed review: ✅ StrengthsArchitecture & Design
Code Quality
Accessibility
Issues & Recommendations1. Memory Leak RiskLocation: src/service/highContrast.ts:98-109 The sharedCanvasCtx is never cleaned up in the dispose() method. Add this.sharedCanvasCtx = null to cleanup. 2. Chart-Specific Logic in Generic ServiceLocations: Lines 335-339, 348-355, 390-397, 674-683 The service contains hardcoded chart type checks. This violates the open/closed principle and creates tight coupling. Consider refactoring to a strategy pattern. 3. Error Handling GapsLocation: src/service/highContrast.ts:704 The findClosestColor() method throws an error for empty color arrays, but this could crash the application. Return inputColor instead of throwing. 4. Missing Input ValidationThe highContrastLevels input accepts any number value without validation (no min 2 / max checks). 5. Potential Performance IssuegetOriginalColorInfo() queries ALL SVG elements on every capture. For complex charts with thousands of elements, this could be slow. 6. Color Mutation BugLocation: src/service/highContrast.ts:738-741 This mutates the colorArray parameter via splice(). Since colorArray comes from this.colorEquivalents getter, this means the computed getter returns different values after the first call! Create a copy of the array before mutating. 7. Race Condition in Settings ObserverLocation: src/service/highContrast.ts:157-161 The observer only checks if high contrast mode changed. However, if highContrastLevels, highContrastLightColor, or highContrastDarkColor change while the mode is ON, the display will not update. 8. Incomplete Heatmap FixPR description acknowledges: Still a minor issue with some heatmap charts, where the numeric text on the cell can be the same as the background. Testing ConcernsMissing Test Coverage:
Security ReviewNo Critical Issues Found - No XSS vulnerabilities, injection risks, or sensitive data exposure detected. Proper sanitization of user color inputs via canvas normalization. SummaryOverall Assessment: This is a high-quality, well-architected feature with excellent attention to accessibility. The core implementation is solid, but there are several bugs and architectural concerns that should be addressed before merging. Must Fix Before Merge:
Should Fix Before Merge:
Can Address in Follow-up:
Great work on this feature! The attention to detail in color theory and accessibility is commendable. Please address the critical bugs, and this will be ready to ship. |
|
🎉 This PR is included in version 3.45.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Pull Request
Description
Adds basic high contrast functionality, including multiple level support in settings (defaults to 2 levels (black and white)).
Related Issues
Addresses #361
Changes Made
Created a toggle function triggered on 'c'. All colored objects in the standard svg structure are analyzed and converted to their closest grayscale color according to the number of specified contrast levels. EG, for black and white, convert everything to either black or white.
A few exceptions: Many charts use a color very close to white, so we define a custom "is it actually white, or just close" so the chart items and backgrounds don't end up being the same color in high contrast mode.
Additional Notes
Still a minor issue with some heatmap charts, where the numeric text on the cell can be the same as the background.
Still todo: