Skip to content

Phase 7.2c: Complete Topbar Migration to Plain CSS#3056

Open
OpenStaxClaude wants to merge 3 commits into
phase-7.2b-migrate-toolbar-componentsfrom
phase-7.2c-migrate-topbar-utils
Open

Phase 7.2c: Complete Topbar Migration to Plain CSS#3056
OpenStaxClaude wants to merge 3 commits into
phase-7.2b-migrate-toolbar-componentsfrom
phase-7.2c-migrate-topbar-utils

Conversation

@OpenStaxClaude

@OpenStaxClaude OpenStaxClaude commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR completes the migration of Topbar/styled.tsx to plain CSS as part of Phase 7.2c of the CSS migration effort (CORE-2283).

What Was Migrated

Topbar/styled.tsx:

  • ✅ Removed HamburgerIcon styled wrapper - now uses plain CSS class
  • ✅ Removed LeftArrow styled wrapper - now uses plain CSS class
  • ✅ Removed SearchInputWrapper styled wrapper - converted to plain function
  • ✅ Removed AngleLeftIcon styled wrapper - converted to plain function
  • ✅ Added CSS classes: topbar-hamburger-icon, topbar-left-arrow, topbar-shadow
  • ✅ Kept legacy shadow css export for backward compatibility with AssignedTopBar

Migration Status

The Topbar component is now ~98% migrated to plain CSS. The only remaining styled-components usage is:

  • Legacy shadow css fragment export (used by AssignedTopBar.tsx which still uses styled-components)

Content components:

  • BookBanner.tsx - Book title and chapter banner with gradient backgrounds, scroll animations, and two variants (big/mini) - ~350 lines, 8 styled-components

Utils:

  • applyBookTextColor.ts - Inlined into BookBanner (was only used there)

BookBanner Migration Details

The BookBanner component was the most complex migration in this PR:

  • 8 styled-components converted to functional components
  • Gradient backgrounds computed dynamically from theme and book colorSchema
  • Scroll-based transitions between big and mini variants preserved
  • Two responsive variants (big/mini) with different layouts and behaviors
  • Text colors applied via CSS variables from theme
  • Disabled print styling via CSS @media print rules

What Was NOT Migrated

The following files were intentionally left for a future PR:

  • utils/sidebar.ts - Contains styleWhen* functions used by many components

These utility files should be migrated once more consuming components have been converted to plain CSS.

Changes Made

  1. Removed styled-components dependencies from component implementations
  2. Added CSS classes for icon sizing and shadow utility
  3. Converted to plain functions using classNames for className composition
  4. Kept backward compatibility with legacy shadow export for AssignedTopBar
  5. Used existing Topbar.css which was already comprehensive from previous work

Testing Checklist

  • TypeScript compilation succeeds
  • Component renders correctly with all variants
  • Icon sizing is correct (hamburger, left arrow)
  • Shadow utility works in AssignedTopBar
  • No console warnings
  • BookBanner gradients display correctly for all book themes
  • BookBanner scroll behavior works (transition between big/mini variants)

Stack

This PR builds on top of:

Related Jira Ticket

CORE-2283: Phase 7.2: Migrate Page & Toolbar Components

🤖 Generated with Claude Code

Completed the migration of Topbar/styled.tsx by:
- Removed remaining styled-components wrappers (HamburgerIcon, LeftArrow, SearchInputWrapper)
- Converted styled components to plain functions using classNames
- Added CSS classes for icon sizing (topbar-hamburger-icon, topbar-left-arrow)
- Added topbar-shadow utility class for backward compatibility
- Kept legacy shadow css export for AssignedTopBar (to be migrated later)
- Removed styled-components imports except for legacy shadow export

All Topbar components now use plain CSS with CSS variables for dynamic values.
The Topbar.css file was already comprehensive from previous work.

Note: utils/* files (applyBookTextColor.ts, sidebar.ts) were not migrated in this PR
as they have broader dependencies across multiple components and should be addressed
in a future PR once more components are migrated.

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@TomWoodward TomWoodward temporarily deployed to rex-web-phase-7-2c-migr-lr88ka July 2, 2026 15:36 Inactive
Migrated BookBanner.tsx (~350 lines) from styled-components to plain CSS:
- Converted 8 styled-components to plain CSS + React components
- Inlined applyBookTextColor utility (only used in BookBanner)
- Maintained gradient backgrounds, scroll animations, and two variants (big/mini)
- Preserved all responsive behavior and accessibility features

Key Changes:
- Created BookBanner.css with comprehensive styles for both variants
- Replaced styled-components with functional components using classNames
- Used CSS variables for dynamic values (gradients, colors, z-indices, heights)
- Maintained scroll-based transition behavior between big/mini variants
- Added React.forwardRef to BarWrapper for proper ref forwarding

Technical Details:
- Gradient backgrounds computed dynamically from theme and colorSchema prop
- Text colors applied via CSS variables from theme.color.primary[colorSchema].foreground
- Responsive breakpoints documented with calculations
- Preserved disabled print styling via CSS @media print rules
- ChevronLeftIcon migrated to plain SVG component

Following 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>
@TomWoodward TomWoodward temporarily deployed to rex-web-phase-7-2c-migr-jldvps July 2, 2026 16:02 Inactive
@TomWoodward TomWoodward temporarily deployed to rex-web-phase-7-2c-migr-lib7w4 July 2, 2026 16:12 Inactive
@RoyEJohnson RoyEJohnson force-pushed the phase-7.2c-migrate-topbar-utils branch from ec08468 to 8c592f2 Compare July 2, 2026 16:28
@TomWoodward TomWoodward temporarily deployed to rex-web-phase-7-2c-migr-bcqtgd July 2, 2026 16:28 Inactive
@TomWoodward TomWoodward temporarily deployed to rex-web-phase-7-2c-migr-bcqtgd July 2, 2026 17:06 Inactive
RoyEJohnson

This comment was marked as resolved.

@TomWoodward TomWoodward had a problem deploying to rex-web-phase-7-2c-migr-bcqtgd July 2, 2026 17:31 Failure
@OpenStaxClaude

This comment was marked as resolved.

@TomWoodward TomWoodward had a problem deploying to rex-web-phase-7-2c-migr-bcqtgd July 2, 2026 17:35 Failure
@RoyEJohnson RoyEJohnson force-pushed the phase-7.2c-migrate-topbar-utils branch from f263a29 to 687659d Compare July 2, 2026 17:42
@TomWoodward TomWoodward temporarily deployed to rex-web-phase-7-2c-migr-bcqtgd July 2, 2026 17:43 Inactive
@TomWoodward TomWoodward temporarily deployed to rex-web-phase-7-2c-migr-bcqtgd July 2, 2026 17:44 Inactive
@RoyEJohnson RoyEJohnson requested a review from Copilot July 2, 2026 17:50

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

This PR continues the styled-components → plain CSS migration by finishing the Topbar migration (except for a legacy shadow export used by AssignedTopBar) and migrating the BookBanner component to a CSS-based implementation.

Changes:

  • Converted multiple Topbar styled-components wrappers to plain function components + CSS classes, while keeping a legacy shadow css export for AssignedTopBar.
  • Migrated BookBanner from styled-components to plain CSS with CSS variables for theme-driven colors/gradients and preserved scroll-based big/mini behavior.
  • Removed now-unused utilities (applyBookTextColor.ts, Toolbar/iconStyles.ts) and updated snapshots/CSS formatting.

Reviewed changes

Copilot reviewed 7 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/app/content/components/utils/applyBookTextColor.ts Removed unused styled-components helper (inlined into BookBanner).
src/app/content/components/Topbar/Topbar.css Added new Topbar utility/icon classes (topbar-shadow, topbar-hamburger-icon, topbar-left-arrow).
src/app/content/components/Topbar/styled.tsx Replaced several styled wrappers with plain components and added CSS import + shadow compatibility export.
src/app/content/components/Topbar/snapshots/index.spec.tsx.snap Updated snapshots to reflect className changes after migration.
src/app/content/components/Toolbar/Toolbar.css Formatting-only tweak.
src/app/content/components/Toolbar/iconStyles.ts Removed legacy styled-components css fragment (no remaining TS imports found).
src/app/content/components/BookBanner.tsx Migrated BookBanner component to plain CSS, using CSS variables for theme/gradient styling.
src/app/content/components/BookBanner.css New stylesheet implementing the migrated BookBanner styling and responsive behavior.
src/app/content/components/snapshots/BookBanner.spec.tsx.snap Updated snapshots to reflect DOM/CSS-variable based styling.

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

Comment thread src/app/content/components/BookBanner.css Outdated
Comment thread src/app/content/components/Topbar/styled.tsx
Comment thread src/app/content/components/Topbar/Topbar.css Outdated
@TomWoodward TomWoodward temporarily deployed to rex-web-phase-7-2c-migr-bcqtgd July 2, 2026 18:00 Inactive
@RoyEJohnson RoyEJohnson force-pushed the phase-7.2c-migrate-topbar-utils branch from 58ab964 to eaf2da9 Compare July 2, 2026 18:01
@TomWoodward TomWoodward temporarily deployed to rex-web-phase-7-2c-migr-bcqtgd July 2, 2026 18:02 Inactive
RoyEJohnson

This comment was marked as resolved.

@OpenStaxClaude

This comment was marked as resolved.

@TomWoodward TomWoodward temporarily deployed to rex-web-phase-7-2c-migr-bcqtgd July 2, 2026 18:48 Inactive
@RoyEJohnson RoyEJohnson force-pushed the phase-7.2c-migrate-topbar-utils branch from d5eaa45 to a35db81 Compare July 2, 2026 18:52
@TomWoodward TomWoodward temporarily deployed to rex-web-phase-7-2c-migr-bcqtgd July 2, 2026 18:53 Inactive
@RoyEJohnson RoyEJohnson requested a review from Copilot July 2, 2026 18:53

This comment was marked as resolved.

@TomWoodward TomWoodward temporarily deployed to rex-web-phase-7-2c-migr-bcqtgd July 2, 2026 19:09 Inactive
@RoyEJohnson RoyEJohnson force-pushed the phase-7.2c-migrate-topbar-utils branch from f5f3fed to 21a6c91 Compare July 2, 2026 19:11
@TomWoodward TomWoodward temporarily deployed to rex-web-phase-7-2c-migr-bcqtgd July 2, 2026 19:11 Inactive
@RoyEJohnson RoyEJohnson force-pushed the phase-7.2c-migrate-topbar-utils branch from 21a6c91 to a3f599c Compare July 2, 2026 19:25
@TomWoodward TomWoodward temporarily deployed to rex-web-phase-7-2c-migr-bcqtgd July 2, 2026 19:25 Inactive
@RoyEJohnson RoyEJohnson requested a review from Copilot July 2, 2026 19:27

This comment was marked as resolved.

Remove unnecessary undefined fallbacks from BookBanner textColor ternaries

The colorSchema prop in BookTitle, BookTitleLink, and BookChapter components
is always defined when these components are rendered. The bookTheme selector
returns either the book's theme or a default 'blue' theme, never undefined.

These components are only rendered after checking that book exists, and
bookTheme is always defined in that context. The ternary fallbacks to
undefined were dead code that made the type system less precise.

Changes:
- Removed ternary operators checking if colorSchema exists
- Updated TypeScript interfaces to reflect colorSchema is never undefined
- Simplified textColor assignment to direct property access

This addresses the code review feedback about lacking test coverage for
the undefined branches - they were unnecessary and have been removed.

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

Remove unused files

snaps

Lint

specificity

more fixups

Fix BookBanner mobile font sizes for title and chapter

On mobile, both BookTitle and BookChapter should use smaller font sizes
(1.6rem/2rem) regardless of variant. The original styled-components used
h3Style and h4Style which both have mobile breakpoints that set these values.

Changes:
- Added mobile styles for .book-banner-title: font-size: 1.6rem; line-height: 2rem
- Added mobile styles for .book-banner-chapter: font-size: 1.6rem; line-height: 2rem

This ensures both big and mini variants display with the correct mobile
typography on screens under 1200px (75em breakpoint).

Addresses review feedback about missing mobile font-size/line-height.

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

Include left chevron on collapsed banner

Co-Authored-By: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@RoyEJohnson RoyEJohnson force-pushed the phase-7.2c-migrate-topbar-utils branch from a3f599c to 8a9291a Compare July 2, 2026 19:43
@RoyEJohnson RoyEJohnson marked this pull request as ready for review July 2, 2026 19:59
@RoyEJohnson RoyEJohnson requested a review from a team as a code owner July 2, 2026 19:59
@RoyEJohnson RoyEJohnson requested review from jivey and removed request for a team July 2, 2026 19:59

@jivey jivey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is looking ok to me

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.

5 participants