Class: UI::Checkbox

Inherits:
Phlex::HTML
  • Object
show all
Includes:
CheckboxBehavior
Defined in:
app/components/ui/checkbox.rb

Instance Method Summary collapse

Methods included from CheckboxBehavior

#checkbox_classes, #checkbox_data_attributes, #checkbox_html_attributes, #checkbox_id

Constructor Details

#initialize(name: nil, id: nil, value: nil, checked: false, disabled: false, required: false, classes: "", **attributes) ⇒ Checkbox

Returns a new instance of Checkbox.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/components/ui/checkbox.rb', line 6

def initialize(
  name: nil,
  id: nil,
  value: nil,
  checked: false,
  disabled: false,
  required: false,
  classes: "",
  **attributes
)
  @name = name
  @id = id
  @value = value
  @checked = checked
  @disabled = disabled
  @required = required
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#view_templateObject



26
27
28
29
30
31
# File 'app/components/ui/checkbox.rb', line 26

def view_template
  div(class: "relative inline-flex items-center justify-center") do
    input(**checkbox_html_attributes)
    checkmark_icon
  end
end