From b7ed5fe2bb1afbb44906c407ca3d40cc9d871470 Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Fri, 26 Jun 2026 16:53:13 -0700 Subject: [PATCH 1/2] feat(block-kit): add alert block example Mirror the official docs alert block example in the Python block-kit showcase. Alert blocks display notification messages within modals. Docs: https://docs.slack.dev/reference/block-kit/blocks/alert-block Co-Authored-By: Claude --- block-kit/README.md | 1 + block-kit/src/blocks/alert.py | 16 ++++++++++++++++ block-kit/tests/blocks/test_alert.py | 17 +++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 block-kit/src/blocks/alert.py create mode 100644 block-kit/tests/blocks/test_alert.py diff --git a/block-kit/README.md b/block-kit/README.md index ee77ff0..f062272 100644 --- a/block-kit/README.md +++ b/block-kit/README.md @@ -9,6 +9,7 @@ Read the [docs](https://docs.slack.dev/block-kit/) to learn concepts behind thes ### Blocks - **[Actions](https://docs.slack.dev/reference/block-kit/blocks/actions-block)**: Holds multiple interactive elements. [Implementation](./src/blocks/actions.py). +- **[Alert](https://docs.slack.dev/reference/block-kit/blocks/alert-block)**: Displays a notification message within a modal. [Implementation](./src/blocks/alert.py). - **[Context](https://docs.slack.dev/reference/block-kit/blocks/context-block)**: Provides contextual info, which can include both images and text. [Implementation](./src/blocks/context.py). - **[Context actions](https://docs.slack.dev/reference/block-kit/blocks/context-actions-block)**: Displays actions as contextual info, which can include both feedback buttons and icon buttons. [Implementation](./src/blocks/context_actions.py). - **[Divider](https://docs.slack.dev/reference/block-kit/blocks/divider-block)**: Visually separates pieces of info inside of a message. [Implementation](./src/blocks/divider.py). diff --git a/block-kit/src/blocks/alert.py b/block-kit/src/blocks/alert.py new file mode 100644 index 0000000..316e347 --- /dev/null +++ b/block-kit/src/blocks/alert.py @@ -0,0 +1,16 @@ +from slack_sdk.models.blocks import AlertBlock +from slack_sdk.models.blocks.basic_components import MarkdownTextObject + + +def example01() -> AlertBlock: + """ + Displays a notification message within a modal. + https://docs.slack.dev/reference/block-kit/blocks/alert-block/ + + An informational alert. + """ + block = AlertBlock( + text=MarkdownTextObject(text="The work is mysterious and important."), + level="info", + ) + return block diff --git a/block-kit/tests/blocks/test_alert.py b/block-kit/tests/blocks/test_alert.py new file mode 100644 index 0000000..b1e359c --- /dev/null +++ b/block-kit/tests/blocks/test_alert.py @@ -0,0 +1,17 @@ +import json + +from src.blocks import alert + + +def test_example01(): + block = alert.example01() + actual = block.to_dict() + expected = { + "type": "alert", + "text": { + "type": "mrkdwn", + "text": "The work is mysterious and important.", + }, + "level": "info", + } + assert json.dumps(actual, sort_keys=True) == json.dumps(expected, sort_keys=True) From 96a16d99c684307e1ee0fa519e5a15fe5ff7d162 Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Fri, 26 Jun 2026 16:54:14 -0700 Subject: [PATCH 2/2] feat(block-kit): add table block example Mirrors the official table block docs example with header, text, link, and number cells alongside column settings. https://docs.slack.dev/reference/block-kit/blocks/table-block Co-Authored-By: Claude --- block-kit/README.md | 2 +- block-kit/src/blocks/table.py | 46 ++++++++++++++++++++++++++++ block-kit/tests/blocks/test_table.py | 45 +++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 block-kit/src/blocks/table.py create mode 100644 block-kit/tests/blocks/test_table.py diff --git a/block-kit/README.md b/block-kit/README.md index f062272..9316d80 100644 --- a/block-kit/README.md +++ b/block-kit/README.md @@ -9,7 +9,6 @@ Read the [docs](https://docs.slack.dev/block-kit/) to learn concepts behind thes ### Blocks - **[Actions](https://docs.slack.dev/reference/block-kit/blocks/actions-block)**: Holds multiple interactive elements. [Implementation](./src/blocks/actions.py). -- **[Alert](https://docs.slack.dev/reference/block-kit/blocks/alert-block)**: Displays a notification message within a modal. [Implementation](./src/blocks/alert.py). - **[Context](https://docs.slack.dev/reference/block-kit/blocks/context-block)**: Provides contextual info, which can include both images and text. [Implementation](./src/blocks/context.py). - **[Context actions](https://docs.slack.dev/reference/block-kit/blocks/context-actions-block)**: Displays actions as contextual info, which can include both feedback buttons and icon buttons. [Implementation](./src/blocks/context_actions.py). - **[Divider](https://docs.slack.dev/reference/block-kit/blocks/divider-block)**: Visually separates pieces of info inside of a message. [Implementation](./src/blocks/divider.py). @@ -21,5 +20,6 @@ Read the [docs](https://docs.slack.dev/block-kit/) to learn concepts behind thes - **[Plan](https://docs.slack.dev/reference/block-kit/blocks/plan-block)**: Displays a collection of related tasks. [Implementation](./src/blocks/plan.py). - **[Rich text](https://docs.slack.dev/reference/block-kit/blocks/rich-text-block)**: Displays formatted, structured representation of text. [Implementation](./src/blocks/rich_text.py). - **[Section](https://docs.slack.dev/reference/block-kit/blocks/section-block)**: Displays text, possibly alongside elements. [Implementation](./src/blocks/section.py). +- **[Table](https://docs.slack.dev/reference/block-kit/blocks/table-block)**: Displays structured data arranged in rows and columns. [Implementation](./src/blocks/table.py). - **[Task card](https://docs.slack.dev/reference/block-kit/blocks/task-card-block)**: Displays a single task, representing a single action. [Implementation](./src/blocks/task_card.py). - **[Video](https://docs.slack.dev/reference/block-kit/blocks/video-block)**: Displays an embedded video player. [Implementation](./src/blocks/video.py). diff --git a/block-kit/src/blocks/table.py b/block-kit/src/blocks/table.py new file mode 100644 index 0000000..1fa2bcc --- /dev/null +++ b/block-kit/src/blocks/table.py @@ -0,0 +1,46 @@ +from slack_sdk.models.blocks import TableBlock + + +def example01() -> TableBlock: + """ + Displays structured data arranged in rows and columns. + https://docs.slack.dev/reference/block-kit/blocks/table-block/ + + A table with header, text, link, and number cells alongside column settings. + """ + block = TableBlock( + block_id="optional_unique_id", + column_settings=[ + {"is_wrapped": True, "align": "left"}, + {"align": "right", "is_wrapped": False}, + ], + rows=[ + [ + {"type": "raw_text", "text": "Header A"}, + {"type": "raw_text", "text": "Header B"}, + ], + [ + {"type": "raw_text", "text": "Data 1A"}, + { + "type": "rich_text", + "elements": [ + { + "type": "rich_text_section", + "elements": [ + { + "type": "link", + "text": "Data 1B", + "url": "https://slack.com", + } + ], + } + ], + }, + ], + [ + {"type": "raw_text", "text": "Data 2A"}, + {"type": "raw_number", "text": "12345"}, + ], + ], + ) + return block diff --git a/block-kit/tests/blocks/test_table.py b/block-kit/tests/blocks/test_table.py new file mode 100644 index 0000000..f9b7f74 --- /dev/null +++ b/block-kit/tests/blocks/test_table.py @@ -0,0 +1,45 @@ +import json + +from src.blocks import table + + +def test_example01(): + block = table.example01() + actual = block.to_dict() + expected = { + "type": "table", + "block_id": "optional_unique_id", + "column_settings": [ + {"is_wrapped": True, "align": "left"}, + {"align": "right", "is_wrapped": False}, + ], + "rows": [ + [ + {"type": "raw_text", "text": "Header A"}, + {"type": "raw_text", "text": "Header B"}, + ], + [ + {"type": "raw_text", "text": "Data 1A"}, + { + "type": "rich_text", + "elements": [ + { + "type": "rich_text_section", + "elements": [ + { + "type": "link", + "text": "Data 1B", + "url": "https://slack.com", + } + ], + } + ], + }, + ], + [ + {"type": "raw_text", "text": "Data 2A"}, + {"type": "raw_number", "text": "12345"}, + ], + ], + } + assert json.dumps(actual, sort_keys=True) == json.dumps(expected, sort_keys=True)