Skip to content

Commit a4fad17

Browse files
committed
feat: showcase the 'actions' block matching examples in documentation
0 parents  commit a4fad17

File tree

12 files changed

+266
-0
lines changed

12 files changed

+266
-0
lines changed

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
- package-ecosystem: "pip"
8+
directory: "block-kit"
9+
schedule:
10+
interval: "daily"

.github/workflows/test.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Test
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
jobs:
8+
test:
9+
name: "pytest@python3.13"
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
showcase:
14+
- "block-kit"
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v5
18+
- name: Install Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: "3.13"
22+
- name: Run tests
23+
run: |
24+
cd "${{ matrix.showcase }}"
25+
pip install -r requirements.txt
26+
ruff check
27+
ruff format --diff --check
28+
mypy ./**/*.py
29+
pytest -v

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Bolt for Python Showcase
2+
3+
This collections of examples highlights features of a Slack app in the language of Bolt for Python.
4+
5+
## Available demonstration
6+
7+
- **[Block Kit](./block-kit)**: The framework of visual components arranged to create app layouts.

block-kit/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
__pycache__
2+
.mypy_cache
3+
.pytest_cache
4+
.ruff_cache
5+
.venv

block-kit/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Block Kit
2+
3+
The framework of visual components arranged to create app layouts.
4+
5+
Read the [docs](https://docs.slack.dev/block-kit/) to learn concepts behind these constructions, or explore [reference](https://docs.slack.dev/reference/block-kit) pages for attribute details.
6+
7+
## What's on display
8+
9+
### Blocks
10+
11+
- **[Actions](https://docs.slack.dev/reference/block-kit/blocks/actions-block)**: Holds multiple interactive elements. [Implementation](./src/blocks/actions.py).

block-kit/requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
mypy==1.18.2
2+
pytest==8.3.3
3+
ruff==0.14.3
4+
slack_sdk==3.37.0

block-kit/src/__init__.py

Whitespace-only changes.

block-kit/src/blocks/__init__.py

Whitespace-only changes.

block-kit/src/blocks/actions.py

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
from slack_sdk.models.blocks import ActionsBlock
2+
from slack_sdk.models.blocks.basic_components import Option, PlainTextObject
3+
from slack_sdk.models.blocks.block_elements import (
4+
ButtonElement,
5+
DatePickerElement,
6+
OverflowMenuElement,
7+
StaticSelectElement,
8+
)
9+
10+
11+
def example01() -> ActionsBlock:
12+
"""
13+
Holds multiple interactive elements.
14+
https://docs.slack.dev/reference/block-kit/blocks/actions-block/
15+
16+
An actions block with a select menu and a button.
17+
"""
18+
block = ActionsBlock(
19+
block_id="actions1",
20+
elements=[
21+
StaticSelectElement(
22+
action_id="select_2",
23+
placeholder=PlainTextObject(text="Which witch is the witchiest witch?"),
24+
options=[
25+
Option(text=PlainTextObject(text="Matilda"), value="matilda"),
26+
Option(text=PlainTextObject(text="Glinda"), value="glinda"),
27+
Option(
28+
text=PlainTextObject(text="Granny Weatherwax"),
29+
value="grannyWeatherwax",
30+
),
31+
Option(text=PlainTextObject(text="Hermione"), value="hermione"),
32+
],
33+
),
34+
ButtonElement(
35+
text=PlainTextObject(text="Cancel"),
36+
value="cancel",
37+
action_id="button_1",
38+
),
39+
],
40+
)
41+
return block
42+
43+
44+
def example02() -> ActionsBlock:
45+
"""
46+
An actions block with a datepicker, an overflow, and a button.
47+
"""
48+
block = ActionsBlock(
49+
block_id="actionblock789",
50+
elements=[
51+
DatePickerElement(
52+
action_id="datepicker123",
53+
initial_date="1990-04-28",
54+
placeholder=PlainTextObject(text="Select a date"),
55+
),
56+
OverflowMenuElement(
57+
action_id="overflow",
58+
options=[
59+
Option(
60+
text=PlainTextObject(text="*this is plain_text text*"),
61+
value="value-0",
62+
),
63+
Option(
64+
text=PlainTextObject(text="*this is plain_text text*"),
65+
value="value-1",
66+
),
67+
Option(
68+
text=PlainTextObject(text="*this is plain_text text*"),
69+
value="value-2",
70+
),
71+
Option(
72+
text=PlainTextObject(text="*this is plain_text text*"),
73+
value="value-3",
74+
),
75+
Option(
76+
text=PlainTextObject(text="*this is plain_text text*"),
77+
value="value-4",
78+
),
79+
],
80+
),
81+
ButtonElement(
82+
text=PlainTextObject(text="Click Me"),
83+
value="click_me_123",
84+
action_id="button",
85+
),
86+
],
87+
)
88+
return block

block-kit/tests/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)