@@ -6,8 +6,7 @@ import { Pie } from 'react-chartjs-2';
6
6
import { BoolTag } from "@/component-library/Tags/BoolTag" ;
7
7
import { Number } from "@/component-library/Text/Content/Number" ;
8
8
import { Contenttd , Generaltable , Titleth } from "@/component-library/Helpers/Metatable" ;
9
- import { useEffect , useState } from "react" ;
10
-
9
+ import tailwind from "@/tailwind"
11
10
ChartJS . register ( ArcElement , Tooltip , Legend ) ;
12
11
13
12
const RSEPie : React . FC < JSX . IntrinsicElements [ "div" ] & {
@@ -20,21 +19,28 @@ const RSEPie: React.FC<JSX.IntrinsicElements["div"] & {
20
19
labels : [ "Used" , "Free" ] ,
21
20
datasets : [ {
22
21
data : [ input . used , input . quota - input . used ] ,
23
- backgroundColor : [ "#f87171" , "#86efac" ]
22
+ backgroundColor : [ tailwind . theme . extend . colors . brand [ 400 ] , tailwind . theme . extend . colors . extra . emerald [ 400 ] ]
24
23
} ]
25
24
}
25
+
26
+ const isDarkMode = ( ) =>
27
+ window . matchMedia && window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches ;
28
+
26
29
const options = {
27
30
plugins : {
28
31
legend : {
29
- display : small
32
+ display : true ,
33
+ labels :{
34
+ color : isDarkMode ( ) ? tailwind . theme . extend . colors . text [ 200 ] : tailwind . theme . extend . colors . text [ 900 ] ,
35
+ }
30
36
} ,
31
37
}
32
38
}
33
39
const customid = input . rse + "-piediv"
34
40
return (
35
41
< div
36
42
className = { twMerge (
37
- "w-52 md:w-96 h-auto" ,
43
+ "h-auto" ,
38
44
"flex flex-col justify-start items-center" ,
39
45
hideWhenSmall ? "hidden md:flex" : "" ,
40
46
className ?? "" ,
@@ -44,13 +50,13 @@ const RSEPie: React.FC<JSX.IntrinsicElements["div"] & {
44
50
>
45
51
< label
46
52
className = { twMerge (
47
- "break-all " ,
53
+ "w-max " ,
48
54
) }
49
55
htmlFor = { customid }
50
56
>
51
57
{ input . rse }
52
58
</ label >
53
- < div className = "relative w-24 md:w-72 " >
59
+ < div className = "relative flex w-full " >
54
60
< Pie
55
61
data = { data }
56
62
options = { options }
@@ -87,25 +93,6 @@ export const WidgetUsedquota: React.FC<JSX.IntrinsicElements["div"] & {
87
93
}
88
94
) => {
89
95
const { className, ...otherprops } = props
90
- const [ windowSize , setWindowSize ] = useState ( [
91
- 1920 , 1080
92
- ] ) ;
93
-
94
- useEffect ( ( ) => {
95
- setWindowSize ( [ window . innerWidth , window . innerHeight ] )
96
-
97
- const handleWindowResize = ( ) => {
98
- setWindowSize ( [ window . innerWidth , window . innerHeight ] ) ;
99
- } ;
100
-
101
- window . addEventListener ( 'resize' , handleWindowResize ) ;
102
-
103
- return ( ) => {
104
- window . removeEventListener ( 'resize' , handleWindowResize ) ;
105
- } ;
106
- } , [ ] ) ;
107
-
108
- const isSm = ( ) => windowSize [ 0 ] > 640 // 640px is the breakpoint for sm => is minimum sm sized
109
96
110
97
return (
111
98
< div
@@ -116,20 +103,20 @@ export const WidgetUsedquota: React.FC<JSX.IntrinsicElements["div"] & {
116
103
{ ...otherprops }
117
104
>
118
105
< div >
119
- < H4 className = "font-bold" > Top Used RSEs</ H4 >
106
+ < H4 className = "font-bold dark:text-text-0 text-text-1000 " > Top Used RSEs</ H4 >
120
107
</ div >
121
108
< div
122
109
className = { twMerge (
123
110
"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4" ,
124
111
"dark:text-text-0 text-text-1000"
125
112
) }
126
113
>
127
- < RSEPie input = { input [ 0 ] } small = { isSm ( ) } />
128
- < RSEPie input = { input [ 1 ] } small = { isSm ( ) } />
129
- < RSEPie input = { input [ 2 ] } small = { isSm ( ) } />
130
- < RSEPie input = { input [ 3 ] } small = { isSm ( ) } hideWhenSmall />
131
- < RSEPie input = { input [ 4 ] } small = { isSm ( ) } hideWhenSmall />
132
- < RSEPie input = { input [ 5 ] } small = { isSm ( ) } hideWhenSmall />
114
+ < RSEPie input = { input [ 0 ] } />
115
+ < RSEPie input = { input [ 1 ] } />
116
+ < RSEPie input = { input [ 2 ] } />
117
+ < RSEPie input = { input [ 3 ] } hideWhenSmall />
118
+ < RSEPie input = { input [ 4 ] } hideWhenSmall />
119
+ < RSEPie input = { input [ 5 ] } hideWhenSmall />
133
120
</ div >
134
121
</ div >
135
122
) ;
0 commit comments