Skip to content

Phase 4.3: Study Guides UI Migration (Remaining Components)#3023

Merged
RoyEJohnson merged 2 commits into
mainfrom
CORE-1830-study-guides-phase-4.3
Jun 8, 2026
Merged

Phase 4.3: Study Guides UI Migration (Remaining Components)#3023
RoyEJohnson merged 2 commits into
mainfrom
CORE-1830-study-guides-phase-4.3

Conversation

@OpenStaxClaude

Copy link
Copy Markdown
Contributor

Summary

This PR completes the study guides migration by converting the remaining study guides components from styled-components to plain CSS, continuing the work from Phase 4.2 (PR #2936).

Related Jira Ticket

CORE-1830: Phase 4.3: Study Guides UI Migration (Remaining Components)

Components Migrated

1. Filters.tsx ✅

  • Migrated StyledColorFilter (min-width styling)
  • Migrated RightButtonsWrapper (flexbox layout)
  • Created Filters.css with plain CSS classes

2. StudyGuides.tsx ✅

  • Migrated nested component styling (HighlightsChapterWrapper, HighlightSection, HighlightWrapper)
  • Used CSS descendant selectors with :has() to target styled-components by data-testid
  • Bound theme.color.neutral.darkest as CSS variable for print styles
  • Preserved mobile breakpoint styles (max-width: 75em)
  • Preserved print styles
  • Created StudyGuides.css with comprehensive comments

3. StudyGuidesPopUp.tsx ✅

  • No migration needed - Only uses shared PopupStyles components
  • These will be migrated in a future phase when ALL popup components are migrated together

4. StudyGuidesToasts.tsx ✅

  • No migration needed - Just a Redux connector with no styling

Migration Approach

Following the hybrid approach from PLAIN_CSS_MIGRATION_GUIDE.md:

  • Theme remains in JavaScript for type safety and dynamic access
  • CSS variables bound from theme values when needed
  • Plain CSS files imported for side effects
  • Descendant selectors used to style nested components

Key Technical Notes

StudyGuides.tsx Nested Styling Challenge

The most complex part of this migration was handling StudyGuides.tsx, which previously used styled-components' component interpolation feature to style imported components:

// Before: styled-components interpolation
export default styled(StudyGuides)`
  ${HighlightsChapterWrapper} {
    // styles...
  }
`

Since the nested components (HighlightsChapterWrapper, HighlightSection, HighlightWrapper) are styled-components that generate dynamic class names, we can't target them by class name. Instead, we use CSS descendant selectors with :has() pseudo-class to target elements by their structure and data-testid attributes:

/* Target: div containing h2[data-testid="chapter-title"] */
.study-guides-wrapper > div:has(h2[data-testid="chapter-title"]) {
  /* styles for HighlightsChapterWrapper */
}

/* Target: h3 elements with data-testid="section-title" */
.study-guides-wrapper h3[data-testid="section-title"] {
  /* styles for HighlightSection */
}

This approach:

  • ✅ Works with existing styled-components without modifying shared components
  • ✅ Uses stable data-testid attributes already in the DOM
  • ✅ Maintains all original styling behavior
  • ⚠️ Requires browser support for :has() pseudo-class (all modern browsers)

Testing

Due to Node version incompatibility in the environment, automated tests couldn't be run. Manual verification recommended:

Areas to Test

  1. Filters
    • Color filter dropdown min-width (29rem)
    • Print button alignment (right side with auto margin)
  2. Study Guides List
    • Mobile chapter title truncation (max-width: 90%, ellipsis)
    • Mobile section padding (padding-left: 2rem)
    • Print styles (no padding, no margins, correct background color)

Test Steps

Follow the Testing Guide from Phase 4.2 (CORE-1704):

  1. Navigate to any REX textbook
  2. Sign in and create highlights
  3. Open "My Highlights & Study Guides"
  4. Verify filters layout and functionality
  5. Test mobile responsive behavior
  6. Test print preview

Success Criteria

  • ✅ All study guides component styled-components removed (Filters.tsx, StudyGuides.tsx)
  • ⏳ All tests passing (pending environment fix)
  • ⏳ No visual regressions (pending manual testing)
  • ✅ Mobile responsive behavior maintained (CSS preserved)
  • ✅ Print styles preserved (CSS with variable binding)

Notes

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com

@TomWoodward
TomWoodward temporarily deployed to rex-web-core-1830-study-7jsg2x May 13, 2026 19:37 Inactive
@RoyEJohnson
RoyEJohnson force-pushed the CORE-1830-study-guides-phase-4.3 branch from b8c016a to 15904de Compare May 13, 2026 20:18
@TomWoodward
TomWoodward temporarily deployed to rex-web-core-1830-study-7jsg2x May 13, 2026 20:19 Inactive
@RoyEJohnson
RoyEJohnson requested a review from Copilot May 13, 2026 20:30

This comment was marked as low quality.

@RoyEJohnson
RoyEJohnson force-pushed the CORE-1704-study-guides-css-migration branch from 835719a to 40d290c Compare May 20, 2026 12:20
Base automatically changed from CORE-1704-study-guides-css-migration to main May 20, 2026 14:01
@RoyEJohnson
RoyEJohnson force-pushed the CORE-1830-study-guides-phase-4.3 branch 2 times, most recently from 619f51d to 56b338e Compare May 20, 2026 15:36
@RoyEJohnson
RoyEJohnson requested a review from Copilot May 20, 2026 15:42

This comment was marked as resolved.

RoyEJohnson

This comment was marked as resolved.

@OpenStaxClaude

This comment was marked as resolved.

@RoyEJohnson
RoyEJohnson marked this pull request as ready for review May 20, 2026 17:25
@RoyEJohnson
RoyEJohnson requested a review from a team as a code owner May 20, 2026 17:25
@RoyEJohnson
RoyEJohnson requested a review from Dantemss May 20, 2026 17:25
OpenStaxClaude and others added 2 commits June 3, 2026 13:02
Migrate Filters.tsx and StudyGuides.tsx from styled-components to plain CSS
following the hybrid approach documented in PLAIN_CSS_MIGRATION_GUIDE.md.

Changes:
- Filters.tsx: Migrated StyledColorFilter and RightButtonsWrapper to CSS classes
  - Created Filters.css with study-guides-color-filter and study-guides-right-buttons classes
  - Removed styled-components, replaced with className props

- StudyGuides.tsx: Migrated nested component styling to CSS descendant selectors
  - Created StudyGuides.css targeting HighlightsChapterWrapper, HighlightSection, HighlightWrapper
  - Used :has() selectors to target styled-components by their data-testid attributes
  - Bound theme.color.neutral.darkest as CSS variable for print styles
  - Preserved mobile breakpoint and print styles

Note: StudyGuidesPopUp.tsx and StudyGuidesToasts.tsx do not require migration as they
only use shared components with no study-guides-specific styling.

Related to CORE-1830

Snaps/lint css
Address Copilot review comments by fixing CSS selectors that were
incorrectly using direct child combinator (>) from .study-guides-wrapper.

Since .study-guides-wrapper has display:contents, the styled-components
(HighlightsChapterWrapper, HighlightWrapper) are nested inside
HighlightsWrapper, not direct children.

Changes:
- Remove > from .study-guides-wrapper > div selectors
- Use div:has(> h2[...]) to precisely target HighlightsChapterWrapper
- Use div:has(> h3[...]) to precisely target HighlightWrapper
- Update comments to clarify the DOM structure and targeting approach

Fixes all four issues identified in the review:
1. Mobile styles for HighlightsChapterWrapper (line 21)
2. Print padding for HighlightsChapterWrapper (line 45)
3. Print margin-left for HighlightWrapper (line 54)
4. Print margin-top for adjacent siblings (line 63)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@RoyEJohnson
RoyEJohnson force-pushed the CORE-1830-study-guides-phase-4.3 branch from 83f0caa to d2f4dab Compare June 3, 2026 18:02
@RoyEJohnson
RoyEJohnson merged commit 31125d9 into main Jun 8, 2026
7 checks passed
@RoyEJohnson
RoyEJohnson deleted the CORE-1830-study-guides-phase-4.3 branch June 8, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants