-
Notifications
You must be signed in to change notification settings - Fork 0
/
scrollbars.js
53 lines (44 loc) · 1.17 KB
/
scrollbars.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
// ####################################
// ##### SCROLLBARS (TAILWIND PLUGIN)
// ####################################
module.exports = function({ addUtilities }) {
const utilities = {}
const directions = [ 'x', 'y' ]
const sizes = [ null, 'sm', 'lg' ]
const dirProps = {
x: 'height',
y: 'width'
}
directions.forEach(dir => {
sizes.forEach(sz => {
const tail = sz == null ? dir : `${dir}-${sz}`
const klass = `.scrollbar-${tail}`
Object.assign(utilities, {
[klass]: {
[`overflow-${dir}`]: 'auto',
},
[`${klass}::-webkit-scrollbar`]: {
'background-color': 'inherit'
},
[`${klass}::-webkit-scrollbar-thumb`]: {
'border-radius': '8px',
'background-color': '#b1b1b1'
}
})
if (sz == 'sm') {
Object.assign(utilities, {
[`${klass}::-webkit-scrollbar`]: {
[dirProps[dir]]: '4px'
},
})
} else if (sz == 'lg') {
Object.assign(utilities, {
[`${klass}::-webkit-scrollbar`]: {
[dirProps[dir]]: '16px'
},
})
}
})
})
addUtilities(utilities)
}