Class: Tailwinds::BaseComponent
- Inherits:
-
Tramway::BaseComponent
- Object
- ViewComponent::Base
- Tramway::BaseComponent
- Tailwinds::BaseComponent
- Defined in:
- app/components/tailwinds/base_component.rb
Overview
Shared base component for Tailwinds components
Direct Known Subclasses
BackButtonComponent, BadgeComponent, ButtonComponent, FlashComponent
Constant Summary collapse
- TYPE_COLOR_MAP =
{ default: :gray, life: :gray, primary: :blue, hope: :blue, secondary: :zinc, success: :green, will: :green, warning: :orange, greed: :orange, danger: :red, rage: :red, love: :violet, compassion: :indigo, compassio: :indigo, fear: :yellow, submit: :green }.freeze
Constants included from Tramway::Helpers::ViewsHelper
Tramway::Helpers::ViewsHelper::FORM_SIZES
Instance Method Summary collapse
Methods included from Tramway::Helpers::ViewsHelper
#tramway_back_button, #tramway_badge, #tramway_button, #tramway_cell, #tramway_container, #tramway_flash, #tramway_form_for, #tramway_header, #tramway_main_container, #tramway_row, #tramway_table, #tramway_title
Methods included from Tramway::Helpers::ComponentHelper
Methods included from Tramway::Helpers::DecorateHelper
Instance Method Details
#normalized_type ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'app/components/tailwinds/base_component.rb', line 33 def normalized_type value = type value = nil if value.respond_to?(:empty?) && value.empty? value ||= :default value = value.downcase if value.respond_to?(:downcase) value = value.to_sym if value.respond_to?(:to_sym) TYPE_COLOR_MAP.key?(value) ? value : :default end |
#resolved_color ⇒ Object
25 26 27 |
# File 'app/components/tailwinds/base_component.rb', line 25 def resolved_color (color || type_color).to_s end |
#type_color ⇒ Object
29 30 31 |
# File 'app/components/tailwinds/base_component.rb', line 29 def type_color TYPE_COLOR_MAP.fetch(normalized_type, TYPE_COLOR_MAP[:default]).to_sym end |