-
Notifications
You must be signed in to change notification settings - Fork 317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add FormattedText component #72
base: main
Are you sure you want to change the base?
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #72 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 2 2
Lines 120 118 -2
=========================================
- Hits 120 118 -2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we also need to change types types for Button
and Paragraph
to take list[FormattedText | str | Link]
instead of just str
.
None, serialization_alias='textFormat' | ||
) | ||
# TODO, use pydantic-extra-types Color? | ||
text_color: str | None = pydantic.Field(None, serialization_alias='color') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to use Union
, not |
to support older python.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking good, thanks.
You'll need to rebase to main and fix JSON Schema equivalence tests which might be tricky, let me know if you need help.
demo/components_list.py
Outdated
c.Div( | ||
components=[ | ||
c.Heading(text='FormattedText', level=2), | ||
c.Markdown(text='`FormattedText` can be used to change the style of the text.'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add something like
this is particularly useful to avoid the overhead of loading the markdown renderer, or when you're including user generated content that you don't want to escape styling.
@@ -56,7 +56,7 @@ class Text(pydantic.BaseModel, extra='forbid'): | |||
|
|||
|
|||
class Paragraph(pydantic.BaseModel, extra='forbid'): | |||
text: str | |||
text: '_t.List[_t.Union[str, FormattedText, Link]]' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
text: '_t.List[_t.Union[str, FormattedText, Link]]' | |
text: '_t.Union[str, _t.List[_t.Union[str, FormattedText, Link]]]' |
you need to support just str
as well.
Then you need to update Paragraph
and Button
to render this.
I guess Text
should also be changed.
const style = { | ||
backgroundColor, | ||
color, | ||
fontWeight: textFormat === 'bold' ? 'bold' : 'normal', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should probably be omitted, not normal
if bold is not set.
backgroundColor, | ||
color, | ||
fontWeight: textFormat === 'bold' ? 'bold' : 'normal', | ||
fontStyle: textFormat === 'italic' ? 'italic' : 'normal', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same.
Yes please, can you help me with that? |
This is my PR proposal for #29