Skip to content

Dup 2.6 Migrate Content Page Components to CSS - #2844

Closed
RoyEJohnson wants to merge 2 commits into
mainfrom
dup-2.6-for-copilot
Closed

Dup 2.6 Migrate Content Page Components to CSS#2844
RoyEJohnson wants to merge 2 commits into
mainfrom
dup-2.6-for-copilot

Conversation

@RoyEJohnson

Copy link
Copy Markdown
Contributor

CORE-1700

Summary

Migrated three critical content page layout components from styled-components to CSS Modules as part of Phase 2.6 of the Plain CSS Migration initiative.

Related Jira: CORE-1700

Components Migrated

1. PageContent (src/app/content/components/Page/PageContent.tsx)

  • Main content area with highlight styles, search highlighting, and MathJax integration
  • Dynamic highlight styles generated from highlightStyles array in constants
  • Created PageContent.css for static styles
  • Created PageContent.legacy.ts for backward-compatible contentTextStyle export
  • Reduced from 235 lines to 124 lines (47% reduction)

2. Topbar (src/app/content/components/Topbar/)

  • Horizontal toolbar with search and text resizer controls
  • Complex responsive behavior (desktop/mobile/mobile-medium layouts)
  • Dynamic book theme colors for search button
  • Text resizer with theme-dependent gradient
  • Created Topbar.css with all responsive media queries

3. Toolbar (src/app/content/components/Toolbar/)

  • Vertical navigation sidebar with study tools buttons
  • Mobile menu with show/hide animations
  • Created Toolbar.css with keyframe animations
  • Created Toolbar.legacy.ts for backward-compatible exports (PlainButton, barPadding, toolbarDefaultButton, etc.)

Technical Implementation

CSS Variables for Dynamic Theming

Dynamic values (book theme colors, padding, gradients) are bound as CSS variables from JavaScript:

style={{
  '--search-button-bg': colorSchema ? theme.color.primary[colorSchema].base : 'transparent',
  '--toolbar-z-index': theme.zIndex.toolbar,
  ...style,
} as React.CSSProperties}

Icon Components

Kept icon components wrapped with styled() using empty template literals for component selector compatibility, following pattern from Phase 1.4:

  • PageContent: None needed
  • Topbar: AngleLeftIcon, HamburgerIcon, TimesCircleIcon
  • Toolbar: ChevronLeftIcon, PrintIconComponent

Backward Compatibility

Created .legacy.ts files to maintain exports used by other components:

  • PageContent.legacy.ts: Exports contentTextStyle (used by Attribution.tsx)
  • Toolbar.legacy.ts: Exports PlainButton, barPadding, toolbarDefaultButton, etc. (used by Topbar, TableOfContents, SidebarControl, PrintButton)

Responsive Design

All media queries moved to top level in CSS (required for plain CSS):

  • Desktop: > 1200px (75em)
  • Mobile: 800px - 1200px (50em - 75em)
  • Mobile Medium: < 800px (50em)

Migration Patterns Followed

✅ Hybrid approach (theme in JavaScript, styles in CSS)
✅ CSS variables bound from theme at component level
✅ Top-level media queries (not nested)
✅ Separate .legacy.ts files for backward compatibility
classNames library for conditional class composition
React.forwardRef for components receiving refs
✅ Transient prop filtering (props starting with $)
✅ Icon components wrapped with styled() for compatibility

Testing Requirements

Responsive Testing

Test at all three breakpoints:

  1. Desktop (> 1200px): Verify toolbar visible on left, topbar shows full search bar and text resizer
  2. Mobile (800px - 1200px): Verify toolbar transitions smoothly, topbar remains functional
  3. Mobile Medium (< 800px): Verify hamburger menu appears, toolbar becomes modal overlay

Topbar Functionality

  • Search input: Type query, verify styling, submit search, clear search
  • Search button color: Verify button color matches book theme (test with different books)
  • Text resizer: Click dropdown, drag slider, verify text size changes
  • Mobile toggle: Click hamburger menu, verify toolbar slides in
  • Keyboard navigation: Press Alt+S to cycle focus between search regions

Toolbar Functionality

  • All buttons: Click each button (TOC, Search, Practice Questions, Study Guides, Highlights, Print)
  • Active states: Verify buttons show active styling when their panel is open
  • Mobile menu: Open menu, verify close button works, test tab trapping

PageContent / Highlights

  • Create highlights: Select text, create highlight in different colors
  • Highlight display: Verify all highlight colors render correctly
  • Block highlights: Verify block-level highlights (figures, equations) have proper padding
  • Search highlights: Perform search, verify yellow highlight on results, orange on current result
  • MathJax highlights: Verify math equations can be highlighted and display correctly

Z-Index and Layering

  • Open text resizer dropdown and verify it appears above other content
  • Open toolbar dropdown menus (e.g., Study Guides) and verify they appear correctly
  • Open modal overlays and verify they appear above all other content
  • Scroll page and verify topbar/toolbar remain sticky in correct positions

Visual Regression

  • Compare screenshots before/after at all breakpoints
  • Test with multiple book themes (blue, orange, green, etc.)
  • Verify no layout shifts or unexpected spacing changes

Files Changed

  • 13 files changed
  • 1635 insertions, 814 deletions
  • 3 new CSS files created
  • 2 new legacy files created

Next Steps

  • Manual testing at all breakpoints
  • Verify with different book themes
  • Screenshot testing for visual regression
  • Unit test verification (if CI allows)

🤖 Generated with Claude Code

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

This comment was marked as resolved.

This comment was marked as resolved.

@TomWoodward
TomWoodward temporarily deployed to rex-web-dup-2-6-for-cop-8zthpy April 6, 2026 12:57 Inactive
@TomWoodward
TomWoodward temporarily deployed to rex-web-dup-2-6-for-cop-8zthpy April 6, 2026 13:05 Inactive
@RoyEJohnson
RoyEJohnson force-pushed the dup-2.6-for-copilot branch from 8831282 to 4f28199 Compare April 6, 2026 14:31
@TomWoodward
TomWoodward temporarily deployed to rex-web-dup-2-6-for-cop-8zthpy April 6, 2026 14:31 Inactive
@TomWoodward
TomWoodward temporarily deployed to rex-web-dup-2-6-for-cop-8zthpy April 6, 2026 14:59 Inactive
@RoyEJohnson
RoyEJohnson force-pushed the dup-2.6-for-copilot branch from 63dddac to 1aaaceb Compare April 7, 2026 14:25
@RoyEJohnson
RoyEJohnson requested a review from Copilot April 7, 2026 14:25
@TomWoodward
TomWoodward temporarily deployed to rex-web-dup-2-6-for-cop-8zthpy April 7, 2026 14:25 Inactive

This comment was marked as resolved.

This comment was marked as resolved.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 54 out of 55 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/app/content/components/Toolbar/Toolbar.legacy.tsx Outdated
@TomWoodward
TomWoodward temporarily deployed to rex-web-dup-2-6-for-cop-8zthpy April 9, 2026 00:11 Inactive
@TomWoodward
TomWoodward temporarily deployed to rex-web-dup-2-6-for-cop-8zthpy April 9, 2026 10:53 Inactive
@RoyEJohnson RoyEJohnson changed the title Migrate Content Page Components to CSS Dup 2.6 Migrate Content Page Components to CSS Apr 9, 2026
@RoyEJohnson
RoyEJohnson force-pushed the dup-2.6-for-copilot branch from d30bd48 to 43e6b67 Compare April 9, 2026 11:06
@TomWoodward
TomWoodward temporarily deployed to rex-web-dup-2-6-for-cop-8zthpy April 9, 2026 11:06 Inactive
@TomWoodward
TomWoodward temporarily deployed to rex-web-dup-2-6-for-cop-8zthpy April 9, 2026 11:21 Inactive
@RoyEJohnson
RoyEJohnson force-pushed the dup-2.6-for-copilot branch from 750c496 to d161d04 Compare April 9, 2026 11:29
@TomWoodward
TomWoodward temporarily deployed to rex-web-dup-2-6-for-cop-8zthpy April 9, 2026 11:29 Inactive
@RoyEJohnson
RoyEJohnson force-pushed the dup-2.6-for-copilot branch from d161d04 to 9dadd6a Compare April 9, 2026 11:45
@TomWoodward
TomWoodward temporarily deployed to rex-web-dup-2-6-for-cop-8zthpy April 9, 2026 11:45 Inactive
@TomWoodward
TomWoodward temporarily deployed to rex-web-phase-2-6-conte-skrpca April 9, 2026 11:59 Inactive
@RoyEJohnson
RoyEJohnson requested a review from Copilot April 9, 2026 12:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 58 out of 58 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@RoyEJohnson
RoyEJohnson force-pushed the dup-2.6-for-copilot branch from 9dadd6a to a0c162b Compare April 9, 2026 15:47
@TomWoodward
TomWoodward temporarily deployed to rex-web-dup-2-6-for-cop-8zthpy April 9, 2026 15:47 Inactive
@RoyEJohnson
RoyEJohnson force-pushed the dup-2.6-for-copilot branch from a0c162b to c7457d6 Compare April 9, 2026 18:27
@TomWoodward
TomWoodward temporarily deployed to rex-web-dup-2-6-for-cop-8zthpy April 9, 2026 18:27 Inactive
@RoyEJohnson

Copy link
Copy Markdown
Contributor Author

This was a "spare" copy to run tests on.

@RoyEJohnson RoyEJohnson closed this Apr 9, 2026
@RoyEJohnson RoyEJohnson reopened this Apr 9, 2026
@TomWoodward
TomWoodward temporarily deployed to rex-web-dup-2-6-for-cop-uitk0u April 9, 2026 22:13 Inactive
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@RoyEJohnson
RoyEJohnson force-pushed the dup-2.6-for-copilot branch from c7457d6 to d638374 Compare April 9, 2026 22:15
@TomWoodward
TomWoodward temporarily deployed to rex-web-dup-2-6-for-cop-uitk0u April 9, 2026 22:15 Inactive
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@TomWoodward
TomWoodward temporarily deployed to rex-web-dup-2-6-for-cop-uitk0u April 9, 2026 22:23 Inactive
@RoyEJohnson

Copy link
Copy Markdown
Contributor Author

This was just to gather Copilot reviews.

@RoyEJohnson
RoyEJohnson deleted the dup-2.6-for-copilot branch April 14, 2026 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants