Support for Block Kit header and button accessory #116
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
In order to create a more complex slack message, I needed to add support for the Block Kit Header element, and add optional Accessories to Section elements. Headers are a short but high-level, large, bold plaintext element. Accessories allow Block Elements to float to the right of a Section block, to provide small buttons and images close to the section they are related to. Accessories provide a better usage of horizontal space in messages, and prevent using another vertical block row for an element where unnecessary.
Documentation
Relevant Slack API Links
Header Blocks
Section Blocks
List of Block Elements, also called Element Objects, e.g. buttons
Code Feature Changes
SlackBlock
type, accepting oneSlackPlainTextOnly
element, with a comment noting amaxlength
of 150, which is done similarly to other implemented types.Maybe SlackAccessory
, to allow the option of tagging one on to the right of a section of text.SlackButtonAccessory
, which takes aSlackAction
(button).SlackBlockImage
which provides the fully-implemented typeSlackImage
, but was not within my scope of work at this time.Effects
SlackBlockSection
provided by this repo will now need to update their code to reflect the addition of theMaybe SlackAccessory
which was not previously defined. Providing a simpleNothing
after theSlackText
provided to the data constructor is sufficient. Given that this code is marked Experimental and development is ongoing, changes like this should not be too surprising.This repo does not provide coded nor documentation of tests for Block Kit elements.