-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
35 lines (31 loc) · 703 Bytes
/
Copy pathindex.js
File metadata and controls
35 lines (31 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* Simple CSS multiline truncation
*
* Example:
*
* import linesTruncate from 'react-css-truncate';
*
* <div style={linesTruncate(2)}>
* <div style={{ ...linesTruncate(1), width: '50px' }}>
*
*/
const linesTruncate = linesCount => {
const lines = parseInt(linesCount);
if (isNaN(lines) || lines < 1) {
return {};
}
return lines === 1
? {
whiteSpace: "nowrap",
textOverflow: "ellipsis",
overflow: "hidden"
}
: {
"-webkit-line-clamp": `${lines} !important`,
"-webkit-box-orient": "vertical",
display: "-webkit-box",
maxHeight: "100%",
overflow: "hidden"
};
};
module.exports = linesTruncate;