Class: Keystone::Ui::SectionComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/keystone/ui/section_component.rb

Constant Summary collapse

SPACING_CLASSES =
{ sm: "mt-4", md: "mt-6", lg: "mt-8" }.freeze
HEADER_CLASSES =
"flex items-center justify-between mb-4"
TITLE_CLASSES =
"text-lg font-semibold text-gray-900 dark:text-white"
SUBTITLE_CLASSES =
"mt-1 text-sm text-gray-500 dark:text-gray-400"
ACTION_BASE_CLASSES =
"text-sm"

Instance Method Summary collapse

Constructor Details

#initialize(title: nil, subtitle: nil, action: nil, spacing: :md) ⇒ SectionComponent

Returns a new instance of SectionComponent.



12
13
14
15
16
17
# File 'app/components/keystone/ui/section_component.rb', line 12

def initialize(title: nil, subtitle: nil, action: nil, spacing: :md)
  @title = title
  @subtitle = subtitle
  @action = action
  @spacing = spacing
end

Instance Method Details

#action_classesObject



23
24
25
# File 'app/components/keystone/ui/section_component.rb', line 23

def action_classes
  "#{ACTION_BASE_CLASSES} text-accent-600 hover:text-accent-900 dark:text-accent-400 dark:hover:text-accent-300"
end

#header?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/components/keystone/ui/section_component.rb', line 27

def header?
  !@title.nil?
end

#spacing_classObject



19
20
21
# File 'app/components/keystone/ui/section_component.rb', line 19

def spacing_class
  SPACING_CLASSES.fetch(@spacing)
end