Class: Keystone::Ui::DisclosureComponent

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

Constant Summary collapse

WRAPPER_CLASSES =
"group rounded-xl border border-surface-200 dark:border-surface-700"
SUMMARY_CLASSES =
"flex cursor-pointer list-none items-center justify-between gap-4 px-6 py-4 font-semibold text-surface-900 [&::-webkit-details-marker]:hidden dark:text-white"
ICON_CLASSES =
"h-4 w-4 shrink-0 text-surface-400 transition-transform group-open:rotate-180"
BODY_CLASSES =
"px-6 pb-4 text-sm text-surface-600 dark:text-surface-400"
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 Method Summary collapse

Constructor Details

#initialize(open: false) ⇒ DisclosureComponent

Returns a new instance of DisclosureComponent.



17
18
19
# File 'app/components/keystone/ui/disclosure_component.rb', line 17

def initialize(open: false)
  @open = open
end

Instance Method Details

#body_classesObject



37
38
39
# File 'app/components/keystone/ui/disclosure_component.rb', line 37

def body_classes
  BODY_CLASSES
end

#caret_iconObject



41
42
43
# File 'app/components/keystone/ui/disclosure_component.rb', line 41

def caret_icon
  CARET_ICON
end

#icon_classesObject



33
34
35
# File 'app/components/keystone/ui/disclosure_component.rb', line 33

def icon_classes
  ICON_CLASSES
end

#open?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'app/components/keystone/ui/disclosure_component.rb', line 21

def open?
  @open
end

#summary_classesObject



29
30
31
# File 'app/components/keystone/ui/disclosure_component.rb', line 29

def summary_classes
  SUMMARY_CLASSES
end

#wrapper_classesObject



25
26
27
# File 'app/components/keystone/ui/disclosure_component.rb', line 25

def wrapper_classes
  WRAPPER_CLASSES
end