Skip to content

Commit edda310

Browse files
committed
Add primary and non-primary fact block builders
- Introduced `PrimaryFactBlock()` and `NonPrimaryFactBlock()` functions to create fact blocks with configurable primary status - Simplified fact block creation by extracting common logic into a shared implementation - Supports creating fact blocks with flexible title and value configurations
1 parent 86f5b24 commit edda310

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

elementary/messages/block_builders.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,24 @@ def SummaryLineBlock(
8787
return LineBlock(inlines=text_blocks)
8888

8989

90+
def NonPrimaryFactBlock(fact: Tuple[SimpleLineBlock, SimpleLineBlock]) -> FactBlock:
91+
title, value = fact
92+
return FactBlock(
93+
title=LineBlock(inlines=_build_inlines(title)),
94+
value=LineBlock(inlines=_build_inlines(value)),
95+
primary=False,
96+
)
97+
98+
99+
def PrimaryFactBlock(fact: Tuple[SimpleLineBlock, SimpleLineBlock]) -> FactBlock:
100+
title, value = fact
101+
return FactBlock(
102+
title=LineBlock(inlines=_build_inlines(title)),
103+
value=LineBlock(inlines=_build_inlines(value)),
104+
primary=True,
105+
)
106+
107+
90108
def FactsBlock(
91109
*,
92110
facts: Sequence[

0 commit comments

Comments
 (0)