Module: Iron::UiHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/iron/ui_helper.rb
Constant Summary collapse
- FIELD_TYPE_BADGE_CLASSES =
{ "stone" => "badge-stone", "indigo" => "badge-indigo", "amber" => "badge-amber", "sky" => "badge-sky", "green" => "badge-green", "orange" => "badge-orange", "violet" => "badge-violet", "cyan" => "badge-cyan" }.freeze
Instance Method Summary collapse
- #back_button_to(title, url, options = {}) ⇒ Object
- #badge(content = nil, **options, &block) ⇒ Object
- #field_type_badge(field_definition) ⇒ Object
- #field_type_meta(field_definition) ⇒ Object
Instance Method Details
#back_button_to(title, url, options = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'app/helpers/iron/ui_helper.rb', line 3 def (title, url, = {}, &) link_to url, class: tw( "inline-flex items-center gap-2 text-sm/6 text-stone-500 dark:text-stone-400", .delete(:class) ) do safe_join([ icon("chevron-left", class: "size-4"), tag.span(title) ]) end end |
#badge(content = nil, **options, &block) ⇒ Object
16 17 18 19 20 |
# File 'app/helpers/iron/ui_helper.rb', line 16 def badge(content = nil, **, &block) tag.span class: tw("badge", .delete(:class)), ** do block_given? ? capture(&block) : content end end |
#field_type_badge(field_definition) ⇒ Object
50 51 52 53 |
# File 'app/helpers/iron/ui_helper.rb', line 50 def field_type_badge(field_definition) = (field_definition) badge field_definition.humanized_type, class: FIELD_TYPE_BADGE_CLASSES[[:color]] end |
#field_type_meta(field_definition) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/helpers/iron/ui_helper.rb', line 22 def (field_definition) case field_definition.type_handle when "text_field" then { icon: "type", color: "stone" } when "text_area" then { icon: "text", color: "stone" } when "rich_text_area" then { icon: "text-quote", color: "indigo" } when "number" then { icon: "hash", color: "amber" } when "file" then { icon: "file", color: "sky" } when "boolean" then { icon: "toggle-right", color: "green" } when "date" then { icon: "calendar", color: "orange" } when "block" then { icon: "blocks", color: "violet" } when "block_list" then { icon: "list", color: "violet" } when "reference" then { icon: "link", color: "cyan" } when "reference_list" then { icon: "link", color: "cyan" } else { icon: "circle-help", color: "stone" } end end |