Skip to content
Merged
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
3 changes: 2 additions & 1 deletion blockkit/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from blockkit.enums import ListStyle, Style
from blockkit.objects import (
Confirm,
Date,
DispatchActionConfig,
Emoji,
Filter,
Expand Down Expand Up @@ -679,7 +680,7 @@ def __init__(
)


RichTextObject = Union[Text, Emoji]
RichTextObject = Union[Text, Date, Emoji]


class RichTextPreformatted(Component):
Expand Down
12 changes: 12 additions & 0 deletions blockkit/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"Text",
"Style",
"Emoji",
"Date",
]


Expand Down Expand Up @@ -83,6 +84,17 @@ def __init__(self, *, name: str):
super().__init__(name=name)


class Date(Component):
type: str = "date"
timestamp: int = Field(...)
format: str = Field(..., min_length=1)
url: Optional[str] = None
fallback: Optional[str] = None

def __init__(self, *, timestamp: int, format: str, url: Optional[str] = None, fallback: Optional[str] = None):
super().__init__(timestamp=timestamp, format=format, url=url, fallback=fallback)


class Confirm(Component):
title: Union[PlainText, str]
text: Union[PlainText, MarkdownText, str]
Expand Down
3 changes: 3 additions & 0 deletions tests/test_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
)
from blockkit.objects import (
Confirm,
Date,
DispatchActionConfig,
Emoji,
Filter,
Expand Down Expand Up @@ -1430,6 +1431,7 @@ def test_builds_rich_text_quote():
Text(text="is better than well "),
Text(text="said.", style=Style(bold=True, strike=True)),
Emoji(name="wink"),
Date(timestamp=123456789, format="{ago}", url="https://example.com", fallback="Yep"),
]
).build() == {
"type": "rich_text_quote",
Expand All @@ -1439,6 +1441,7 @@ def test_builds_rich_text_quote():
{"type": "text", "text": "is better than well "},
{"type": "text", "text": "said.", "style": {"bold": True, "strike": True}},
{"type": "emoji", "name": "wink"},
{"type": "date", "timestamp": 123456789, "format": "{ago}", "url": "https://example.com", "fallback": "Yep"},
],
}

Expand Down