-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
file name formating before render, tooltip added for full file name v…
…iew on hover
- Loading branch information
1 parent
3f5a84b
commit 5daed6b
Showing
3 changed files
with
44 additions
and
12 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
12 changes: 12 additions & 0 deletions
12
src/components/client/irregularity/helpers/formatFileName.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,12 @@ | ||
export const formatFileName = (fileName: string) => { | ||
const maxLength = 15 | ||
if (fileName.length <= maxLength) return fileName | ||
|
||
const fileExtension = fileName.split('.').pop() | ||
if (fileExtension) { | ||
const nameWithoutExtension = fileName.slice(0, -(fileExtension.length + 1)) | ||
return `${nameWithoutExtension.slice(0, 6)}...${nameWithoutExtension.slice( | ||
-6, | ||
)}.${fileExtension}` | ||
} | ||
} |
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