Class: Tailwinds::BaseComponent
Overview
Shared base component for Tailwinds components
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
Instance Method Summary
collapse
#tramway_back_button, #tramway_badge, #tramway_button, #tramway_cell, #tramway_container, #tramway_form_for, #tramway_header, #tramway_row, #tramway_table, #tramway_title
#component
#tramway_decorate
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
|