Skip to content

Commit 03f4e64

Browse files
committed
fixed bug darkBackground default config
1 parent 25da720 commit 03f4e64

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gradin/tailwindcss-scrollbar",
3-
"version": "2.0.3",
3+
"version": "2.0.4",
44
"description": "Tailwindcss plugin to customize scrollbar.",
55
"main": "src/index.js",
66
"scripts": {},

src/index.js

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,46 @@ const getSize = (options, theme) => {
44
if (options && options.size) { // with plugin options
55
return options.size
66
}
7-
return theme('scrollbar.DEFAULT.size', '5px') // with config
7+
return theme('scrollbar.DEFAULT.size', '5px') // with tailwind.config.js
88
}
99
const getStyleTrack = (options, theme) => {
10-
const defaultBackground = '#f1f1f1'
11-
const defaultConfig = {
12-
background: defaultBackground,
13-
darkBackground: defaultBackground,
14-
}
10+
const background = '#f1f1f1' // default
1511
const fromConfig = theme('scrollbar.DEFAULT.track', {}) // with tailwind.config.js
1612
const fromOptions = (options && options.track) ? options.track : {} // with plugin options
1713

18-
return { ...defaultConfig, ...fromConfig, ...fromOptions }
14+
const finalConfig = { background, ...fromConfig, ...fromOptions }
15+
16+
if (! finalConfig.darkBackground) {
17+
finalConfig.darkBackground = finalConfig.background
18+
}
19+
20+
return finalConfig
1921
}
2022
const getStyleThumb = (options, theme) => {
21-
const defaultBackground = '#c1c1c1'
22-
const defaultConfig = {
23-
background: defaultBackground,
24-
darkBackground: defaultBackground,
25-
}
23+
const background = '#c1c1c1'
2624
const fromConfig = theme('scrollbar.DEFAULT.thumb', {}) // with tailwind.config.js
2725
const fromOptions = (options && options.thumb) ? options.thumb : {} // with plugin options
2826

29-
return { ...defaultConfig, ...fromConfig, ...fromOptions }
27+
const finalConfig = { background, ...fromConfig, ...fromOptions }
28+
29+
if (! finalConfig.darkBackground) {
30+
finalConfig.darkBackground = finalConfig.background
31+
}
32+
33+
return finalConfig
3034
}
3135
const getStyleThumbHover = (options, theme) => {
32-
const defaultBackground = '#a8a8a8'
33-
const defaultConfig = {
34-
background: defaultBackground,
35-
darkBackground: defaultBackground,
36-
}
36+
const background = '#a8a8a8'
3737
const fromConfig = theme('scrollbar.DEFAULT.hover', {}) // with tailwind.config.js
3838
const fromOptions = (options && options.hover) ? options.hover : {} // with plugin options
3939

40-
return { ...defaultConfig, ...fromConfig, ...fromOptions }
40+
const finalConfig = { background, ...fromConfig, ...fromOptions }
41+
42+
if (! finalConfig.darkBackground) {
43+
finalConfig.darkBackground = finalConfig.background
44+
}
45+
46+
return finalConfig
4147
}
4248

4349
module.exports = plugin.withOptions(function (options) {

0 commit comments

Comments
 (0)