Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/ui improvements #126

Merged
merged 10 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/).

## 0.8.0-rc
## 0.7.1
- Change Chart height
- Improve font style
- Improve reference colors for charts
- Minor UI improvements


## 0.7.0
- Improve Settings page UI
Expand Down
81 changes: 81 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,87 @@
}
</style>

<!-- LOAD GOOGLE FONTS START -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap"
rel="stylesheet"
/>
<style>
.roboto-thin {
font-family: "Roboto", sans-serif;
font-weight: 100;
font-style: normal;
}

.roboto-light {
font-family: "Roboto", sans-serif;
font-weight: 300;
font-style: normal;
}

.roboto-regular {
font-family: "Roboto", sans-serif;
font-weight: 400;
font-style: normal;
}

.roboto-medium {
font-family: "Roboto", sans-serif;
font-weight: 500;
font-style: normal;
}

.roboto-bold {
font-family: "Roboto", sans-serif;
font-weight: 700;
font-style: normal;
}

.roboto-black {
font-family: "Roboto", sans-serif;
font-weight: 900;
font-style: normal;
}

.roboto-thin-italic {
font-family: "Roboto", sans-serif;
font-weight: 100;
font-style: italic;
}

.roboto-light-italic {
font-family: "Roboto", sans-serif;
font-weight: 300;
font-style: italic;
}

.roboto-regular-italic {
font-family: "Roboto", sans-serif;
font-weight: 400;
font-style: italic;
}

.roboto-medium-italic {
font-family: "Roboto", sans-serif;
font-weight: 500;
font-style: italic;
}

.roboto-bold-italic {
font-family: "Roboto", sans-serif;
font-weight: 700;
font-style: italic;
}

.roboto-black-italic {
font-family: "Roboto", sans-serif;
font-weight: 900;
font-style: italic;
}
</style>
<!-- LOAD GOOGLE FONTS END -->
<title>Pachtop</title>
</head>
<body>
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"highcharts-react-official": "^3.2.1",
"lodash.sortby": "^4.7.0",
"mantine-datatable": "^2.9.14",
"non.geist": "^1.0.3",
"pocketbase": "^0.21.2",
"posthog-js": "^1.131.4",
"react": "^18.3.1",
Expand All @@ -48,4 +49,4 @@
"vite": "^5.2.11"
},
"packageManager": "[email protected]"
}
}
66 changes: 40 additions & 26 deletions src/components/area-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,34 @@ export interface InitialAreaChatStateInput {
export const useAreaChartState = (
opts: InitialAreaChatStateInput
): [Highcharts.Options, Dispatch<SetStateAction<Highcharts.Options>>] => {
const theme = useMantineTheme();
const { other } = useMantineTheme();
const [chartOptions, setChartOptions] = useState<Highcharts.Options>({
title: {
text: opts.title.text,
style: {
fontFamily: "Roboto, Arial, sans-serif",
fontFamily: "Geist Variable, Roboto, Arial, sans-serif",
fontWeight: "bold",
fontSize: "18px",
color: "#dce1e8",
},
},
// This is the rectangle box that u can use to navigate
navigator: {
adaptToUpdatedData: true,
maskFill: other.charts.area.default.navigator.maskFill,
handles: {
backgroundColor: other.charts.area.default.navigator.handles.backgroundColor,
},
},

plotOptions: {
series: {
marker: {
enabled: false,
},
},
area: {
stacking: "normal",

area: {
lineWidth: 1,
marker: {
lineWidth: 1,
Expand All @@ -52,18 +60,21 @@ export const useAreaChartState = (
},
xAxis: {
type: "datetime",
gridLineColor: "#263858",
lineColor: "#263858",
gridLineColor: other.charts.area.default.gridLineColor,
lineColor: other.charts.area.default.lineColor,
labels: {
step: 2,
format: "{value:%I:%M %p}",
style: {
color: "#8192ac",
color: other.charts.area.default.labelColor,
},
},
},
legend: {
enabled: false,
itemStyle: {
color: other.charts.area.default.legend.color,
},
enabled: true,
},
time: {
useUTC: false,
Expand All @@ -75,8 +86,8 @@ export const useAreaChartState = (
text: null,
},
startOnTick: true,
gridLineColor: "#263858",
lineColor: "#263858",
gridLineColor: other.charts.area.default.gridLineColor,
lineColor: other.charts.area.default.lineColor,
labels: {
formatter: opts.yAxis.labels.formatter,
style: {
Expand All @@ -91,33 +102,35 @@ export const useAreaChartState = (
xDateFormat: "%Y-%m-%d %I:%M:%S %p",
pointFormatter: opts.tooltip.pointFormatter,
style: {
color: "#dce1e8",
color: other.charts.area.default.tooltip.color,
},
backgroundColor: "#263858",
backgroundColor: other.charts.area.default.tooltip.backgroundColor,
},
// Scrollbar at the bottom of the chart
scrollbar: {
rifleColor: "#324363",
barBackgroundColor: "#324363",
buttonBackgroundColor: "#324363",
trackBorderColor: "#324363",
rifleColor: other.charts.area.default.scrollbar.rifleColor,
barBackgroundColor: other.charts.area.default.scrollbar.barBackgroundColor,
buttonBackgroundColor: other.charts.area.default.scrollbar.buttonBackgroundColor,
trackBorderColor: other.charts.area.default.scrollbar.trackBorderColor,
},
// This is the calendar thing on the top right
rangeSelector: {
labelStyle: {
color: "#8192ac",
backgroundColor: "#263858",
color: other.charts.area.default.rangeSelector.labelStyle.color,
backgroundColor: other.charts.area.default.rangeSelector.labelStyle.backgroundColor,
},

inputStyle: {
color: "#8192ac",
color: other.charts.area.default.rangeSelector.inputStyle.color,
},
buttonTheme: {
fill: "none",
display: "none",
r: 8,
style: {
background: "none",
color: "#8192ac",
backgroundColor: "#263858",
color: other.charts.area.default.buttonTheme.style.color,
backgroundColor: other.charts.area.default.buttonTheme.style.backgroundColor,
fontWeight: "bold",
},
},
Expand All @@ -142,15 +155,16 @@ export const useAreaChartState = (
text: "All",
},
],
// inputEnabled: false,

selected: 0,
},

boost: {
enabled: true,
useGPUTranslations: false,
allowForce: true,
},
chart: {
backgroundColor: "transparent",
style: {
color: "#dce1e8",
},
},
});

Expand Down
5 changes: 3 additions & 2 deletions src/components/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import { Card as MantineCard } from "@mantine/core";

interface CardProps {
children: React.ReactNode;
height?: string;
style?: React.CSSProperties;
}

const Card: React.FC<CardProps> = ({ children, style }) => {
const styles: React.CSSProperties = { height: "300px", ...style };
const Card: React.FC<CardProps> = ({ children, style, height = "300px" }) => {
const styles: React.CSSProperties = { height, ...style };
return (
<MantineCard style={styles} shadow="xl" p="sm" radius={"md"} withBorder>
{children}
Expand Down
2 changes: 1 addition & 1 deletion src/components/page-wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface PageWrapperProps {
const PageWrapper: React.FC<PageWrapperProps> = ({ children, name, height }) => {
return (
<Stack spacing="lg" h={height}>
<Title order={2}>{name}</Title>
<Title order={1}>{name}</Title>
{children}
</Stack>
);
Expand Down
5 changes: 3 additions & 2 deletions src/components/stats-ring.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DefaultMantineColor, Paper, Group, RingProgress, Center, rem, Text } from "@mantine/core";
import { IconArrowUpRight, IconArrowDownRight, TablerIconsProps } from "@tabler/icons-react";
import Card from "./card";

interface StatsRingProps {
label: string;
Expand All @@ -11,7 +12,7 @@ interface StatsRingProps {

const StatsRing: React.FC<StatsRingProps> = (props) => {
return (
<Paper withBorder radius={"md"} p={"xs"}>
<Card height="100%">
<Group>
<RingProgress
size={80}
Expand All @@ -33,7 +34,7 @@ const StatsRing: React.FC<StatsRingProps> = (props) => {
</Text>
</div>
</Group>
</Paper>
</Card>
);
};

Expand Down
2 changes: 2 additions & 0 deletions src/features/metrics/components/disks/disk.area-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const DiskAreaChart: React.FC<DiskAreaChartProps> = ({ disk }) => {
title: {
text: `${disk.id} Disk Usage`,
},


yAxis: {
labels: {
formatter: (x) => formatBytes(x.value as number),
Expand Down
4 changes: 2 additions & 2 deletions src/features/metrics/components/disks/disk.stats-ring.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import StatsRing from "@/components/stats-ring";
import formatOverallStats from "@/features/metrics/utils/format-overall-stats";
import React from "react";

import { IconCpu2 } from "@tabler/icons-react";
import { IconCpu2, IconFileAnalytics, IconFolders } from "@tabler/icons-react";
import { useMantineTheme } from "@mantine/core";

const DiskStatsRing: React.FC = ({}) => {
Expand All @@ -21,7 +21,7 @@ const DiskStatsRing: React.FC = ({}) => {
const label = `Disk ${disk?.data?.at(-1)?.name}`;

return (
<StatsRing color={other.charts.statsRing.disk} Icon={IconCpu2} stats={stats} label={label} progress={progress} />
<StatsRing color={other.charts.statsRing.disk} Icon={IconFolders} stats={stats} label={label} progress={progress} />
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const MemoryAreaChart: React.FC = ({}) => {
const { other } = useMantineTheme();
const [chartOptions, setChartOptions] = useAreaChartState({
title: {
text: "Ram Usage",
text: "RAM Usage",
},
yAxis: {
labels: {
Expand Down
10 changes: 8 additions & 2 deletions src/features/metrics/components/memory/memory.stats-ring.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import StatsRing from "@/components/stats-ring";
import formatOverallStats from "@/features/metrics/utils/format-overall-stats";
import React from "react";

import { IconCpu2 } from "@tabler/icons-react";
import { IconChartArea, IconCpu2 } from "@tabler/icons-react";
import { useMantineTheme } from "@mantine/core";

const MemoryStatsRing: React.FC = ({}) => {
Expand All @@ -17,7 +17,13 @@ const MemoryStatsRing: React.FC = ({}) => {
const stats = React.useMemo(() => formatOverallStats(used, available), [used, available]);

return (
<StatsRing color={other.charts.statsRing.memory} Icon={IconCpu2} stats={stats} label="Memory" progress={progress} />
<StatsRing
color={other.charts.statsRing.memory}
Icon={IconChartArea}
stats={stats}
label="Memory"
progress={progress}
/>
);
};

Expand Down
2 changes: 1 addition & 1 deletion src/features/metrics/components/swap/swap.area-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const SwapAreaChart: React.FC = ({}) => {
const { other } = useMantineTheme();
const [chartOptions, setChartOptions] = useAreaChartState({
title: {
text: "Swap Memory Usage",
text: "Swap Usage",
},
yAxis: {
labels: {
Expand Down
4 changes: 2 additions & 2 deletions src/features/metrics/components/swap/swap.stats-ring.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import StatsRing from "@/components/stats-ring";
import formatOverallStats from "@/features/metrics/utils/format-overall-stats";
import React from "react";

import { IconCpu2 } from "@tabler/icons-react";
import { IconCpu2, IconFile } from "@tabler/icons-react";
import { useMantineTheme } from "@mantine/core";

const SwapStatsRing: React.FC = ({}) => {
Expand All @@ -17,7 +17,7 @@ const SwapStatsRing: React.FC = ({}) => {
const stats = React.useMemo(() => formatOverallStats(used, available), [used, available]);

return (
<StatsRing color={other.charts.statsRing.swap} Icon={IconCpu2} stats={stats} label="Swap" progress={progress} />
<StatsRing color={other.charts.statsRing.swap} Icon={IconFile} stats={stats} label="Swap" progress={progress} />
);
};

Expand Down
Loading
Loading