-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathradio_button.rb
More file actions
50 lines (45 loc) · 1.7 KB
/
radio_button.rb
File metadata and controls
50 lines (45 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# frozen_string_literal: true
module Flowbite
module Input
# The radio button component can be used to allow the user to choose a
# single option from one or more available options.
#
# https://flowbite.com/docs/forms/radio/
class RadioButton < Field
class << self
# Radio buttons only have their default size.
def sizes
{
default: ["w-4", "h-4"]
}
end
# rubocop:disable Layout/LineLength
def styles
{
default: Flowbite::Style.new(
default: ["text-blue-600", "bg-gray-100", "border-gray-300", "focus:ring-blue-500", "dark:focus:ring-blue-600", "dark:ring-offset-gray-800", "focus:ring-2", "dark:bg-gray-700", "dark:border-gray-600"],
disabled: ["text-blue-600", "bg-gray-100", "border-gray-300", "focus:ring-blue-500", "dark:focus:ring-blue-600", "dark:ring-offset-gray-800", "focus:ring-2", "dark:bg-gray-700", "dark:border-gray-600"],
error: ["text-red-600", "bg-red-50", "border-red-500", "focus:ring-red-500", "dark:focus:ring-red-600", "dark:ring-offset-gray-800", "focus:ring-2", "dark:bg-gray-700", "dark:border-red-500"]
)
}.freeze
end
end
# Returns the HTML to use for the actual input field element.
def call
@form.send(
input_field_type,
@attribute,
@value,
**input_options
)
end
def initialize(attribute:, form:, value:, disabled: false, options: {})
super(attribute: attribute, disabled: disabled, form: form, options: options)
@value = value
end
def input_field_type
:radio_button
end
end
end
end