Skip to content

refactor(tui): extract shared style definitions#59

Merged
daisuke8000 merged 1 commit intomainfrom
refactor/pr4-styles-extraction
Dec 20, 2025
Merged

refactor(tui): extract shared style definitions#59
daisuke8000 merged 1 commit intomainfrom
refactor/pr4-styles-extraction

Conversation

@daisuke8000
Copy link
Owner

Summary

  • Add styles.rs module with shared style definitions for TUI components
  • Apply styles to render_collections() and render_databases() views
  • Reduce inline style definitions by ~24 lines

Changes

  • New: crates/mbr-tui/src/components/styles.rs (119 lines)
    • border_style() for focused/unfocused border styling
    • header_style() for table headers
    • row_highlight_style() for selected table rows
    • HIGHLIGHT_SYMBOL constant for selection indicator
    • Text style constants reserved for future use (PR 5, 6)
  • Modified: content.rs - use shared styles in collections and databases views

Test plan

  • cargo test passes (32 tests)
  • cargo clippy passes
  • TUI functionality preserved

Related

Part 4 of crates refactoring plan. Styles module prepares for comprehensive View refactoring in PR 5, 6.

Add styles.rs module with common style definitions for TUI components:
- border_style() for focused/unfocused border styling
- header_style() for table headers
- row_highlight_style() for selected table rows
- HIGHLIGHT_SYMBOL constant for selection indicator
- Text style constants for future use

Apply styles to render_collections() and render_databases() views.

Changes:
- Add crates/mbr-tui/src/components/styles.rs (119 lines)
- Simplify style definitions in content.rs
- Reduce content.rs by ~24 lines
@daisuke8000 daisuke8000 merged commit 1b84574 into main Dec 20, 2025
1 check passed
@daisuke8000 daisuke8000 deleted the refactor/pr4-styles-extraction branch December 20, 2025 13:31
daisuke8000 added a commit that referenced this pull request Dec 20, 2025
Apply the extracted helpers from PR #58 and #59 to three render
functions in content.rs:

- render_collection_questions: Use LoadStateConfig for non-loaded
  states, header_style(), row_highlight_style(), HIGHLIGHT_SYMBOL
- render_database_schemas: Same pattern applied
- render_schema_tables: Same pattern applied

This reduces content.rs from 4,427 to 4,112 lines (~315 lines removed)
by eliminating duplicated LoadState pattern matching and inline style
definitions across these functions.

Changes:
- Replace manual LoadState match arms with render_non_loaded_state()
- Replace manual empty state rendering with render_empty_with_hint()
- Use shared style functions instead of inline Style definitions
- Use HIGHLIGHT_SYMBOL constant instead of hardcoded "► "
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.

1 participant