Skip to content

Commit 91dbced

Browse files
committed
hover color and line
1 parent 3c53d02 commit 91dbced

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

web-report/src/components/EndpointAccordion.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {AccordionContent, AccordionItem, AccordionTrigger} from "@/components/ui
22
import {Badge} from "@/components/ui/badge.tsx";
33
import React, {useState} from "react";
44
import {TestCases} from "@/components/TestCases.tsx";
5-
import {getColor} from "@/lib/utils";
5+
import {getColor, getHoverColor} from "@/lib/utils";
66

77
interface IStatusType {
88
code: number | string;
@@ -86,7 +86,7 @@ export const EndpointAccordion: React.FC<IEndpointAccordionProps> = ({
8686
setSelectedCode(code.code);
8787
setIsFault(false);
8888
}}
89-
className={`${getColor(code.code, true, false)} ${getSelectedStyle(code.code, false)} hover:bg-green-600 cursor-pointer text-white font-mono text-base border-2 border-black shadow-[2px_2px_0px_0px_rgba(0,0,0,1)]`}>
89+
className={`${getColor(code.code, true, false)} ${getSelectedStyle(code.code, false)} ${getHoverColor(code.code, false)} cursor-pointer text-white font-mono text-base border-2 border-black shadow-[2px_2px_0px_0px_rgba(0,0,0,1)]`}>
9090
{code.code == -1 ? "NO-RESPONSE" : `H${code.code}`}
9191
</Badge>
9292
))

web-report/src/components/ui/accordion.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function AccordionItem({
1717
return (
1818
<AccordionPrimitive.Item
1919
data-slot="accordion-item"
20-
className={cn("border-b last:border-b-0", className)}
20+
className={cn("border-b", className)}
2121
{...props}
2222
/>
2323
)

web-report/src/lib/utils.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ const getColorNumber = (code: number, isBackground: boolean) => {
2929
if (code >= 500) return isBackground ? "bg-red-500" : "text-red-500";
3030
};
3131

32+
export const getHoverColor = (code: string | number | null | undefined, isFault: boolean): string => {
33+
if (isFault) return "hover:bg-red-400";
34+
if (code === null || code === undefined || code === "") return "hover:bg-gray-400";
35+
const num = Number(code);
36+
if (isNaN(num)) return "hover:bg-red-400";
37+
if (num >= 200 && num < 300) return "hover:bg-green-600";
38+
if (num >= 300 && num < 400) return "hover:bg-blue-600";
39+
if (num >= 400 && num < 500) return "hover:bg-orange-600";
40+
if (num >= 500) return "hover:bg-red-600";
41+
return "hover:bg-gray-400";
42+
};
43+
3244
export const fetchFileContent = async (filePath: string): Promise<string | object> => {
3345
try {
3446
const response = await fetch(filePath);

0 commit comments

Comments
 (0)