-
Notifications
You must be signed in to change notification settings - Fork 298
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?
Changes from 1 commit
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', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should probably be omitted, not |
||
fontStyle: textFormat === 'italic' ? 'italic' : 'normal', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same. |
||
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 |
---|---|---|
|
@@ -202,6 +202,17 @@ class Iframe(pydantic.BaseModel, extra='forbid'): | |
type: _t.Literal['Iframe'] = 'Iframe' | ||
|
||
|
||
class FormattedText(pydantic.BaseModel, extra='forbid'): | ||
text: str | ||
text_format: _t.Literal['bold', 'italic', 'underline', 'strikethrough'] | None = pydantic.Field( | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. you need to use |
||
background_color: str | None = pydantic.Field(None, serialization_alias='backgroundColor') | ||
type: _t.Literal['FormattedText'] = 'FormattedText' | ||
|
||
|
||
AnyComponent = _te.Annotated[ | ||
_t.Union[ | ||
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