-
Notifications
You must be signed in to change notification settings - Fork 336
add FormattedText component #72
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
bef4392
5f76caa
6c6e9a5
bc87be2
975d48e
c96b1d6
6d1c386
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { FC } from 'react' | ||
|
|
||
| import { ClassName } from '../hooks/className' | ||
|
|
||
| export interface FormattedTextProps { | ||
| type: 'FormattedText' | ||
| text: string | ||
| textFormat?: 'bold' | 'italic' | 'underline' | 'strikethrough' | ||
| color?: string | ||
| backgroundColor?: string | ||
| className?: ClassName | ||
| } | ||
|
|
||
| export const FormattedTextComp: FC<FormattedTextProps> = (props) => { | ||
| const { text, textFormat, color, backgroundColor } = props | ||
|
|
||
| const style = { | ||
| backgroundColor, | ||
| color, | ||
| fontWeight: textFormat === 'bold' ? 'bold' : 'normal', | ||
|
||
| fontStyle: textFormat === 'italic' ? 'italic' : 'normal', | ||
|
||
| textDecoration: | ||
| textFormat === 'underline' ? 'underline' : textFormat === 'strikethrough' ? 'line-through' : 'none', | ||
| } | ||
|
|
||
| return <span style={style}>{text}</span> | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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]]' | ||||||
|
||||||
| 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.
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