Skip to content

Commit a45cbe4

Browse files
committed
Add plugins to tailwind theme in core, move scrollbar styles to new utility classes
1 parent 2a8798b commit a45cbe4

File tree

5 files changed

+94
-24
lines changed

5 files changed

+94
-24
lines changed

packages/core/plugins.ts

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import plugin from 'tailwindcss/plugin';
2+
import type { OptionalConfig } from 'tailwindcss/types/config';
3+
4+
export const plugins = [
5+
plugin(({ addUtilities, matchUtilities, theme }) => {
6+
addUtilities({
7+
'.scrollbar-thin': {
8+
'scrollbar-width': 'thin',
9+
},
10+
});
11+
12+
matchUtilities(
13+
{
14+
scrollbar: (value: string) => ({
15+
scrollbarColor: value,
16+
}),
17+
},
18+
{ values: theme('colors') ?? {} }
19+
);
20+
21+
matchUtilities(
22+
{
23+
'scrollbar-w': (value: string) => ({
24+
'&::-webkit-scrollbar': {
25+
width: value,
26+
},
27+
}),
28+
},
29+
{ values: theme('spacing') ?? {} }
30+
);
31+
32+
matchUtilities(
33+
{
34+
'scrollbar-track': (value: string) => ({
35+
'&::-webkit-scrollbar-track': {
36+
background: value,
37+
},
38+
}),
39+
},
40+
{ values: theme('colors') ?? {} }
41+
);
42+
43+
matchUtilities(
44+
{
45+
'scrollbar-thumb': (value: string) => ({
46+
'&::-webkit-scrollbar-thumb': {
47+
backgroundColor: value,
48+
},
49+
}),
50+
},
51+
{ values: theme('colors') ?? {} }
52+
);
53+
54+
matchUtilities(
55+
{
56+
'scrollbar-thumb-border': (value: string) => ({
57+
'&::-webkit-scrollbar-thumb': {
58+
borderRadius: value,
59+
},
60+
}),
61+
},
62+
{ values: theme('borderRadius') ?? {} }
63+
);
64+
65+
matchUtilities(
66+
{
67+
'scrollbar-thumb-border': (value: string) => ({
68+
'&::-webkit-scrollbar-thumb': {
69+
borderWidth: value,
70+
},
71+
}),
72+
},
73+
{ values: theme('borderWidth') ?? {} }
74+
);
75+
76+
matchUtilities(
77+
{
78+
'scrollbar-thumb-border': (value: string) => ({
79+
'&::-webkit-scrollbar-thumb': {
80+
borderColor: value,
81+
},
82+
}),
83+
},
84+
{ values: theme('borderColor') ?? {} }
85+
);
86+
}),
87+
] satisfies OptionalConfig['plugins'];

packages/core/src/lib/select/select-menu.svelte

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export let heading = '';
2828
{/if}
2929
<ul
3030
role="menu"
31-
class="select-menu flex max-h-36 flex-col overflow-y-auto"
31+
class="scrollbar-thin scrollbar-black scrollbar-w-1.5 scrollbar-track-transparent scrollbar-thumb-black scrollbar-thumb-border-0 scrollbar-thumb-border-transparent flex max-h-36 flex-col overflow-y-auto"
3232
tabindex="-1"
3333
bind:this={element}
3434
on:mouseleave
@@ -50,25 +50,3 @@ export let heading = '';
5050
</button>
5151
{/if}
5252
</div>
53-
54-
<style>
55-
/* TODO: Move these do tailwind classes */
56-
.select-menu::-webkit-scrollbar {
57-
width: 6px;
58-
}
59-
60-
.select-menu::-webkit-scrollbar-track {
61-
background: transparent;
62-
}
63-
64-
.select-menu::-webkit-scrollbar-thumb {
65-
background-color: black;
66-
border-radius: 0;
67-
border: 0 solid transparent;
68-
}
69-
70-
.select-menu {
71-
scrollbar-width: thin;
72-
scrollbar-color: black transparent;
73-
}
74-
</style>

packages/core/svelte.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const config = {
2323
'../postcss.config.js',
2424
'../svelte.config.js',
2525
'../tailwind.config.ts',
26+
'../plugins.ts',
2627
'../theme.ts',
2728
],
2829
}),

packages/core/tailwind.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import type { Config } from 'tailwindcss';
22
import { theme } from './theme';
3+
import { plugins } from './plugins';
34

45
export default {
56
content: ['./src/**/*.{ts,svelte}'],
7+
plugins,
68
theme,
79
variants: {
810
extend: {},

packages/core/theme.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { OptionalConfig } from 'tailwindcss/types/config';
2+
13
export const theme = {
24
extend: {
35
fontFamily: {
@@ -59,4 +61,4 @@ export const theme = {
5961
'expand-vertical': 'max-height,visibility',
6062
},
6163
},
62-
};
64+
} satisfies OptionalConfig['theme'];

0 commit comments

Comments
 (0)