Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """ | |
| Visual Separation Manager Demo | |
| This demo shows the VisualSeparationManager functionality for creating | |
| consistent visual styling and separation for different content types. | |
| Requirements: 7.1, 7.2, 7.3, 7.4, 7.5 | |
| """ | |
| import sys | |
| import os | |
| # Add project root to path | |
| project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
| sys.path.insert(0, project_root) | |
| from src.interface.visual_separation_manager import ( | |
| VisualSeparationManager, | |
| ContentType, | |
| VisualStyle | |
| ) | |
| from src.interface.enhanced_display_integration import ( | |
| EnhancedDisplayIntegration, | |
| create_enhanced_display_integration | |
| ) | |
| def demo_visual_separation_manager(): | |
| """Demonstrate VisualSeparationManager functionality.""" | |
| print("π¨ Visual Separation Manager Demo") | |
| print("=" * 50) | |
| # Create visual separation manager | |
| visual_manager = VisualSeparationManager() | |
| print("\n1. Testing AI Analysis Styling:") | |
| ai_styling = visual_manager.create_ai_analysis_styling() | |
| print(f" Container style: {ai_styling['container'][:50]}...") | |
| print(f" Header style: {ai_styling['header'][:50]}...") | |
| print(f" Icon style: {ai_styling['icon'][:30]}...") | |
| print("\n2. Testing Patient Message Styling:") | |
| patient_styling = visual_manager.create_patient_message_styling() | |
| print(f" Container style: {patient_styling['container'][:50]}...") | |
| print(f" Message box style: {patient_styling['message_box'][:50]}...") | |
| print("\n3. Testing Provider Summary Styling:") | |
| provider_styling = visual_manager.create_provider_summary_styling() | |
| print(f" Container style: {provider_styling['container'][:50]}...") | |
| print(f" Info box style: {provider_styling['info_box'][:50]}...") | |
| print("\n4. Testing Section Separators:") | |
| separators = visual_manager.generate_section_separators() | |
| for sep_type, sep_html in separators.items(): | |
| print(f" {sep_type}: {len(sep_html)} characters") | |
| print("\n5. Testing Classification Styling:") | |
| for classification in ["RED", "YELLOW", "GREEN"]: | |
| styling = visual_manager.get_classification_styling(classification) | |
| print(f" {classification}: {styling['text'][:30]}...") | |
| print("\n6. Testing Urgency Styling:") | |
| for urgency in ["IMMEDIATE", "URGENT", "STANDARD"]: | |
| styling = visual_manager.get_urgency_styling(urgency) | |
| print(f" {urgency}: {styling['badge'][:40]}...") | |
| print("\n7. Testing Icon Styling:") | |
| for content_type in [ContentType.AI_ANALYSIS, ContentType.PATIENT_MESSAGE, ContentType.PROVIDER_SUMMARY]: | |
| icon_style = visual_manager.create_icon_styling(content_type) | |
| print(f" {content_type.value}: {icon_style[:40]}...") | |
| print("\n8. Testing Consistent Formatting:") | |
| sections = [ | |
| {"type": "ai_analysis", "content": "AI analysis content example"}, | |
| {"type": "patient_message", "content": "Patient message content example"}, | |
| {"type": "provider_summary", "content": "Provider summary content example"} | |
| ] | |
| formatted_result = visual_manager.apply_consistent_formatting(sections) | |
| print(f" Formatted result length: {len(formatted_result)} characters") | |
| print(f" Contains separators: {'---' in formatted_result}") | |
| print(f" Contains all content: {all(section['content'] in formatted_result for section in sections)}") | |
| def demo_enhanced_display_integration(): | |
| """Demonstrate Enhanced Display Integration with VisualSeparationManager.""" | |
| print("\n\nπ Enhanced Display Integration Demo") | |
| print("=" * 50) | |
| # Create integration instance | |
| integration = create_enhanced_display_integration() | |
| print("\n1. Testing Section Creation with Styling:") | |
| # AI Analysis section | |
| ai_section = integration.create_section_with_styling( | |
| content="Patient shows signs of spiritual distress with loss of meaning indicators.", | |
| section_type="ai_analysis", | |
| title="AI Analysis - RED FLAG" | |
| ) | |
| print(f" AI section length: {len(ai_section)} characters") | |
| print(f" Contains AI icon: {'π€' in ai_section}") | |
| # Patient Message section | |
| patient_section = integration.create_section_with_styling( | |
| content="I don't know what to believe anymore. Everything feels meaningless.", | |
| section_type="patient_message" | |
| ) | |
| print(f" Patient section length: {len(patient_section)} characters") | |
| print(f" Contains patient icon: {'π¬' in patient_section}") | |
| # Provider Summary section | |
| provider_section = integration.create_section_with_styling( | |
| content="Immediate spiritual care intervention recommended for existential crisis.", | |
| section_type="provider_summary" | |
| ) | |
| print(f" Provider section length: {len(provider_section)} characters") | |
| print(f" Contains provider icon: {'π' in provider_section}") | |
| print("\n2. Testing Badge Creation:") | |
| # Classification badges | |
| red_badge = integration.get_classification_badge("RED") | |
| yellow_badge = integration.get_classification_badge("YELLOW") | |
| green_badge = integration.get_classification_badge("GREEN") | |
| print(f" RED badge: {len(red_badge)} characters") | |
| print(f" YELLOW badge: {len(yellow_badge)} characters") | |
| print(f" GREEN badge: {len(green_badge)} characters") | |
| # Urgency badges | |
| immediate_badge = integration.get_urgency_badge("IMMEDIATE") | |
| urgent_badge = integration.get_urgency_badge("URGENT") | |
| standard_badge = integration.get_urgency_badge("STANDARD") | |
| print(f" IMMEDIATE badge: {len(immediate_badge)} characters") | |
| print(f" URGENT badge: {len(urgent_badge)} characters") | |
| print(f" STANDARD badge: {len(standard_badge)} characters") | |
| print("\n3. Testing Content Separators:") | |
| separators = ["light", "medium", "heavy", "section_break"] | |
| for sep_type in separators: | |
| separator = integration.create_content_separator(sep_type) | |
| print(f" {sep_type} separator: {len(separator)} characters") | |
| print("\n4. Testing Multiple Sections Formatting:") | |
| sections = [ | |
| {"type": "ai_analysis", "content": "AI analysis content"}, | |
| {"type": "patient_message", "content": "Patient message content"}, | |
| {"type": "provider_summary", "content": "Provider summary content"} | |
| ] | |
| formatted_multiple = integration.format_multiple_sections(sections) | |
| print(f" Multiple sections result: {len(formatted_multiple)} characters") | |
| print(f" Contains all content: {all(section['content'] in formatted_multiple for section in sections)}") | |
| def demo_visual_styling_consistency(): | |
| """Demonstrate visual styling consistency across components.""" | |
| print("\n\nπ― Visual Styling Consistency Demo") | |
| print("=" * 50) | |
| visual_manager = VisualSeparationManager() | |
| print("\n1. Color Consistency Check:") | |
| # Check classification colors | |
| classification_colors = visual_manager.classification_colors | |
| print(f" Classification colors: {classification_colors}") | |
| # Check urgency colors | |
| urgency_colors = visual_manager.urgency_colors | |
| print(f" Urgency colors: {urgency_colors}") | |
| print("\n2. Style Structure Consistency:") | |
| # Check that all content types have consistent styling structure | |
| content_types = [ContentType.AI_ANALYSIS, ContentType.PATIENT_MESSAGE, ContentType.PROVIDER_SUMMARY] | |
| for content_type in content_types: | |
| if content_type == ContentType.AI_ANALYSIS: | |
| styling = visual_manager.create_ai_analysis_styling() | |
| elif content_type == ContentType.PATIENT_MESSAGE: | |
| styling = visual_manager.create_patient_message_styling() | |
| elif content_type == ContentType.PROVIDER_SUMMARY: | |
| styling = visual_manager.create_provider_summary_styling() | |
| required_keys = ["container", "header", "icon"] | |
| has_all_keys = all(key in styling for key in required_keys) | |
| print(f" {content_type.value}: Has all required keys: {has_all_keys}") | |
| # Check for consistent CSS properties | |
| container_style = styling.get("container", "") | |
| has_border = "border:" in container_style | |
| has_padding = "padding:" in container_style | |
| has_margin = "margin:" in container_style | |
| has_background = "background-color:" in container_style | |
| print(f" - Border: {has_border}, Padding: {has_padding}, Margin: {has_margin}, Background: {has_background}") | |
| print("\n3. Separator Consistency:") | |
| separators = visual_manager.generate_section_separators() | |
| for sep_name, sep_html in separators.items(): | |
| has_div = "<div" in sep_html | |
| has_style = "style=" in sep_html | |
| print(f" {sep_name}: Has div: {has_div}, Has style: {has_style}") | |
| def main(): | |
| """Run all visual separation manager demos.""" | |
| try: | |
| demo_visual_separation_manager() | |
| demo_enhanced_display_integration() | |
| demo_visual_styling_consistency() | |
| print("\n\nβ All Visual Separation Manager demos completed successfully!") | |
| print("\nKey Features Demonstrated:") | |
| print("- β AI Analysis styling with classification colors") | |
| print("- β Patient Message styling with consistent formatting") | |
| print("- β Provider Summary styling with urgency indicators") | |
| print("- β Section separators for visual content division") | |
| print("- β Classification and urgency badges") | |
| print("- β Icon styling for different content types") | |
| print("- β Consistent formatting across multiple sections") | |
| print("- β Integration with enhanced display system") | |
| print(f"\nRequirements Validated:") | |
| print("- 7.1: β AI analysis and provider summary visual styling") | |
| print("- 7.2: β Patient message and content section styling") | |
| print("- 7.3: β Icons and color coding for content types") | |
| print("- 7.4: β Visual separators and section breaks") | |
| print("- 7.5: β Consistent formatting and visual hierarchy") | |
| except Exception as e: | |
| print(f"\nβ Demo failed with error: {e}") | |
| import traceback | |
| traceback.print_exc() | |
| return 1 | |
| return 0 | |
| if __name__ == "__main__": | |
| exit(main()) |