Class: Keystone::Ui::AccordionComponent

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

Constant Summary collapse

BASE_CLASSES =
"flex flex-col gap-4"
ITEM_LAYOUT_CLASSES =
"rounded-xl border"
BUTTON_LAYOUT_CLASSES =
"flex w-full items-center justify-between px-6 py-4 text-left font-semibold transition"
ANSWER_LAYOUT_CLASSES =
"hidden px-6 pb-4 text-sm"
ICON_LAYOUT_CLASSES =
"shrink-0 transition-transform"
CARET_ICON =
<<~SVG.freeze
  <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M19 9l-7 7-7-7" /></svg>
SVG

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(items: []) ⇒ AccordionComponent

Returns a new instance of AccordionComponent.



18
19
20
# File 'app/components/keystone/ui/accordion_component.rb', line 18

def initialize(items: [])
  @items = items
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



16
17
18
# File 'app/components/keystone/ui/accordion_component.rb', line 16

def items
  @items
end

Instance Method Details

#answer_classesObject



34
35
36
# File 'app/components/keystone/ui/accordion_component.rb', line 34

def answer_classes
  "#{ANSWER_LAYOUT_CLASSES} text-surface-600 dark:text-surface-400"
end

#button_classesObject



30
31
32
# File 'app/components/keystone/ui/accordion_component.rb', line 30

def button_classes
  "#{BUTTON_LAYOUT_CLASSES} text-surface-900 dark:text-white hover:text-accent-600 dark:hover:text-accent-400"
end

#caret_iconObject



42
43
44
# File 'app/components/keystone/ui/accordion_component.rb', line 42

def caret_icon
  CARET_ICON
end

#classesObject



22
23
24
# File 'app/components/keystone/ui/accordion_component.rb', line 22

def classes
  BASE_CLASSES
end

#icon_classesObject



38
39
40
# File 'app/components/keystone/ui/accordion_component.rb', line 38

def icon_classes
  "#{ICON_LAYOUT_CLASSES} text-surface-400"
end

#item_classesObject



26
27
28
# File 'app/components/keystone/ui/accordion_component.rb', line 26

def item_classes
  "#{ITEM_LAYOUT_CLASSES} border-surface-200 dark:border-surface-700"
end

#wrapper_dataObject



46
47
48
# File 'app/components/keystone/ui/accordion_component.rb', line 46

def wrapper_data
  { controller: "accordion" }
end