Class: Plushie::Widget::Checkbox
- Inherits:
-
Object
- Object
- Plushie::Widget::Checkbox
- Defined in:
- lib/plushie/widget/checkbox.rb
Overview
Constant Summary collapse
- PROPS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Supported property keys for this widget.
i[label is_toggled spacing width size text_size font line_height shaping wrapping style icon disabled a11y].freeze
Instance Attribute Summary collapse
-
#a11y ⇒ Object
readonly
Returns the value of attribute a11y.
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#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.
-
#is_toggled ⇒ Object
readonly
Returns the value of attribute is_toggled.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#line_height ⇒ Object
readonly
Returns the value of attribute line_height.
-
#shaping ⇒ Object
readonly
Returns the value of attribute shaping.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#spacing ⇒ Object
readonly
Returns the value of attribute spacing.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
-
#text_size ⇒ Object
readonly
Returns the value of attribute text_size.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
-
#wrapping ⇒ Object
readonly
Returns the value of attribute wrapping.
Instance Method Summary collapse
-
#build ⇒ Plushie::Node
Build a Node from the current property values.
-
#initialize(id, label, is_toggled = false, **opts) ⇒ Checkbox
constructor
A new instance of Checkbox.
Constructor Details
#initialize(id, label, is_toggled = false, **opts) ⇒ Checkbox
Returns a new instance of Checkbox.
19 20 21 22 23 24 25 |
# File 'lib/plushie/widget/checkbox.rb', line 19 def initialize(id, label, is_toggled = false, **opts) @id = id.to_s @label = label @is_toggled = is_toggled PROPS.each { |k| instance_variable_set(:"@#{k}", opts[k]) if opts.key?(k) } @label = opts[:label] if opts.key?(:label) end |
Instance Attribute Details
#a11y ⇒ Object (readonly)
Returns the value of attribute a11y.
1 2 3 |
# File 'lib/plushie/widget/checkbox.rb', line 1 def a11y @a11y end |
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
1 2 3 |
# File 'lib/plushie/widget/checkbox.rb', line 1 def disabled @disabled end |
#font ⇒ Object (readonly)
Returns the value of attribute font.
1 2 3 |
# File 'lib/plushie/widget/checkbox.rb', line 1 def font @font end |
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
1 2 3 |
# File 'lib/plushie/widget/checkbox.rb', line 1 def icon @icon end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
1 2 3 |
# File 'lib/plushie/widget/checkbox.rb', line 1 def id @id end |
#is_toggled ⇒ Object (readonly)
Returns the value of attribute is_toggled.
1 2 3 |
# File 'lib/plushie/widget/checkbox.rb', line 1 def is_toggled @is_toggled end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
1 2 3 |
# File 'lib/plushie/widget/checkbox.rb', line 1 def label @label end |
#line_height ⇒ Object (readonly)
Returns the value of attribute line_height.
1 2 3 |
# File 'lib/plushie/widget/checkbox.rb', line 1 def line_height @line_height end |
#shaping ⇒ Object (readonly)
Returns the value of attribute shaping.
1 2 3 |
# File 'lib/plushie/widget/checkbox.rb', line 1 def shaping @shaping end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
1 2 3 |
# File 'lib/plushie/widget/checkbox.rb', line 1 def size @size end |
#spacing ⇒ Object (readonly)
Returns the value of attribute spacing.
1 2 3 |
# File 'lib/plushie/widget/checkbox.rb', line 1 def spacing @spacing end |
#style ⇒ Object (readonly)
Returns the value of attribute style.
1 2 3 |
# File 'lib/plushie/widget/checkbox.rb', line 1 def style @style end |
#text_size ⇒ Object (readonly)
Returns the value of attribute text_size.
1 2 3 |
# File 'lib/plushie/widget/checkbox.rb', line 1 def text_size @text_size end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
1 2 3 |
# File 'lib/plushie/widget/checkbox.rb', line 1 def width @width end |
#wrapping ⇒ Object (readonly)
Returns the value of attribute wrapping.
1 2 3 |
# File 'lib/plushie/widget/checkbox.rb', line 1 def wrapping @wrapping end |
Instance Method Details
#build ⇒ Plushie::Node
Build a Node from the current property values.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/plushie/widget/checkbox.rb', line 36 def build props = {} Build.put_if(props, :label, @label) Build.put_if(props, :checked, @is_toggled) Build.put_if(props, :spacing, @spacing) Build.put_if(props, :width, @width) Build.put_if(props, :size, @size) Build.put_if(props, :text_size, @text_size) Build.put_if(props, :font, @font) Build.put_if(props, :line_height, @line_height) Build.put_if(props, :shaping, @shaping) Build.put_if(props, :wrapping, @wrapping) Build.put_if(props, :style, @style) Build.put_if(props, :icon, @icon) Build.put_if(props, :disabled, @disabled) Build.put_if(props, :a11y, @a11y) Node.new(id: @id, type: "checkbox", props: props) end |