utils.blocks¶
Block generation utility module for pre-defined block payloads
-
slack_blockkit.utils.blocks.
get_checkmark
(task_completed: bool) → str¶ Returns a check mark emoji indicating the completed task status. If the task is complete, then a white check mark is returned. If not, an empty white square is.
- Parameters
task_completed (bool) – Whether or not the task was complete.
- Returns
A checkmark emoji string based on whether or not the task was completed.
- Return type
str
-
slack_blockkit.utils.blocks.
get_information_block
(link: str, text: str) → dict¶ Returns an information block, which is a section with an info icon followed by linked text.
- Parameters
link (str) – The link the block redirects the user to.
text (str) – The link text.
- Returns
A dict in the format of a context block.
- Return type
dict
-
slack_blockkit.utils.blocks.
get_task_block
(text: str, info_link: str, info_text: str) → list¶ Returns a task block, which is comprised of a paragraph of text followed by an information link at the bottom.
- Parameters
text (str) – Markdown-supported text to display in the paragraph.
info_link (str) – The link associated with the task block.
info_text (str) – The link text.
- Returns
An array of blocks formatted for a block payload.
- Return type
list
-
slack_blockkit.utils.blocks.
get_text_block_with_accessory
(text_object: slack_blockkit.composition_object.TextObject, accessory: slack_blockkit.block_element.BlockElement) → dict¶ Returns a text block with an accessory.
- Parameters
text_object (TextObject) – The text block object.
accessory (LayoutBlock) – The accessory object.
- Returns
The text block with an accessory layout block.
- Return type
dict
-
slack_blockkit.utils.blocks.
get_text_block_with_image
(text: str, image_url: str, alt_text: str) → dict¶ Returns a text block with an image to the right of it.
- Parameters
text (str) – The text in the text block.
image_url (str) – The URL to the image.
alt_text (str) – Alternate text (appears on image hover).
- Returns
The block as a dict.
- Return type
dict