Class: Keystone::Ui::RadioCardComponent

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

Constant Summary collapse

BASE_CLASSES =
"block p-4 rounded-lg border-2 cursor-pointer transition"
HIGHLIGHT_CLASSES =
"border-surface-200 peer-checked:border-accent-500 peer-checked:bg-accent-50"
LABEL_CLASSES =
"block font-medium text-surface-900"
HINT_CLASSES =
"block mt-1 text-sm text-surface-500"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, value:, label:, hint: nil, checked: false) ⇒ RadioCardComponent

Returns a new instance of RadioCardComponent.



13
14
15
16
17
18
19
# File 'app/components/keystone/ui/radio_card_component.rb', line 13

def initialize(name:, value:, label:, hint: nil, checked: false)
  @name = name
  @value = value
  @label = label
  @hint = hint
  @checked = checked
end

Instance Attribute Details

#hintObject (readonly)

Returns the value of attribute hint.



11
12
13
# File 'app/components/keystone/ui/radio_card_component.rb', line 11

def hint
  @hint
end

#labelObject (readonly)

Returns the value of attribute label.



11
12
13
# File 'app/components/keystone/ui/radio_card_component.rb', line 11

def label
  @label
end

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'app/components/keystone/ui/radio_card_component.rb', line 11

def name
  @name
end

#valueObject (readonly)

Returns the value of attribute value.



11
12
13
# File 'app/components/keystone/ui/radio_card_component.rb', line 11

def value
  @value
end

Instance Method Details

#checked?Boolean

Returns:

  • (Boolean)


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

def checked?
  @checked
end

#classesObject



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

def classes
  "#{BASE_CLASSES} #{HIGHLIGHT_CLASSES}"
end

#hint?Boolean

Returns:

  • (Boolean)


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

def hint?
  !@hint.nil?
end

#hint_classesObject



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

def hint_classes
  HINT_CLASSES
end

#label_classesObject



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

def label_classes
  LABEL_CLASSES
end