feat: add Settings context and migrate SCSS theme system to React#259
Open
devin-ai-integration[bot] wants to merge 3 commits into
Open
feat: add Settings context and migrate SCSS theme system to React#259devin-ai-integration[bot] wants to merge 3 commits into
devin-ai-integration[bot] wants to merge 3 commits into
Conversation
- Create Settings TypeScript interface (react-app/src/models/settings.ts)
- Create SettingsContext with React Context API (react-app/src/context/SettingsContext.tsx)
- Manages theme, font size, spacing, open-in-new-tab, and show-settings state
- Persists preferences to localStorage
- Detects system color scheme (prefers-color-scheme: dark) on first visit
- Listens for system theme changes
- Copy and adapt SCSS theme system:
- _media.scss, _theme_variables.scss, _themes.scss (core theme engine)
- global.scss (base styles with themes import)
- Copy component SCSS as CSS Modules with :host replaced by wrapper classes:
- Header, Settings, Footer, FeedPage, FeedItem, ItemDetailsPage,
Comment, UserPage, Loader, ErrorMessage
- Add global.scss import in main.tsx
Co-Authored-By: Matthew Guerra <matthew.guerra@cognition.ai>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
- toggleSettings: use functional updater to read prev state directly - toggleOpenLinksInNewTab: use functional updater to avoid stale closure, persist correct value to localStorage - Media query listener: guard with localStorage check so user's explicit theme choice is not overridden by system color scheme changes Co-Authored-By: Matthew Guerra <matthew.guerra@cognition.ai>
- _themes.scss: amoledblack theme now passes proper border shorthand (2px solid $color) instead of bare color value - SettingsContext: extract getInitialTheme() to detect system dark mode synchronously during useState initialization, eliminating the flash from default→night theme on first render Co-Authored-By: Matthew Guerra <matthew.guerra@cognition.ai>
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.
Summary
Implements settings state management and SCSS theming for the Angular → React migration (Session 2 of parallel migration).
Settings Context (
react-app/src/context/SettingsContext.tsx)SettingsService(DI singleton) to a React Context providerlocalStorage(matching Angular behavior)getInitialTheme()— no flash on first loadmatchMedialistener with proper cleanuptoggleSettingsandtoggleOpenLinksInNewTabto avoid stale closuresSettings Model (
react-app/src/models/settings.ts)SettingsmodelSCSS Theme System (
react-app/src/styles/)_media.scss— responsive breakpoint variables_theme_variables.scss— color tokens for day/night/amoled-black themes_themes.scss— theme mixin + 3 theme instantiations (default, night, amoledblack)global.scss— base styles importing the theme system2px solid $color) instead of bare color value (bug in Angular source)default,night,amoledblack) on the root<div>in App.tsxComponent CSS Modules
All Angular component SCSS files migrated to CSS Modules with
:hostreplaced by wrapper class names:Header.module.scss(.header-root)Settings.module.scss(.settings-root)Footer.module.scss(.footer-root)FeedPage.module.scss(.feed-root)FeedItem.module.scss(.feed-item-root)ItemDetailsPage.module.scss(.item-details-root)Comment.module.scss(.comment-root)UserPage.module.scss(.user-root)Loader.module.scss(.loader-root)ErrorMessage.module.scss(.error-message-root)Integration
react-app/src/main.tsximportsglobal.scssReview & Testing Checklist for Human
SettingsContextcorrectly mirrors AngularSettingsServicebehavior (localStorage keys, default values, system theme detection).header-root,.settings-root, etc.) will integrate correctly with the React components from other sessionsNotes
react-app/directory with Vite + React setup) being merged first.main.tsxfile is minimal (just theglobal.scssimport) — Session 1 will provide the full React entrypoint; this import line should be merged into it.package.jsondependencies.Link to Devin session: https://app.devin.ai/sessions/59528812c4f646c1a5e59d35a60cbd2c
Requested by: @matthewguerra-cog
Devin Review