|
| 1 | +from slack_sdk.models.blocks import Block, DividerBlock, SectionBlock |
| 2 | +from slack_sdk.models.blocks.basic_components import ( |
| 3 | + MarkdownTextObject, |
| 4 | + Option, |
| 5 | + PlainTextObject, |
| 6 | +) |
| 7 | +from slack_sdk.models.blocks.block_elements import StaticSelectElement |
| 8 | + |
| 9 | + |
| 10 | +def example01() -> Option: |
| 11 | + """ |
| 12 | + Defines a single item in a number of item selection elements. |
| 13 | + https://docs.slack.dev/reference/block-kit/composition-objects/option-object/ |
| 14 | +
|
| 15 | + A single option object. |
| 16 | + """ |
| 17 | + option = Option( |
| 18 | + text=PlainTextObject(text="Save it", emoji=True), |
| 19 | + value="value-2", |
| 20 | + ) |
| 21 | + return option |
| 22 | + |
| 23 | + |
| 24 | +def example02() -> list[Block]: |
| 25 | + """ |
| 26 | + A static select menu element with several option objects. |
| 27 | + """ |
| 28 | + blocks: list[Block] = [ |
| 29 | + SectionBlock( |
| 30 | + text=MarkdownTextObject(text=":mag: Search results for *Cata*"), |
| 31 | + ), |
| 32 | + DividerBlock(), |
| 33 | + SectionBlock( |
| 34 | + text=MarkdownTextObject( |
| 35 | + text="*<fakeLink.toYourApp.com|Use Case Catalogue>*\nUse Case Catalogue for the following departments/roles..." |
| 36 | + ), |
| 37 | + accessory=StaticSelectElement( |
| 38 | + placeholder=PlainTextObject(text="Manage", emoji=True), |
| 39 | + options=[ |
| 40 | + Option( |
| 41 | + text=PlainTextObject(text="Edit it", emoji=True), |
| 42 | + value="value-0", |
| 43 | + ), |
| 44 | + Option( |
| 45 | + text=PlainTextObject(text="Read it", emoji=True), |
| 46 | + value="value-1", |
| 47 | + ), |
| 48 | + Option( |
| 49 | + text=PlainTextObject(text="Save it", emoji=True), |
| 50 | + value="value-2", |
| 51 | + ), |
| 52 | + ], |
| 53 | + ), |
| 54 | + ), |
| 55 | + ] |
| 56 | + return blocks |
0 commit comments