Class: Plushie::Widget::KeyedColumn
- Inherits:
-
Object
- Object
- Plushie::Widget::KeyedColumn
- Defined in:
- lib/plushie/widget/keyed_column.rb
Overview
Keyed column layout -- vertical layout with stable identity keys.
Props:
- spacing (number) -- vertical space between children in pixels.
- padding (number|hash) -- padding inside the column.
- width (length) -- column width.
- height (length) -- column height.
- max_width (number) -- maximum width in pixels.
- a11y (hash) -- accessibility overrides.
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[spacing padding width height max_width a11y].freeze
Instance Attribute Summary collapse
-
#a11y ⇒ Object
readonly
Returns the value of attribute a11y.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#max_width ⇒ Object
readonly
Returns the value of attribute max_width.
-
#padding ⇒ Object
readonly
Returns the value of attribute padding.
-
#spacing ⇒ Object
readonly
Returns the value of attribute spacing.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #build ⇒ Plushie::Node
-
#initialize(id, **opts) ⇒ KeyedColumn
constructor
A new instance of KeyedColumn.
-
#push(child) ⇒ KeyedColumn
Append a child widget.
Constructor Details
#initialize(id, **opts) ⇒ KeyedColumn
Returns a new instance of KeyedColumn.
30 31 32 33 34 |
# File 'lib/plushie/widget/keyed_column.rb', line 30 def initialize(id, **opts) @id = id.to_s @children = opts.delete(:children) || [] PROPS.each { |k| instance_variable_set(:"@#{k}", opts[k]) if opts.key?(k) } end |
Instance Attribute Details
#a11y ⇒ Object (readonly)
Returns the value of attribute a11y.
1 2 3 |
# File 'lib/plushie/widget/keyed_column.rb', line 1 def a11y @a11y end |
#children ⇒ Object (readonly)
Returns the value of attribute children.
1 2 3 |
# File 'lib/plushie/widget/keyed_column.rb', line 1 def children @children end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
1 2 3 |
# File 'lib/plushie/widget/keyed_column.rb', line 1 def height @height end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
1 2 3 |
# File 'lib/plushie/widget/keyed_column.rb', line 1 def id @id end |
#max_width ⇒ Object (readonly)
Returns the value of attribute max_width.
1 2 3 |
# File 'lib/plushie/widget/keyed_column.rb', line 1 def max_width @max_width end |
#padding ⇒ Object (readonly)
Returns the value of attribute padding.
1 2 3 |
# File 'lib/plushie/widget/keyed_column.rb', line 1 def padding @padding end |
#spacing ⇒ Object (readonly)
Returns the value of attribute spacing.
1 2 3 |
# File 'lib/plushie/widget/keyed_column.rb', line 1 def spacing @spacing end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
1 2 3 |
# File 'lib/plushie/widget/keyed_column.rb', line 1 def width @width end |
Instance Method Details
#build ⇒ Plushie::Node
50 51 52 53 54 55 56 57 58 |
# File 'lib/plushie/widget/keyed_column.rb', line 50 def build props = {} PROPS.each do |key| val = instance_variable_get(:"@#{key}") Build.put_if(props, key, val) end Node.new(id: @id, type: "keyed_column", props: props, children: Build.children_to_nodes(@children)) end |
#push(child) ⇒ KeyedColumn
Append a child widget.
45 46 47 |
# File 'lib/plushie/widget/keyed_column.rb', line 45 def push(child) dup.tap { _1.instance_variable_set(:@children, @children + [child]) } end |