-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Typography): add Typography components (#2821)
* feat(typography): typography finished * feat(typography): lint change * feat(typography): lint change * feat(typography lint ignore): typography * chore: update snapshot * chore: fix build site * chore: adjust router list * chore: update snapshot * chore: update snapshot * feat(typography): new component * feat(typography): realize typography * chore: update snapshot * chore: update demo * chore: update demo * fix: fix type * fix: fix type * chore: fix build * chore: optimize dir * chore: update coverage * chore: fix test --------- Co-authored-by: Uyarn <[email protected]>
- Loading branch information
Showing
33 changed files
with
3,068 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule _common
updated
45 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React, { forwardRef } from 'react'; | ||
import classNames from 'classnames'; | ||
import Ellipsis from './ellipsis/Ellipsis'; | ||
import { paragraphDefaultProps } from './defaultProps'; | ||
|
||
import useConfig from '../hooks/useConfig'; | ||
import useEllipsis from './ellipsis/useEllipsis'; | ||
import useDefaultProps from '../hooks/useDefaultProps'; | ||
|
||
import type { StyledProps } from '../common'; | ||
import type { TdParagraphProps } from './type'; | ||
|
||
export type TypographyParagraphProps = TdParagraphProps & | ||
StyledProps & { | ||
children: React.ReactNode; | ||
}; | ||
|
||
const Paragraph = forwardRef<HTMLDivElement, TypographyParagraphProps>((originalProps, ref) => { | ||
const { classPrefix } = useConfig(); | ||
const props = useDefaultProps<TypographyParagraphProps>(originalProps, paragraphDefaultProps); | ||
|
||
const { ellipsis, children, className, content, ...rest } = props; | ||
const prefixCls = `${classPrefix}-typography`; | ||
|
||
const { ellipsisProps } = useEllipsis(ellipsis); | ||
|
||
if (!ellipsis) { | ||
return ( | ||
<div className={classNames(className, prefixCls)} ref={ref} {...rest}> | ||
{children || content} | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<Ellipsis {...ellipsisProps} className={classNames(className, prefixCls)} {...rest}> | ||
{children || content} | ||
</Ellipsis> | ||
); | ||
}); | ||
|
||
Paragraph.displayName = 'Paragraph'; | ||
Paragraph.defaultProps = paragraphDefaultProps; | ||
|
||
export default Paragraph; |
Oops, something went wrong.