-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.js
33 lines (27 loc) · 803 Bytes
/
index.js
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
/**
* plugin uses to build `truncate-key-lines` classes based on `ellipsis`
* example:
* theme.ellipsis.lines = { 3: '3' }
* result:
* .truncate-3-lines {
* 'overflow': 'hidden',
* 'display': '-webkit-box',
* '-webkit-line-clamp': 3,
* '-webkit-box-orient': 'vertical',
* }
*/
const ellipsisPlugin = (variants = []) => ({ addUtilities, config, e }) => {
const lines = config('theme.truncate.lines')
const keys = Object.keys(lines)
if (!keys.length) return;
const utilities = keys.map(key => ({
[`.${e(`truncate-${key}-lines`)}`]: {
'overflow': 'hidden',
'display': '-webkit-box',
'-webkit-line-clamp': lines[key],
'-webkit-box-orient': 'vertical',
},
}))
addUtilities(utilities, variants);
};
module.exports = ellipsisPlugin