-
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.
- Loading branch information
1 parent
3b0a950
commit 4f2f5f2
Showing
6 changed files
with
48 additions
and
70 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
packages/extension/src/components/atoms/TruncatedText/TruncatedText.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,31 @@ | ||
import { ComponentProps, FC } from 'react'; | ||
|
||
import { Typography } from '@mui/material'; | ||
|
||
type TruncatedTextProps = ComponentProps<typeof Typography> & { | ||
text?: string; | ||
maxLength?: number; | ||
}; | ||
|
||
export const TruncatedText: FC<TruncatedTextProps> = ({ text, maxLength, sx, ...rest }) => { | ||
if (!text) return null; | ||
|
||
const displayedText = | ||
maxLength && text.length > maxLength ? `${text.substring(0, maxLength - 3)}...` : text; | ||
|
||
return ( | ||
<Typography | ||
sx={{ | ||
display: 'block', | ||
overflow: 'hidden', | ||
textOverflow: 'ellipsis', | ||
width: '100%', | ||
...sx | ||
}} | ||
{...rest} | ||
variant="body1" | ||
> | ||
{displayedText} | ||
</Typography> | ||
); | ||
}; |
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 './TruncatedText'; |
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