Module: LeanCms::ApplicationHelper
- Defined in:
- app/helpers/lean_cms/application_helper.rb
Instance Method Summary collapse
-
#darken_color(hex_color, percent) ⇒ Object
Darken a hex color by a percentage.
-
#format_date(date) ⇒ Object
Format date for display.
-
#format_datetime(datetime) ⇒ Object
Format datetime for display.
-
#status_badge_class(status) ⇒ Object
Status badge colors.
Instance Method Details
#darken_color(hex_color, percent) ⇒ Object
Darken a hex color by a percentage
4 5 6 7 8 9 |
# File 'app/helpers/lean_cms/application_helper.rb', line 4 def darken_color(hex_color, percent) hex_color = hex_color.gsub('#', '') rgb = hex_color.scan(/../).map { |color| color.to_i(16) } rgb = rgb.map { |channel| [(channel * (100 - percent) / 100).round, 0].max } "##{rgb.map { |channel| channel.to_s(16).rjust(2, '0') }.join}" end |
#format_date(date) ⇒ Object
Format date for display
12 13 14 15 |
# File 'app/helpers/lean_cms/application_helper.rb', line 12 def format_date(date) return unless date date.strftime("%B %d, %Y") end |
#format_datetime(datetime) ⇒ Object
Format datetime for display
18 19 20 21 |
# File 'app/helpers/lean_cms/application_helper.rb', line 18 def format_datetime(datetime) return unless datetime datetime.strftime("%B %d, %Y at %I:%M %p") end |
#status_badge_class(status) ⇒ Object
Status badge colors
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/helpers/lean_cms/application_helper.rb', line 24 def status_badge_class(status) case status.to_s when 'published' 'bg-green-100 text-green-800' when 'draft' 'bg-yellow-100 text-yellow-800' when 'new_submission' 'bg-blue-100 text-blue-800' when 'read' 'bg-gray-100 text-gray-800' when 'replied' 'bg-green-100 text-green-800' when 'archived' 'bg-gray-100 text-gray-600' else 'bg-gray-100 text-gray-800' end end |