Class: BetterUi::General::Input::Pin::Component
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- BetterUi::General::Input::Pin::Component
- Defined in:
- app/components/better_ui/general/input/pin/component.rb
Constant Summary collapse
- PIN_THEME =
Costanti con classi Tailwind dirette
{ default: 'border-gray-300 focus:border-blue-500 focus:ring-blue-500', white: 'border-gray-300 bg-white focus:border-gray-900 focus:ring-gray-900', red: 'border-red-300 focus:border-red-500 focus:ring-red-500', rose: 'border-rose-300 focus:border-rose-500 focus:ring-rose-500', orange: 'border-orange-300 focus:border-orange-500 focus:ring-orange-500', green: 'border-green-300 focus:border-green-500 focus:ring-green-500', blue: 'border-blue-300 focus:border-blue-500 focus:ring-blue-500', yellow: 'border-yellow-300 focus:border-yellow-500 focus:ring-yellow-500', violet: 'border-violet-300 focus:border-violet-500 focus:ring-violet-500' }.freeze
- PIN_SIZE =
{ small: 'w-8 h-8 text-sm', medium: 'w-12 h-12 text-base', large: 'w-16 h-16 text-lg' }.freeze
- PIN_GAP =
{ small: 'gap-2', medium: 'gap-3', large: 'gap-4' }.freeze
- PIN_BASE_CLASSES =
'rounded-md border text-center font-mono focus:outline-none focus:ring-2 focus:ring-offset-1 transition-colors'.freeze
Instance Attribute Summary collapse
-
#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.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#placeholder ⇒ Object
readonly
Returns the value of attribute placeholder.
-
#required ⇒ Object
readonly
Returns the value of attribute required.
-
#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: '', length: 6, placeholder: '•', required: false, disabled: false, theme: :default, size: :medium, form: nil, classes: '', **options) ⇒ Component
constructor
A new instance of Component.
Constructor Details
#initialize(name:, value: '', length: 6, placeholder: '•', required: false, disabled: false, theme: :default, size: :medium, form: nil, classes: '', **options) ⇒ Component
Returns a new instance of Component.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/components/better_ui/general/input/pin/component.rb', line 49 def initialize(name:, value: '', length: 6, placeholder: '•', required: false, disabled: false, theme: :default, size: :medium, form: nil, classes: '', **) @name = name @value = value.to_s @length = length.to_i @placeholder = placeholder @required = required @disabled = disabled @theme = theme.to_sym @size = size.to_sym @form = form @classes = classes @options = validate_params end |
Instance Attribute Details
#classes ⇒ Object (readonly)
Returns the value of attribute classes.
35 36 37 |
# File 'app/components/better_ui/general/input/pin/component.rb', line 35 def classes @classes end |
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
35 36 37 |
# File 'app/components/better_ui/general/input/pin/component.rb', line 35 def disabled @disabled end |
#form ⇒ Object (readonly)
Returns the value of attribute form.
35 36 37 |
# File 'app/components/better_ui/general/input/pin/component.rb', line 35 def form @form end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
35 36 37 |
# File 'app/components/better_ui/general/input/pin/component.rb', line 35 def length @length end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
35 36 37 |
# File 'app/components/better_ui/general/input/pin/component.rb', line 35 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
35 36 37 |
# File 'app/components/better_ui/general/input/pin/component.rb', line 35 def @options end |
#placeholder ⇒ Object (readonly)
Returns the value of attribute placeholder.
35 36 37 |
# File 'app/components/better_ui/general/input/pin/component.rb', line 35 def placeholder @placeholder end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
35 36 37 |
# File 'app/components/better_ui/general/input/pin/component.rb', line 35 def required @required end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
35 36 37 |
# File 'app/components/better_ui/general/input/pin/component.rb', line 35 def size @size end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
35 36 37 |
# File 'app/components/better_ui/general/input/pin/component.rb', line 35 def theme @theme end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
35 36 37 |
# File 'app/components/better_ui/general/input/pin/component.rb', line 35 def value @value end |