File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import {
12
12
configureErrors ,
13
13
configureServices ,
14
14
useFilteredWares ,
15
+ truncateDescription ,
15
16
} from '../../utils'
16
17
17
18
const Browse = ( { session } ) => {
@@ -48,12 +49,12 @@ const Browse = ({ session }) => {
48
49
)
49
50
}
50
51
51
- const truncateDescription = ( desc = '' , maxLength , isOpen ) => {
52
- if ( desc . length <= maxLength || isOpen ) return { truncated : desc , cutOffIndex : desc . length }
53
- const lastSpaceIndex = desc . substring ( 0 , maxLength ) . lastIndexOf ( ' ' )
54
- const ellipsis = isOpen ? '' : '...'
55
- return { truncated : desc . slice ( 0 , lastSpaceIndex ) + ellipsis , cutOffIndex : lastSpaceIndex }
56
- }
52
+ // const truncateDescription = (desc = '', maxLength, isOpen) => {
53
+ // if (desc.length <= maxLength || isOpen) return { truncated: desc, cutOffIndex: desc.length }
54
+ // const lastSpaceIndex = desc.substring(0, maxLength).lastIndexOf(' ')
55
+ // const ellipsis = isOpen ? '' : '...'
56
+ // return { truncated: desc.slice(0, lastSpaceIndex) + ellipsis, cutOffIndex: lastSpaceIndex }
57
+ // }
57
58
58
59
return (
59
60
< div className = 'container' >
Original file line number Diff line number Diff line change @@ -82,3 +82,10 @@ export const formatBytes = (bytes, decimals = 2) => {
82
82
83
83
return `${ parseFloat ( ( bytes / Math . pow ( k , i ) ) . toFixed ( dm ) ) } ${ sizes [ i ] } `
84
84
}
85
+
86
+ export const truncateDescription = ( desc = '' , maxLength , isOpen ) => {
87
+ if ( desc . length <= maxLength || isOpen ) return { truncated : desc , cutOffIndex : desc . length }
88
+ const lastSpaceIndex = desc . substring ( 0 , maxLength ) . lastIndexOf ( ' ' )
89
+ const ellipsis = isOpen ? '' : '...'
90
+ return { truncated : desc . slice ( 0 , lastSpaceIndex ) + ellipsis , cutOffIndex : lastSpaceIndex }
91
+ }
You can’t perform that action at this time.
0 commit comments