Phase 7.3b: Migrate Assignment/Book Info Components to Plain CSS#3060
Open
OpenStaxClaude wants to merge 9 commits into
Open
Phase 7.3b: Migrate Assignment/Book Info Components to Plain CSS#3060OpenStaxClaude wants to merge 9 commits into
OpenStaxClaude wants to merge 9 commits into
Conversation
- Replaced styled-components with plain CSS using CSS variables - Created AssignedTopBar.css with responsive breakpoints - Converted StyledTopBarWrapper to use TopBarWrapper with className - Converted StyledSectionTitle to plain h2 element with className - Used CSS variables for dynamic theme values (colors, heights) - Followed migration patterns from PLAIN_CSS_MIGRATION_LEARNINGS.md - All component logic remains unchanged 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
a1f0646 to
e372350
Compare
This comment was marked as resolved.
This comment was marked as resolved.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR continues the Phase 7.3 migration by moving assignment/book-related content components off styled-components and into plain CSS files, while also modernizing Attribution from a class + connect() to a functional component using Redux hooks.
Changes:
- Migrates
Assigned,AssignedTopBar,Attribution, andBuyBookstyling from styled-components to co-located plain CSS. - Refactors
Attributionto a functional component withuseSelector,useEffect, anduseRef/useLayoutEffect. - Updates Jest snapshots to reflect the new class-based markup and removal of styled-components generated styles.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/app/content/components/Assigned.tsx | Replaces styled-components wrappers with function components + CSS variables/classes. |
| src/app/content/components/Assigned.css | Adds plain CSS for Assigned button/toast/platform wrapper behavior. |
| src/app/content/components/AssignedTopBar.tsx | Switches from styled-components wrapper/title to className + CSS variables. |
| src/app/content/components/AssignedTopBar.css | Adds plain CSS for Assigned top bar styling and breakpoints. |
| src/app/content/components/Attribution.tsx | Converts to functional component + Redux hooks; replaces styled Details/Summary with native <details>/<summary> and CSS. |
| src/app/content/components/Attribution.css | Adds plain CSS for attribution container, summary icons, content/link styling, and breakpoints. |
| src/app/content/components/BuyBook.tsx | Replaces styled-components with class-based markup, CSS variables, and disablePrintClass. |
| src/app/content/components/BuyBook.css | Adds plain CSS for BuyBook layout and link styling. |
| src/app/content/components/snapshots/BuyBook.spec.tsx.snap | Updates snapshot output for class-based BuyBook markup. |
| src/app/content/components/snapshots/Attribution.spec.tsx.snap | Updates snapshot output for new details/summary markup and removal of styled-components CSS output. |
| src/app/content/components/snapshots/AssignedTopBar.spec.tsx.snap | Updates snapshot output for AssignedTopBar class usage + CSS variables. |
| src/app/content/snapshots/routes.spec.tsx.snap | Updates assigned route snapshot due to Assigned/Attribution/TopBar markup and class changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e194f06 to
6a16d4a
Compare
RoyEJohnson
reviewed
Jul 14, 2026
Contributor
There was a problem hiding this comment.
This was crazy. So much duplication (now removed).
This commit migrates the BuyBook component following the simplified plain CSS migration approach documented in PLAIN_CSS_MIGRATION_LEARNINGS.md. Changes: - Created BuyBook.css with plain CSS styles - Updated BuyBook.tsx to use className instead of styled-components - Used CSS variables for dynamic values (max-width and color) - Applied disablePrintClass for print hiding behavior - Followed established patterns from other migrated components The component maintains identical functionality and styling while removing the styled-components dependency. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Convert class component to functional component with hooks - Replace connect() HOC with useSelector hook - Create Attribution.css with all component styles - Use CSS variables for dynamic values (theme colors, widths) - Replace styled Summary/Details with plain HTML elements - Implement htmlMessage pattern inline (Content and CodeRunnerNote components) - Maintain all existing functionality: - Auto-scroll on toggle - Close on page navigation - Special attribution for python books - Support for special book IDs - Export named Attribution component for testing - Use classNames package for className composition - Follow patterns from PLAIN_CSS_MIGRATION_LEARNINGS.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Replace styled-components imports with classNames - Convert StyledButton, ToastOverride, and PlatformWrapper to plain React components - Create Assigned.css with corresponding styles - Use CSS variables for dynamic values (contentTextWidth, topbarDesktopHeight, assignedMobileTop) - Convert theme.breakpoints.mobile() to @media query with correct breakpoint (75em) - Maintain all existing functionality and component behavior 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Address Copilot review feedback on AssignedTopBar and Attribution **AssignedTopBar.tsx:** - Conditionally render the <h2> heading only when section?.title exists - Prevents empty headings which are an accessibility issue for screen readers - While section should always be defined in practice (as Roy noted), this handles edge cases during initial render and follows best practices **Attribution.tsx:** - Revert useEffect dependency array back to [] (empty) - The toggle event listener doesn't depend on `page` and should only run on mount/unmount - Re-running this effect on every page change is unnecessary and wasteful - The page change logic is already handled in the separate useLayoutEffect These changes address Copilot's accessibility concern while maintaining the correct React hook behavior. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Fix AssignedTopBar to handle undefined section during loading The AssignedTopBar component was expecting section to always be defined, but sections[currentSectionIndex] can be undefined while the book and assigned sections are still loading. Changes: - Made section prop optional: LinkedArchiveTreeSection | undefined - Added early return (null) when section is not yet available - This allows the Page component to render its loader during loading state - Fixes the test "renders loading state without book" This addresses both Copilot's concern about empty headings and Roy's observation that the test was failing. The component now properly handles the loading state by returning null instead of rendering an empty h2. 🤖 Generated with [Claude Code](https://claude.com/claude-code) props.section is always defined Co-Authored-By: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
141de62 to
f990964
Compare
Co-Authored-By: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
261c9c1 to
aa2ec4a
Compare
Co-Authored-By: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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
This PR migrates 4 assignment and book-related content components from styled-components to plain CSS as part of Phase 7.3 (CORE-2284).
Components Migrated
Migration Highlights
connect()to functional component +useSelectorhooksFiles Changed
New CSS Files:
src/app/content/components/Assigned.css(32 lines)src/app/content/components/AssignedTopBar.css(50 lines)src/app/content/components/Attribution.css(145 lines)src/app/content/components/BuyBook.css(28 lines)Modified Components:
src/app/content/components/Assigned.tsx- Migrated 3 styled-components to plain CSSsrc/app/content/components/AssignedTopBar.tsx- Migrated 2 styled-components to plain CSSsrc/app/content/components/Attribution.tsx- Migrated 5 styled-components + class→functional conversionsrc/app/content/components/BuyBook.tsx- Migrated 2 styled-components to plain CSSKey Patterns Used
CSS Variables for Dynamic Values:
Data Attributes for Conditional Styling:
Top-Level Media Queries:
Attribution Component Refactoring
Beyond the styling migration,
Attribution.tsxwas also modernized:connect()HOC withuseSelectorhookuseEffecthookscreateRef()touseRef()Related
Testing Notes
All component functionality has been preserved:
Components follow established migration patterns and maintain backward compatibility.
🤖 Generated with Claude Code