Skip to content

Commit

Permalink
Merge pull request #567 from vitessio/refactor-homepage
Browse files Browse the repository at this point in the history
Refactor homepage
  • Loading branch information
frouioui authored Jul 9, 2024
2 parents cae8bd2 + f2d9fe3 commit ac7c561
Show file tree
Hide file tree
Showing 16 changed files with 1,289 additions and 201 deletions.
5 changes: 4 additions & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,22 @@
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-separator": "^1.1.0",
"@radix-ui/react-slot": "^1.0.2",
"bytes": "^3.1.2",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"dotenv": "^16.1.4",
"lucide-react": "^0.363.0",
"lucide-react": "^0.400.0",
"moment": "^2.29.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.10.1",
"react-json-pretty": "^2.2.0",
"react-router-dom": "^6.11.2",
"react-spinners": "^0.13.8",
"react-use": "^17.5.0",
"recharts": "^2.12.7",
"serve": "^14.2.0",
"swiper": "^9.4.1",
"tailwind-merge": "^2.2.2",
Expand Down
12 changes: 12 additions & 0 deletions website/src/assets/styles/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ limitations under the License.
--ring: 24.6 95% 53.1%;
--radius: 0.5rem;

--chart-1: 12 76% 61%;
--chart-2: 173 58% 39%;
--chart-3: 197 37% 24%;
--chart-4: 43 74% 66%;
--chart-5: 27 87% 67%;

--front: 0 0% 10%;
--back: 0 0% 100%;

Expand Down Expand Up @@ -86,6 +92,12 @@ limitations under the License.
--ring: 20.5 90.2% 48.2%;
--radius: 0.5rem;

--chart-1: 220 70% 50%;
--chart-2: 160 60% 45%;
--chart-3: 30 80% 55%;
--chart-4: 280 65% 60%;
--chart-5: 340 75% 55%;

--front: 0 0% 100%;
--back: 0 0% 10%;

Expand Down
126 changes: 126 additions & 0 deletions website/src/common/DailySummary.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*
Copyright 2024 The Vitess Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import {
Card,
CardContent,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import {
ChartConfig,
ChartContainer,
ChartTooltip,
} from "@/components/ui/chart";
import { DailySummarydata } from "@/types";
import PropTypes from "prop-types";
import { Line, LineChart, XAxis } from "recharts";

export type DailySummaryProps = {
data: DailySummarydata;
benchmarkType: string;
setBenchmarktype: (type: string) => void;
};

export default function DailySummary({ data }: DailySummaryProps) {
type ChartData = { name: string; totalQps: number };
const chartData: ChartData[] = [];

const chartConfig = {
desktop: {
label: "Total QPS",
color: "hsl(var(--primary))",
},
mobile: {
label: "Total QPS",
color: "hsl(var(--primary))",
},
} satisfies ChartConfig;

if (data.data !== null) {
data.data.map((item) => ({
totalQps: chartData.push({
name: "Total QPS",
totalQps: item.total_qps.center,
}),
}));
}

return (
<Card className="w-[310px] h-[124px] md:w-[316px] md:h-[124px] hover:scale-105 duration-300 border-border">
<CardHeader className="flex flex-row justify-between">
<CardTitle className="font-light text-sm">{data.name}</CardTitle>
<i className="h-4 w-4 text-foreground fa-solid fa-arrow-right daily--fa-arrow-right"></i>
</CardHeader>
<CardContent className="max-h-[4vh] md:max-h-[7vh] pt-0 pb-0">
<ChartContainer
config={chartConfig}
className="md:h-[80px] h-[60px] w-full"
>
<LineChart data={chartData}>
<XAxis dataKey="time" tickLine={false} axisLine={false} />
<ChartTooltip cursor={false} content={<CustomTooltip />} />
<Line
className="pb-0 pt-0"
dataKey="totalQps"
type="monotone"
label="Total QPS"
stroke="var(--color-desktop)"
strokeWidth={1}
dot={{
fill: "var(--color-desktop)",
}}
activeDot={{
r: 6,
}}
/>
</LineChart>
</ChartContainer>
</CardContent>
</Card>
);
}

const CustomTooltip = ({
active,
payload,
}: {
active?: boolean;
payload?: { value: number }[];
}) => {
if (active && payload && payload.length) {
return (
<div className="custom-tooltip p-2 border border-border shadow-lg rounded">
<p className="label flex items-center">
<span
className="inline-block w-2 h-2 mr-2"
style={{ backgroundColor: "hsl(var(--primary))" }}
></span>
{`Total QPS: ${payload[0].value.toFixed(0)}`}
</p>
</div>
);
}

return null;
};

CustomTooltip.propTypes = {
active: PropTypes.bool,
payload: PropTypes.array,
label: PropTypes.string,
};
Loading

0 comments on commit ac7c561

Please sign in to comment.