Class: Tailwinds::BaseComponent

Inherits:
Tramway::BaseComponent show all
Defined in:
app/components/tailwinds/base_component.rb

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

Methods included from Tramway::Helpers::ViewsHelper

#tramway_back_button, #tramway_badge, #tramway_button, #tramway_cell, #tramway_container, #tramway_form_for, #tramway_header, #tramway_row, #tramway_table, #tramway_title

Methods included from Tramway::Helpers::ComponentHelper

#component

Methods included from Tramway::Helpers::DecorateHelper

#tramway_decorate

Instance Method Details

#normalized_typeObject



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_colorObject



25
26
27
# File 'app/components/tailwinds/base_component.rb', line 25

def resolved_color
  (color || type_color).to_s
end

#type_colorObject



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