Class: Plushie::Widget::TextInput
- Inherits:
-
Object
- Object
- Plushie::Widget::TextInput
- Defined in:
- lib/plushie/widget/text_input.rb
Overview
Typed builder for the single-line text input widget (Layer 2 API).
Construct a TextInput, configure via fluent +set_*+ methods, then call #build to produce a Node.
PROPS: value, placeholder, padding, width, size, font, line_height, align_x, icon, on_submit, on_paste, secure, ime_purpose, style, placeholder_color, selection_color, a11y.
Constant Summary collapse
- PROPS =
Supported property keys for the text input widget.
%i[value placeholder padding width size font line_height align_x icon on_submit on_paste secure ime_purpose style placeholder_color selection_color a11y].freeze
Instance Attribute Summary collapse
-
#a11y ⇒ Object
readonly
Returns the value of attribute a11y.
-
#align_x ⇒ Object
readonly
Returns the value of attribute align_x.
-
#font ⇒ Object
readonly
Returns the value of attribute font.
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#ime_purpose ⇒ Object
readonly
Returns the value of attribute ime_purpose.
-
#line_height ⇒ Object
readonly
Returns the value of attribute line_height.
-
#on_paste ⇒ Object
readonly
Returns the value of attribute on_paste.
-
#on_submit ⇒ Object
readonly
Returns the value of attribute on_submit.
-
#padding ⇒ Object
readonly
Returns the value of attribute padding.
-
#placeholder ⇒ Object
readonly
Returns the value of attribute placeholder.
-
#placeholder_color ⇒ Object
readonly
Returns the value of attribute placeholder_color.
-
#secure ⇒ Object
readonly
Returns the value of attribute secure.
-
#selection_color ⇒ Object
readonly
Returns the value of attribute selection_color.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#build ⇒ Plushie::Node
Build a Node from the current property values.
-
#initialize(id, value = "", **opts) ⇒ TextInput
constructor
A new instance of TextInput.
Constructor Details
#initialize(id, value = "", **opts) ⇒ TextInput
Returns a new instance of TextInput.
31 32 33 34 35 36 |
# File 'lib/plushie/widget/text_input.rb', line 31 def initialize(id, value = "", **opts) @id = id.to_s @value = value PROPS.each { |k| instance_variable_set(:"@#{k}", opts[k]) if opts.key?(k) } @value = opts[:value] if opts.key?(:value) end |
Instance Attribute Details
#a11y ⇒ Object (readonly)
Returns the value of attribute a11y.
1 2 3 |
# File 'lib/plushie/widget/text_input.rb', line 1 def a11y @a11y end |
#align_x ⇒ Object (readonly)
Returns the value of attribute align_x.
1 2 3 |
# File 'lib/plushie/widget/text_input.rb', line 1 def align_x @align_x end |
#font ⇒ Object (readonly)
Returns the value of attribute font.
1 2 3 |
# File 'lib/plushie/widget/text_input.rb', line 1 def font @font end |
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
1 2 3 |
# File 'lib/plushie/widget/text_input.rb', line 1 def icon @icon end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
1 2 3 |
# File 'lib/plushie/widget/text_input.rb', line 1 def id @id end |
#ime_purpose ⇒ Object (readonly)
Returns the value of attribute ime_purpose.
1 2 3 |
# File 'lib/plushie/widget/text_input.rb', line 1 def ime_purpose @ime_purpose end |
#line_height ⇒ Object (readonly)
Returns the value of attribute line_height.
1 2 3 |
# File 'lib/plushie/widget/text_input.rb', line 1 def line_height @line_height end |
#on_paste ⇒ Object (readonly)
Returns the value of attribute on_paste.
1 2 3 |
# File 'lib/plushie/widget/text_input.rb', line 1 def on_paste @on_paste end |
#on_submit ⇒ Object (readonly)
Returns the value of attribute on_submit.
1 2 3 |
# File 'lib/plushie/widget/text_input.rb', line 1 def on_submit @on_submit end |
#padding ⇒ Object (readonly)
Returns the value of attribute padding.
1 2 3 |
# File 'lib/plushie/widget/text_input.rb', line 1 def padding @padding end |
#placeholder ⇒ Object (readonly)
Returns the value of attribute placeholder.
1 2 3 |
# File 'lib/plushie/widget/text_input.rb', line 1 def placeholder @placeholder end |
#placeholder_color ⇒ Object (readonly)
Returns the value of attribute placeholder_color.
1 2 3 |
# File 'lib/plushie/widget/text_input.rb', line 1 def placeholder_color @placeholder_color end |
#secure ⇒ Object (readonly)
Returns the value of attribute secure.
1 2 3 |
# File 'lib/plushie/widget/text_input.rb', line 1 def secure @secure end |
#selection_color ⇒ Object (readonly)
Returns the value of attribute selection_color.
1 2 3 |
# File 'lib/plushie/widget/text_input.rb', line 1 def selection_color @selection_color end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
1 2 3 |
# File 'lib/plushie/widget/text_input.rb', line 1 def size @size end |
#style ⇒ Object (readonly)
Returns the value of attribute style.
1 2 3 |
# File 'lib/plushie/widget/text_input.rb', line 1 def style @style end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
1 2 3 |
# File 'lib/plushie/widget/text_input.rb', line 1 def value @value end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
1 2 3 |
# File 'lib/plushie/widget/text_input.rb', line 1 def width @width end |
Instance Method Details
#build ⇒ Plushie::Node
Build a Node from the current property values.
47 48 49 50 51 52 53 54 |
# File 'lib/plushie/widget/text_input.rb', line 47 def build props = {} PROPS.each do |key| val = instance_variable_get(:"@#{key}") Build.put_if(props, key, val) end Node.new(id: @id, type: "text_input", props: props) end |