Skip to content

Commit c5e361c

Browse files
GooseNightmaany
authored andcommitted
Enhancement: Fix diplay issues for tables #414
1 parent ceb1c05 commit c5e361c

File tree

6 files changed

+57
-60
lines changed

6 files changed

+57
-60
lines changed

src/component-library/Pages/Dashboard/Widgets/WidgetOngoingrules.tsx

+20-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
} from "@tanstack/react-table";
2020
import { useEffect, useState } from "react";
2121
import { TableSortUpDown } from "@/component-library/StreamedTables/TableSortUpDown.stories";
22+
import tailwind from "@/tailwind"
2223

2324
ChartJS.register(
2425
CategoryScale,
@@ -83,6 +84,14 @@ export const WidgetOngoingrules: React.FC<JSX.IntrinsicElements["div"] & {
8384
labels: [],
8485
datasets: []
8586
})
87+
const isDarkMode = () =>
88+
window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
89+
90+
window.matchMedia('(prefers-color-scheme: dark)')
91+
.addEventListener('change',() => {
92+
location.reload();
93+
})
94+
8695
const options = {
8796
indexAxis: "y" as const,
8897
responsive: true,
@@ -92,13 +101,21 @@ export const WidgetOngoingrules: React.FC<JSX.IntrinsicElements["div"] & {
92101
title: {
93102
display: true,
94103
text: "Percentage [%]",
104+
color: isDarkMode() ? tailwind.theme.extend.colors.text[200] : tailwind.theme.extend.colors.text[900],
95105
},
96106
stacked: true,
97107
min: 0,
98108
max: 100,
109+
ticks: {
110+
color: isDarkMode() ? tailwind.theme.extend.colors.text[200] : tailwind.theme.extend.colors.text[900],
111+
}
99112
},
100113
y: {
101114
stacked: true,
115+
ticks: {
116+
autoSkip: false,
117+
color: isDarkMode() ? tailwind.theme.extend.colors.text[200] : tailwind.theme.extend.colors.text[900],
118+
}
102119
}
103120
},
104121
plugins: {
@@ -156,17 +173,17 @@ export const WidgetOngoingrules: React.FC<JSX.IntrinsicElements["div"] & {
156173
{
157174
label: "OK",
158175
data: rows.map(row => percentify(row.getValue("ok"), row)),
159-
backgroundColor: "#bef264"
176+
backgroundColor: tailwind.theme.extend.colors.base.success[300],
160177
},
161178
{
162179
label: "Replicating",
163180
data: rows.map(row => percentify(row.getValue("replicating"), row)),
164-
backgroundColor: "#fcd34d",
181+
backgroundColor: tailwind.theme.extend.colors.base.warning[300],
165182
},
166183
{
167184
label: "Stuck",
168185
data: rows.map(row => percentify(row.getValue("stuck"), row)),
169-
backgroundColor: "#f87171"
186+
backgroundColor: tailwind.theme.extend.colors.base.error[400],
170187
}
171188
]
172189
} as ChartData<ChartDataNumeric>

src/component-library/Pages/Dashboard/Widgets/WidgetUsedquota.tsx

+20-33
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import { Pie } from 'react-chartjs-2';
66
import { BoolTag } from "@/component-library/Tags/BoolTag";
77
import { Number } from "@/component-library/Text/Content/Number";
88
import { Contenttd, Generaltable, Titleth } from "@/component-library/Helpers/Metatable";
9-
import { useEffect, useState } from "react";
10-
9+
import tailwind from "@/tailwind"
1110
ChartJS.register(ArcElement, Tooltip, Legend);
1211

1312
const RSEPie: React.FC<JSX.IntrinsicElements["div"] & {
@@ -20,21 +19,28 @@ const RSEPie: React.FC<JSX.IntrinsicElements["div"] & {
2019
labels: ["Used", "Free"],
2120
datasets: [{
2221
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]]
2423
}]
2524
}
25+
26+
const isDarkMode = () =>
27+
window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
28+
2629
const options = {
2730
plugins: {
2831
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+
}
3036
},
3137
}
3238
}
3339
const customid = input.rse + "-piediv"
3440
return (
3541
<div
3642
className={twMerge(
37-
"w-52 md:w-96 h-auto",
43+
"h-auto",
3844
"flex flex-col justify-start items-center",
3945
hideWhenSmall ? "hidden md:flex" : "",
4046
className ?? "",
@@ -44,13 +50,13 @@ const RSEPie: React.FC<JSX.IntrinsicElements["div"] & {
4450
>
4551
<label
4652
className={twMerge(
47-
"break-all",
53+
"w-max",
4854
)}
4955
htmlFor={customid}
5056
>
5157
{input.rse}
5258
</label>
53-
<div className="relative w-24 md:w-72">
59+
<div className="relative flex w-full">
5460
<Pie
5561
data={data}
5662
options={options}
@@ -87,25 +93,6 @@ export const WidgetUsedquota: React.FC<JSX.IntrinsicElements["div"] & {
8793
}
8894
) => {
8995
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
10996

11097
return (
11198
<div
@@ -116,20 +103,20 @@ export const WidgetUsedquota: React.FC<JSX.IntrinsicElements["div"] & {
116103
{...otherprops}
117104
>
118105
<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>
120107
</div>
121108
<div
122109
className={twMerge(
123110
"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",
124111
"dark:text-text-0 text-text-1000"
125112
)}
126113
>
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 />
133120
</div>
134121
</div>
135122
);

src/component-library/Pages/Rule/ListRule.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export const ListRule = (
101101
)
102102
},
103103
meta: {
104-
style: "w-36"
104+
style: ""
105105
}
106106
}),
107107
columnHelper.accessor("remaining_lifetime", {
@@ -118,7 +118,7 @@ export const ListRule = (
118118
)
119119
},
120120
meta: {
121-
style: "w-32"
121+
style: ""
122122
}
123123
}),
124124
columnHelper.accessor("state", {
@@ -136,12 +136,12 @@ export const ListRule = (
136136
)
137137
},
138138
meta: {
139-
style: "w-44"
139+
style: "md:w-44 w-28"
140140
}
141141
}),
142142
columnHelper.accessor("locks_ok_cnt", {
143143
id: "locks_ok_cnt",
144-
cell: info => <P className="text-right dark:text-text-0 text-text-1000">{info.getValue()}</P>,
144+
cell: info => <P className="text-right dark:text-text-0 text-text-1000">{info.getValue()}</P>,
145145
header: info => {
146146
return (
147147
<TableSortUpDown

src/component-library/StreamedTables/TableFilterString.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ export function TableFilterString(
6868
return (
6969
<form
7070
className={twMerge(
71-
"flex flex-row justify-between items-baseline space-x-8",
71+
"flex flex-row flex-wrap justify-between items-baseline ",
7272
"pr-2",
7373
className ?? "",
7474
)}
7575
role="search"
7676
aria-label={`Filter ${name} Column`}
7777
>
78-
<span className="shrink-0">
78+
<span className="">
7979
<H3>{name}</H3>
8080
</span>
8181
<Filter

src/component-library/outputtailwind.css

+9-17
Original file line numberDiff line numberDiff line change
@@ -918,10 +918,6 @@ html {
918918
width: 1.25rem;
919919
}
920920

921-
.w-52 {
922-
width: 13rem;
923-
}
924-
925921
.w-56 {
926922
width: 14rem;
927923
}
@@ -964,6 +960,10 @@ html {
964960
min-width: 0px;
965961
}
966962

963+
.min-w-full {
964+
min-width: 100%;
965+
}
966+
967967
.max-w-sm {
968968
max-width: 24rem;
969969
}
@@ -2012,6 +2012,11 @@ html {
20122012
color: rgb(241 245 249 / var(--tw-text-opacity));
20132013
}
20142014

2015+
.text-text-1000 {
2016+
--tw-text-opacity: 1;
2017+
color: rgb(0 0 0 / var(--tw-text-opacity));
2018+
}
2019+
20152020
.text-text-200 {
20162021
--tw-text-opacity: 1;
20172022
color: rgb(226 232 240 / var(--tw-text-opacity));
@@ -2052,11 +2057,6 @@ html {
20522057
color: rgb(113 113 122 / var(--tw-text-opacity));
20532058
}
20542059

2055-
.text-text-1000 {
2056-
--tw-text-opacity: 1;
2057-
color: rgb(0 0 0 / var(--tw-text-opacity));
2058-
}
2059-
20602060
.underline {
20612061
text-decoration-line: underline;
20622062
}
@@ -3083,14 +3083,6 @@ html {
30833083
width: 15rem;
30843084
}
30853085

3086-
.md\:w-72 {
3087-
width: 18rem;
3088-
}
3089-
3090-
.md\:w-96 {
3091-
width: 24rem;
3092-
}
3093-
30943086
.md\:w-\[400px\] {
30953087
width: 400px;
30963088
}

tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"paths": {
3030
"@/*": [
3131
"./src/*"
32-
]
32+
],
33+
"@/tailwind": ["./tailwind.config.js"]
3334
}
3435
},
3536
"include": [

0 commit comments

Comments
 (0)