Class: Slack::BlockKit::Element::OverflowMenu
- Inherits:
-
Object
- Object
- Slack::BlockKit::Element::OverflowMenu
- Defined in:
- lib/slack/block_kit/element/overflow_menu.rb
Overview
This is like a cross between a button and a select menu - when a user clicks on this overflow button, they will be presented with a list of options to choose from. Unlike the select menu, there is no typeahead field, and the button always appears with an ellipsis (“…”) rather than customisable text.
As such, it is usually used if you want a more compact layout than a select menu, or to supply a list of less visually important actions after a row of buttons.
Constant Summary collapse
- TYPE =
'overflow'
Instance Attribute Summary collapse
-
#confirm ⇒ Object
Returns the value of attribute confirm.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #as_json ⇒ Object
- #confirmation_dialog {|@confirm| ... } ⇒ Object
-
#initialize(action_id:) {|_self| ... } ⇒ OverflowMenu
constructor
A new instance of OverflowMenu.
- #option(value:, text:, emoji: nil, url: nil) ⇒ Object
Constructor Details
#initialize(action_id:) {|_self| ... } ⇒ OverflowMenu
Returns a new instance of OverflowMenu.
22 23 24 25 26 27 28 |
# File 'lib/slack/block_kit/element/overflow_menu.rb', line 22 def initialize(action_id:) @action_id = action_id = [] @confirm = nil yield(self) if block_given? end |
Instance Attribute Details
#confirm ⇒ Object
Returns the value of attribute confirm.
20 21 22 |
# File 'lib/slack/block_kit/element/overflow_menu.rb', line 20 def confirm @confirm end |
#options ⇒ Object
Returns the value of attribute options.
20 21 22 |
# File 'lib/slack/block_kit/element/overflow_menu.rb', line 20 def end |
Instance Method Details
#as_json ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/slack/block_kit/element/overflow_menu.rb', line 49 def as_json(*) { type: TYPE, action_id: @action_id, options: .map(&:as_json), confirm: @confirm&.as_json }.compact end |
#confirmation_dialog {|@confirm| ... } ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/slack/block_kit/element/overflow_menu.rb', line 41 def confirmation_dialog @confirm = Composition::ConfirmationDialog.new yield(@confirm) if block_given? self end |
#option(value:, text:, emoji: nil, url: nil) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/slack/block_kit/element/overflow_menu.rb', line 30 def option(value:, text:, emoji: nil, url: nil) << Composition::Option.new( value: value, text: text, emoji: emoji, url: url ) self end |