-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
53 lines (50 loc) · 1.16 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const plugin = require('tailwindcss/plugin');
const tooltip = plugin(
function({addUtilities, theme, e}) {
const values = theme('pos');
let utilities = {
'.tt': {
'position': 'relative',
'width': 'fit-content',
},
'.tt > .tt-text': {
'position': 'absolute',
'padding': '4px 8px',
'top': '-150%',
'left': '0%',
'z-index': '1000',
'width': '100%',
'text-align': 'center',
'display': 'none',
'justify-content': 'center',
},
'.tt-text > *': {
'border-radius': '5px',
'width': 'fit-content',
'padding': '4px 8px',
},
'.tt:hover .tt-text': {
'display': 'flex',
},
'.tt:hover': {
'cursor': 'pointer',
},
}
let position = Object.entries(values).map(([key, value]) => {
return {
[`.${e(`tt-pos-${key}`)}`]: { top: `${value} !important` },
}
});
utilities = {...utilities, ...position[0], ...position[1]};
addUtilities(utilities)
},
{
theme: {
pos: {
'top': '-150%',
'bottom': '100%',
}
}
}
);
module.exports = tooltip