feat(tui): add cortex-tui-components crate for standardized UI components#467
Merged
feat(tui): add cortex-tui-components crate for standardized UI components#467
Conversation
…ents Create a new component library crate that provides reusable, high-level TUI components built on top of cortex-core's theme system. ## Key Features - **Component Trait System**: Unified interface for all interactive components with render(), handle_key(), focus_state(), and key_hints() - **20+ Reusable Modules**: - borders: 4 border styles (Rounded, Single, Double, ASCII) - focus: FocusManager for tab navigation - scroll: ScrollState and scrollbar rendering - key_hints: KeyHintsBar for keyboard shortcuts - text: StyledText builder and TextStyle presets - input: TextInput with grapheme-aware cursor - selector: Full-featured selection list with search - form: 5 field types (Text, Secret, Number, Toggle, Select) - modal: ModalStack for nested dialogs - dropdown, checkbox, radio, list, toast, spinner, panel, popup, card - **Theme Integration**: Uses cortex-core's Ocean/Cyan theme constants - **73 Unit Tests**: Comprehensive test coverage This library is designed to reduce raw ratatui usage and code duplication across the TUI, making it easier to build consistent interfaces.
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
Create a new
cortex-tui-componentscrate that provides reusable, high-level TUI components built on top ofcortex-core's theme system.Motivation
The existing TUI code has 100+ direct ratatui imports with redundant patterns for dropdowns, scrolling lists, borders, and input handling. This library consolidates those patterns into standardized, reusable components.
Key Features
Component Trait System
Unified interface for all interactive components:
20+ Reusable Modules
bordersRoundedBorderwidgetfocusFocusManagerfor tab navigation with wrap-aroundscrollScrollStateand scrollbar rendering utilitieskey_hintsKeyHintsBarfor displaying keyboard shortcutstextStyledTextbuilder andTextStylepresetsinputTextInputwith grapheme-aware cursor positioningselectorformmodalModalStackfor nested dialogsdropdowncheckboxradiolisttoastspinnerpanelpopupcardTheme Integration
Uses cortex-core's Ocean/Cyan theme constants:
CYAN_PRIMARY,BORDER,BORDER_FOCUSSURFACE_0,SURFACE_1,SURFACE_2TEXT,TEXT_DIM,TEXT_MUTEDTesting
cargo checkandcargo fmtcleanFuture Work
Gradually migrate existing TUI widgets to use these components to reduce code duplication.
Checklist
cargo check)cargo test -p cortex-tui-components)cargo fmt)