feat(types): add ContainerBlock for block kit - #2721
Conversation
🦋 Changeset detectedLatest commit: d61f4e9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2721 +/- ##
=======================================
Coverage 89.12% 89.12%
=======================================
Files 65 65
Lines 10441 10441
Branches 482 482
=======================================
Hits 9306 9306
Misses 1103 1103
Partials 32 32
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
…node-slack-sdk into ale-add-containerblock
zimeg
left a comment
There was a problem hiding this comment.
@srtaalej A few comments now but this is looking good 🌠
I'm curious about inlining possible options as an enum instead of exported type. Also updating reference documentation might nice if it's showing unexpected argument types. And I also think the @jsdoc should match reference as much as possible in hopes that we can keep this synced.
Will test against slack-samples/bolt-js-examples#218 before a final review! 🌚 ✨
| /** | ||
| * A helper union type of all Block types that can be used as child blocks in a {@link ContainerBlock}. | ||
| * @see {@link https://docs.slack.dev/reference/block-kit/blocks/container-block Container block reference}. | ||
| */ | ||
| export type ContainerBlockChildBlock = | ||
| | ActionsBlock | ||
| | ContextBlock | ||
| | DividerBlock | ||
| | FileBlock | ||
| | HeaderBlock | ||
| | ImageBlock | ||
| | InputBlock | ||
| | RichTextBlock | ||
| | SectionBlock | ||
| | TableBlock | ||
| | VideoBlock; |
There was a problem hiding this comment.
🪓 suggestion: Can we inline these options? Or perhaps avoid exporting it? I'm unsure it's used elsewhere and don't want to add additional exports without an immediate use.
| /** | ||
| * @description Plain text title for the container. Maximum length is 150 characters. | ||
| * One of `title` or `rich_text_title` is required. | ||
| */ | ||
| title?: PlainTextElement; | ||
| /** | ||
| * @description Rich text title for the container. Takes precedence over `title` if both are provided. | ||
| * One of `title` or `rich_text_title` is required. | ||
| */ | ||
| rich_text_title?: RichTextBlock; |
There was a problem hiding this comment.
🔭 suggestion: We should update reference pages to match these types if it's correct?
| /** | ||
| * @description Controls the width of the container. Defaults to `"standard"`. | ||
| */ | ||
| width?: 'narrow' | 'standard' | 'wide' | 'full'; |
There was a problem hiding this comment.
🌟 praise: I think we should embrace enum more in ongoing iteration and expand it as needed. IIRC this hasn't been our practice forever but it offers a better experience in current releases with fast fixes onward as needed. Changing a string to enum is more difficult I fear...
Summary
Adds
ContainerBlock(type: "container") to@slack/typesper https://docs.slack.dev/reference/block-kit/blocks/container-block/ContainerBlockinterface with all documented properties:title,rich_text_title,subtitle,child_blocks,width,icon,is_collapsible,default_collapsed,has_header_dividerContainerBlockChildBlockhelper union type for the 11 supported child block typesKnownBlockdiscriminated unionKnownBlockassignabilityhas_header_divider: truewhenis_collapsible: true— documented in JSDocExample Bolt test app (app.js)
Register a
/container-blockslash command in your test app and use the text argument to test different property combinations:/container-block— base (title + child_blocks)/container-block width— addswidth: "wide"/container-block mrkdwn-subtitle— subtitle withmrkdwntype/container-block has-header-divider— addshas_header_divider: true/container-block default-collapsed— addsis_collapsible+default_collapsed/container-block icon— addsiconimage element/container-block rich-text-title— usesrich_text_titleinstead oftitle/container-block all-collapsible— all props with collapsible/container-block all-divider— all props with header divider/container-block all— all compatible properties togetherRequirements