11const plugin = require ( 'tailwindcss/plugin' )
22
33module . exports = plugin . withOptions ( function ( options ) {
4- return function ( { addBase } ) {
5- // const size = options?.size ?? '5px'
6- // const { track, thumb, thumbHover } = options?.colors ?? {}
4+ return function ( { addBase, theme } ) {
5+ const size = options && options . size ? options . size : theme ( 'scrollbar.DEFAULT.size' , '5px' )
76
8- const size = options && options . size ? options . size : '5px'
9- const { track, thumb, thumbHover } = options && options . colors ? options . colors : { }
7+ const optionColors = options && options . colors ? options . colors : { }
8+ const defaultColors = theme ( 'scrollbar.DEFAULT.colors' , {
9+ track : '#f1f1f1' ,
10+ thumb : '#c1c1c1' ,
11+ hover : '#a8a8a8' ,
12+ } )
13+ const { track, thumb, thumbHover } = { ...defaultColors , ...optionColors }
1014
1115 addBase ( [
1216 {
@@ -15,13 +19,13 @@ module.exports = plugin.withOptions(function (options) {
1519 height : size ,
1620 } ,
1721 '::-webkit-scrollbar-track' : {
18- background : track ? track : '#f1f1f1' ,
22+ background : track ,
1923 } ,
2024 '::-webkit-scrollbar-thumb' : {
21- background : thumb ? thumb : '#c1c1c1' ,
25+ background : thumb ,
2226 } ,
2327 '::-webkit-scrollbar-thumb:hover' : {
24- background : thumbHover ? thumbHover : '#a8a8a8' ,
28+ background : thumbHover ,
2529 } ,
2630 } ,
2731 ] )
0 commit comments