Class: Keystone::Ui::SelectComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Keystone::Ui::SelectComponent
- Defined in:
- app/components/keystone/ui/select_component.rb
Constant Summary collapse
- BASE_CLASSES =
"block w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 focus:outline-none focus:ring-1 dark:bg-zinc-900 dark:border-zinc-700 dark:text-white"- DISABLED_CLASSES =
"cursor-not-allowed bg-gray-50 text-gray-500 dark:bg-zinc-800 dark:text-gray-400"- FOCUS_CLASSES =
"focus:border-accent-500 focus:ring-accent-500 dark:focus:border-accent-400 dark:focus:ring-accent-400"
Instance Attribute Summary collapse
-
#include_blank ⇒ Object
readonly
Returns the value of attribute include_blank.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#selected ⇒ Object
readonly
Returns the value of attribute selected.
Instance Method Summary collapse
- #classes ⇒ Object
-
#initialize(name:, options: [], selected: nil, include_blank: nil, disabled: false) ⇒ SelectComponent
constructor
A new instance of SelectComponent.
- #tag_options ⇒ Object
Constructor Details
#initialize(name:, options: [], selected: nil, include_blank: nil, disabled: false) ⇒ SelectComponent
Returns a new instance of SelectComponent.
12 13 14 15 16 17 18 |
# File 'app/components/keystone/ui/select_component.rb', line 12 def initialize(name:, options: [], selected: nil, include_blank: nil, disabled: false) @name = name @options = @selected = selected @include_blank = include_blank @disabled = disabled end |
Instance Attribute Details
#include_blank ⇒ Object (readonly)
Returns the value of attribute include_blank.
10 11 12 |
# File 'app/components/keystone/ui/select_component.rb', line 10 def include_blank @include_blank end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'app/components/keystone/ui/select_component.rb', line 10 def @options end |
#selected ⇒ Object (readonly)
Returns the value of attribute selected.
10 11 12 |
# File 'app/components/keystone/ui/select_component.rb', line 10 def selected @selected end |
Instance Method Details
#classes ⇒ Object
22 23 24 25 26 |
# File 'app/components/keystone/ui/select_component.rb', line 22 def classes tokens = [ BASE_CLASSES, FOCUS_CLASSES ] tokens << DISABLED_CLASSES if @disabled tokens.join(" ") end |
#tag_options ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'app/components/keystone/ui/select_component.rb', line 28 def opts = { name: @name, class: classes } opts[:disabled] = true if @disabled opts end |