Class: Plushie::Widget::Stack
- Inherits:
-
Object
- Object
- Plushie::Widget::Stack
- Defined in:
- lib/plushie/widget/stack.rb
Overview
Stack layout -- layers children on top of each other.
Props:
- width (length) -- stack width.
- height (length) -- stack height.
- clip (boolean) -- clip overflowing children.
- 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[width height clip a11y].freeze
Instance Attribute Summary collapse
-
#a11y ⇒ Object
readonly
Returns the value of attribute a11y.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#clip ⇒ Object
readonly
Returns the value of attribute clip.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #build ⇒ Plushie::Node
-
#initialize(id, **opts) ⇒ Stack
constructor
A new instance of Stack.
-
#push(child) ⇒ Stack
Append a child widget.
Constructor Details
Instance Attribute Details
#a11y ⇒ Object (readonly)
Returns the value of attribute a11y.
1 2 3 |
# File 'lib/plushie/widget/stack.rb', line 1 def a11y @a11y end |
#children ⇒ Object (readonly)
Returns the value of attribute children.
1 2 3 |
# File 'lib/plushie/widget/stack.rb', line 1 def children @children end |
#clip ⇒ Object (readonly)
Returns the value of attribute clip.
1 2 3 |
# File 'lib/plushie/widget/stack.rb', line 1 def clip @clip end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
1 2 3 |
# File 'lib/plushie/widget/stack.rb', line 1 def height @height end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
1 2 3 |
# File 'lib/plushie/widget/stack.rb', line 1 def id @id end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
1 2 3 |
# File 'lib/plushie/widget/stack.rb', line 1 def width @width end |
Instance Method Details
#build ⇒ Plushie::Node
49 50 51 52 53 54 55 56 57 |
# File 'lib/plushie/widget/stack.rb', line 49 def build props = {} PROPS.each do |key| val = instance_variable_get(:"@#{key}") Build.put_if(props, key, val) end Node.new(id: @id, type: "stack", props: props, children: Build.children_to_nodes(@children)) end |
#push(child) ⇒ Stack
Append a child widget.
44 45 46 |
# File 'lib/plushie/widget/stack.rb', line 44 def push(child) dup.tap { _1.instance_variable_set(:@children, @children + [child]) } end |