Class: Keystone::Ui::OptionCardComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Keystone::Ui::OptionCardComponent
- Defined in:
- app/components/keystone/ui/option_card_component.rb
Constant Summary collapse
- BASE_CLASSES =
"inline-flex items-center gap-2 px-3 py-2 rounded-lg border-2 transition cursor-pointer"
Instance Attribute Summary collapse
-
#input_data ⇒ Object
readonly
Returns the value of attribute input_data.
-
#label_data ⇒ Object
readonly
Returns the value of attribute label_data.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #classes ⇒ Object
-
#initialize(name:, value:, selected: false, input_data: {}, label_data: {}) ⇒ OptionCardComponent
constructor
A new instance of OptionCardComponent.
- #selected? ⇒ Boolean
Constructor Details
#initialize(name:, value:, selected: false, input_data: {}, label_data: {}) ⇒ OptionCardComponent
Returns a new instance of OptionCardComponent.
10 11 12 13 14 15 16 |
# File 'app/components/keystone/ui/option_card_component.rb', line 10 def initialize(name:, value:, selected: false, input_data: {}, label_data: {}) @name = name @value = value @selected = selected @input_data = input_data @label_data = label_data end |
Instance Attribute Details
#input_data ⇒ Object (readonly)
Returns the value of attribute input_data.
8 9 10 |
# File 'app/components/keystone/ui/option_card_component.rb', line 8 def input_data @input_data end |
#label_data ⇒ Object (readonly)
Returns the value of attribute label_data.
8 9 10 |
# File 'app/components/keystone/ui/option_card_component.rb', line 8 def label_data @label_data end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'app/components/keystone/ui/option_card_component.rb', line 8 def name @name end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
8 9 10 |
# File 'app/components/keystone/ui/option_card_component.rb', line 8 def value @value end |
Instance Method Details
#classes ⇒ Object
22 23 24 25 |
# File 'app/components/keystone/ui/option_card_component.rb', line 22 def classes border = selected? ? "border-accent-500" : "border-transparent" "#{BASE_CLASSES} #{border}" end |
#selected? ⇒ Boolean
18 19 20 |
# File 'app/components/keystone/ui/option_card_component.rb', line 18 def selected? @selected end |