Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions block-kit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ Read the [docs](https://docs.slack.dev/block-kit/) to learn concepts behind thes
- **[Markdown](https://docs.slack.dev/reference/block-kit/blocks/markdown-block)**: Displays formatted markdown. [Implementation](./src/blocks/markdown.js).
- **[Rich text](https://docs.slack.dev/reference/block-kit/blocks/rich-text-block)**: Displays formatted, structured representation of text. [Implementation](./src/blocks/rich_text.js).
- **[Section](https://docs.slack.dev/reference/block-kit/blocks/section-block)**: Displays text, possibly alongside elements. [Implementation](./src/blocks/section.js).
- **[Table](https://docs.slack.dev/reference/block-kit/blocks/table-block)**: Displays structured information in a table. [Implementation](./src/blocks/table.js).
- **[Video](https://docs.slack.dev/reference/block-kit/blocks/video-block)**: Displays an embedded video player. [Implementation](./src/blocks/video.js).
82 changes: 82 additions & 0 deletions block-kit/src/blocks/table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/**
* Displays structured information in a table.
*
* @see {@link https://docs.slack.dev/reference/block-kit/blocks/table-block/}
*/

/**
* A table block.
*
* @returns {import('@slack/types').TableBlock}
*/
export function example01() {
/**
* @type {import('@slack/types').TableBlock}
*/
const block = {
type: "table",
column_settings: [
{
is_wrapped: true,
},
{
align: "right",
},
],
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: [
{
text: "Data 1B",
type: "link",
url: "https://slack.com",
},
],
},
],
},
],
[
{
type: "raw_text",
text: "Data 2A",
},
{
type: "rich_text",
elements: [
{
type: "rich_text_section",
elements: [
{
text: "Data 2B",
type: "link",
url: "https://slack.com",
},
],
},
],
},
],
],
};
return block;
}
75 changes: 75 additions & 0 deletions block-kit/tests/blocks/table.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import * as assert from "node:assert";
import { describe, it } from "node:test";
import { example01 } from "../../src/blocks/table.js";

describe("table", () => {
it("example01", () => {
const block = example01();
const expected = {
type: "table",
column_settings: [
{
is_wrapped: true,
},
{
align: "right",
},
],
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: [
{
text: "Data 1B",
type: "link",
url: "https://slack.com",
},
],
},
],
},
],
[
{
type: "raw_text",
text: "Data 2A",
},
{
type: "rich_text",
elements: [
{
type: "rich_text_section",
elements: [
{
text: "Data 2B",
type: "link",
url: "https://slack.com",
},
],
},
],
},
],
],
};
assert.deepStrictEqual(block, expected);
});
});