-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor TruncatedText & introduce TruncatedMultiLinesText components
- Loading branch information
1 parent
6611661
commit 2721b72
Showing
6 changed files
with
51 additions
and
18 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
packages/extension/src/components/atoms/TruncatedMultiLinesText/TruncatedMultiLinesText.tsx
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,32 @@ | ||
import { ComponentProps } from 'react'; | ||
|
||
import Typography from '@mui/material/Typography'; | ||
|
||
type TruncatedMultiLinesTextProps = ComponentProps<typeof Typography> & { | ||
text?: string; | ||
maxLines?: string; | ||
}; | ||
|
||
export const TruncatedMultiLinesText = ({ | ||
text = '', | ||
maxLines = '4', | ||
sx, | ||
variant = 'body1' | ||
}: TruncatedMultiLinesTextProps) => { | ||
return ( | ||
<Typography | ||
sx={{ | ||
overflow: 'hidden', | ||
display: '-webkit-box', | ||
width: '100%', | ||
'-webkit-box-orient': 'vertical', | ||
'-webkit-line-clamp': maxLines /* start showing ellipsis when X line is reached */, | ||
'white-space': 'pre-wrap' /* let the text wrap preserving spaces */, | ||
...sx | ||
}} | ||
variant={variant} | ||
> | ||
{text} | ||
</Typography> | ||
); | ||
}; |
1 change: 1 addition & 0 deletions
1
packages/extension/src/components/atoms/TruncatedMultiLinesText/index.ts
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 @@ | ||
export * from './TruncatedMultiLinesText'; |
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