Class: BetterUi::General::Input::Checkbox::Component
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- BetterUi::General::Input::Checkbox::Component
- Defined in:
- app/components/better_ui/general/input/checkbox/component.rb
Constant Summary collapse
- CHECKBOX_THEME =
Costanti con classi Tailwind dirette
{ default: 'border-gray-300 text-gray-800 focus:border-gray-600 focus:ring-gray-600 checked:bg-gray-800 checked:border-gray-800', white: 'border-gray-300 text-gray-900 focus:border-gray-500 focus:ring-gray-500 checked:bg-white checked:border-gray-900 checked:text-gray-900', red: 'border-gray-300 text-red-600 focus:border-red-500 focus:ring-red-500 checked:bg-red-600 checked:border-red-600', rose: 'border-gray-300 text-rose-600 focus:border-rose-500 focus:ring-rose-500 checked:bg-rose-600 checked:border-rose-600', orange: 'border-gray-300 text-orange-600 focus:border-orange-500 focus:ring-orange-500 checked:bg-orange-600 checked:border-orange-600', green: 'border-gray-300 text-green-600 focus:border-green-500 focus:ring-green-500 checked:bg-green-600 checked:border-green-600', blue: 'border-gray-300 text-blue-600 focus:border-blue-500 focus:ring-blue-500 checked:bg-blue-600 checked:border-blue-600', yellow: 'border-gray-300 text-yellow-600 focus:border-yellow-500 focus:ring-yellow-500 checked:bg-yellow-600 checked:border-yellow-600', violet: 'border-gray-300 text-violet-600 focus:border-violet-500 focus:ring-violet-500 checked:bg-violet-600 checked:border-violet-600' }.freeze
- CHECKBOX_SIZE =
{ small: 'h-2.5 w-2.5', medium: 'h-3 w-3', large: 'h-4 w-4' }.freeze
- CHECKBOX_ROUNDED =
{ none: 'rounded-none', small: 'rounded-sm', medium: 'rounded', large: 'rounded-lg', full: 'rounded-full' }.freeze
- CHECKBOX_BASE_CLASSES =
'appearance-none border-2 focus:outline-none focus:ring-2 focus:ring-offset-2 transition-colors duration-200 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50'.freeze
- CHECKBOX_LABEL_GAP =
{ small: 'gap-1.5', medium: 'gap-2', large: 'gap-2.5' }.freeze
- CHECKBOX_LABEL_TEXT =
{ small: 'text-xs', medium: 'text-sm', large: 'text-base' }.freeze
Instance Attribute Summary collapse
-
#checked ⇒ Object
readonly
Returns the value of attribute checked.
-
#classes ⇒ Object
readonly
Returns the value of attribute classes.
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#form ⇒ Object
readonly
Returns the value of attribute form.
-
#indeterminate ⇒ Object
readonly
Returns the value of attribute indeterminate.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#label_position ⇒ Object
readonly
Returns the value of attribute label_position.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#required ⇒ Object
readonly
Returns the value of attribute required.
-
#rounded ⇒ Object
readonly
Returns the value of attribute rounded.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(name:, value: "1", checked: false, required: false, disabled: false, indeterminate: false, label: nil, label_position: :right, theme: :default, size: :medium, rounded: :medium, classes: '', form: nil, **options) ⇒ Component
constructor
A new instance of Component.
Constructor Details
#initialize(name:, value: "1", checked: false, required: false, disabled: false, indeterminate: false, label: nil, label_position: :right, theme: :default, size: :medium, rounded: :medium, classes: '', form: nil, **options) ⇒ Component
Returns a new instance of Component.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'app/components/better_ui/general/input/checkbox/component.rb', line 66 def initialize(name:, value: "1", checked: false, required: false, disabled: false, indeterminate: false, label: nil, label_position: :right, theme: :default, size: :medium, rounded: :medium, classes: '', form: nil, **) @name = name @value = value @checked = checked @required = required @disabled = disabled @indeterminate = indeterminate @label = label @label_position = label_position.to_sym @theme = theme.to_sym @size = size.to_sym @rounded = rounded.to_sym @classes = classes @form = form @options = validate_params end |
Instance Attribute Details
#checked ⇒ Object (readonly)
Returns the value of attribute checked.
49 50 51 |
# File 'app/components/better_ui/general/input/checkbox/component.rb', line 49 def checked @checked end |
#classes ⇒ Object (readonly)
Returns the value of attribute classes.
49 50 51 |
# File 'app/components/better_ui/general/input/checkbox/component.rb', line 49 def classes @classes end |
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
49 50 51 |
# File 'app/components/better_ui/general/input/checkbox/component.rb', line 49 def disabled @disabled end |
#form ⇒ Object (readonly)
Returns the value of attribute form.
49 50 51 |
# File 'app/components/better_ui/general/input/checkbox/component.rb', line 49 def form @form end |
#indeterminate ⇒ Object (readonly)
Returns the value of attribute indeterminate.
49 50 51 |
# File 'app/components/better_ui/general/input/checkbox/component.rb', line 49 def indeterminate @indeterminate end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
49 50 51 |
# File 'app/components/better_ui/general/input/checkbox/component.rb', line 49 def label @label end |
#label_position ⇒ Object (readonly)
Returns the value of attribute label_position.
49 50 51 |
# File 'app/components/better_ui/general/input/checkbox/component.rb', line 49 def label_position @label_position end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
49 50 51 |
# File 'app/components/better_ui/general/input/checkbox/component.rb', line 49 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
49 50 51 |
# File 'app/components/better_ui/general/input/checkbox/component.rb', line 49 def @options end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
49 50 51 |
# File 'app/components/better_ui/general/input/checkbox/component.rb', line 49 def required @required end |
#rounded ⇒ Object (readonly)
Returns the value of attribute rounded.
49 50 51 |
# File 'app/components/better_ui/general/input/checkbox/component.rb', line 49 def rounded @rounded end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
49 50 51 |
# File 'app/components/better_ui/general/input/checkbox/component.rb', line 49 def size @size end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
49 50 51 |
# File 'app/components/better_ui/general/input/checkbox/component.rb', line 49 def theme @theme end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
49 50 51 |
# File 'app/components/better_ui/general/input/checkbox/component.rb', line 49 def value @value end |