|
| 1 | +from slack_sdk.models.blocks import CardBlock, CarouselBlock |
| 2 | +from slack_sdk.models.blocks.basic_components import MarkdownTextObject, PlainTextObject |
| 3 | +from slack_sdk.models.blocks.block_elements import ButtonElement, ImageElement |
| 4 | + |
| 5 | + |
| 6 | +def example01() -> CarouselBlock: |
| 7 | + """ |
| 8 | + Displays related card blocks in a horizontally-scrolling container. |
| 9 | + https://docs.slack.dev/reference/block-kit/blocks/carousel-block/ |
| 10 | +
|
| 11 | + A sample carousel block. |
| 12 | + """ |
| 13 | + block = CarouselBlock( |
| 14 | + elements=[ |
| 15 | + CardBlock( |
| 16 | + block_id="carousel-card-1", |
| 17 | + icon=ImageElement( |
| 18 | + image_url="https://picsum.photos/36/36", |
| 19 | + alt_text="Icon", |
| 20 | + ), |
| 21 | + title=MarkdownTextObject( |
| 22 | + text="MDR", |
| 23 | + verbatim=False, |
| 24 | + ), |
| 25 | + subtitle=MarkdownTextObject( |
| 26 | + text="Refining data files", |
| 27 | + verbatim=False, |
| 28 | + ), |
| 29 | + hero_image=ImageElement( |
| 30 | + image_url="https://picsum.photos/400/300", |
| 31 | + alt_text="Sample hero image", |
| 32 | + ), |
| 33 | + body=MarkdownTextObject( |
| 34 | + text="Blue badge required to gain access.", |
| 35 | + verbatim=False, |
| 36 | + ), |
| 37 | + actions=[ |
| 38 | + ButtonElement( |
| 39 | + text=PlainTextObject(text="Action Button", emoji=False), |
| 40 | + action_id="button_action_1", |
| 41 | + ) |
| 42 | + ], |
| 43 | + ), |
| 44 | + CardBlock( |
| 45 | + block_id="carousel-card-2", |
| 46 | + icon=ImageElement( |
| 47 | + image_url="https://picsum.photos/36/36", |
| 48 | + alt_text="Icon", |
| 49 | + ), |
| 50 | + title=MarkdownTextObject( |
| 51 | + text="O&D", |
| 52 | + verbatim=False, |
| 53 | + ), |
| 54 | + subtitle=MarkdownTextObject( |
| 55 | + text="Storage, maintenance, and rotation of art pieces", |
| 56 | + verbatim=False, |
| 57 | + ), |
| 58 | + hero_image=ImageElement( |
| 59 | + image_url="https://picsum.photos/400/300", |
| 60 | + alt_text="Sample hero image", |
| 61 | + ), |
| 62 | + body=MarkdownTextObject( |
| 63 | + text="Green badge required to gain access.", |
| 64 | + verbatim=False, |
| 65 | + ), |
| 66 | + actions=[ |
| 67 | + ButtonElement( |
| 68 | + text=PlainTextObject(text="Action Button", emoji=False), |
| 69 | + action_id="button_action_2", |
| 70 | + ) |
| 71 | + ], |
| 72 | + ), |
| 73 | + CardBlock( |
| 74 | + block_id="carousel-card-3", |
| 75 | + icon=ImageElement( |
| 76 | + image_url="https://picsum.photos/36/36", |
| 77 | + alt_text="Icon", |
| 78 | + ), |
| 79 | + title=MarkdownTextObject( |
| 80 | + text="Wellness Center", |
| 81 | + verbatim=False, |
| 82 | + ), |
| 83 | + subtitle=MarkdownTextObject( |
| 84 | + text="Wellness sessions", |
| 85 | + verbatim=False, |
| 86 | + ), |
| 87 | + hero_image=ImageElement( |
| 88 | + image_url="https://picsum.photos/400/300", |
| 89 | + alt_text="Sample hero image", |
| 90 | + ), |
| 91 | + body=MarkdownTextObject( |
| 92 | + text="Please take a seat in the waiting room until called.", |
| 93 | + verbatim=False, |
| 94 | + ), |
| 95 | + actions=[ |
| 96 | + ButtonElement( |
| 97 | + text=PlainTextObject(text="Action Button", emoji=False), |
| 98 | + action_id="button_action_3", |
| 99 | + ) |
| 100 | + ], |
| 101 | + ), |
| 102 | + ], |
| 103 | + ) |
| 104 | + return block |
0 commit comments