Files
aperonight/app/helpers/flash_messages_helper.rb
kbe cb0de11de1 refactor: Improve code quality and add comprehensive documentation
- Remove unused create_stripe_session method from TicketsController
- Replace hardcoded API key with environment variable for security
- Fix typo in ApplicationHelper comment
- Improve User model validation constraints for better UX
- Add comprehensive YARD-style documentation across models, controllers, services, and helpers
- Enhance error handling in cleanup jobs with proper exception handling
- Suppress Prawn font warnings in PDF generator
- Update refactoring summary with complete change documentation

All tests pass (200 tests, 454 assertions, 0 failures)
RuboCop style issues resolved automatically

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-05 17:30:13 +02:00

52 lines
2.0 KiB
Ruby
Executable File

# Flash messages helper for consistent styling across the application
#
# Provides standardized CSS classes and icons for different types of flash messages
# using Tailwind CSS classes and Lucide icons for consistent UI presentation
module FlashMessagesHelper
# Return appropriate Tailwind CSS classes for different flash message types
#
# @param type [String, Symbol] The flash message type (notice, error, warning, info)
# @return [String] Tailwind CSS classes for styling the flash message container
#
# Examples:
# flash_class('success') # => "bg-green-50 text-green-800 border-green-200"
# flash_class('error') # => "bg-red-50 text-red-800 border-red-200"
def flash_class(type)
case type.to_s
when "notice", "success"
"bg-green-50 text-green-800 border-green-200"
when "error", "alert"
"bg-red-50 text-red-800 border-red-200"
when "warning"
"bg-yellow-50 text-yellow-800 border-yellow-200"
when "info"
"bg-blue-50 text-blue-800 border-blue-200"
else
"bg-gray-50 text-gray-800 border-gray-200"
end
end
# Return appropriate Lucide icon for different flash message types
#
# @param type [String, Symbol] The flash message type
# @return [String] HTML content tag with Lucide icon data attribute
#
# Examples:
# flash_icon('success') # => <i data-lucide="check-circle" class="..."></i>
# flash_icon('error') # => <i data-lucide="x-circle" class="..."></i>
def flash_icon(type)
case type.to_s
when "notice", "success"
content_tag :i, "", "data-lucide": "check-circle", class: "w-5 h-5 flex-shrink-0"
when "error", "alert"
content_tag :i, "", "data-lucide": "x-circle", class: "w-5 h-5 flex-shrink-0"
when "warning"
content_tag :i, "", "data-lucide": "alert-triangle", class: "w-5 h-5 flex-shrink-0"
when "info"
content_tag :i, "", "data-lucide": "info", class: "w-5 h-5 flex-shrink-0"
else
content_tag :i, "", "data-lucide": "bell", class: "w-5 h-5 flex-shrink-0"
end
end
end