Skip to content

Commit

Permalink
Fix: Dashboard Opacity
Browse files Browse the repository at this point in the history
  • Loading branch information
shm11C3 committed Dec 21, 2024
1 parent edb06b3 commit ef68b51
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/components/charts/DoughnutChart.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useSettingsAtom } from "@/atom/useSettingsAtom";
import { type ChartConfig, ChartContainer } from "@/components/ui/chart";
import { Skeleton } from "@/components/ui/skeleton";
import { minOpacity } from "@/consts";
import type { HardwareDataType } from "@/types/hardwareDataType";
import { Lightning, Speedometer, Thermometer } from "@phosphor-icons/react";
import type { JSX } from "react";
Expand Down Expand Up @@ -76,7 +77,13 @@ export const DoughnutChart = ({
stroke="none"
className="first:fill-zinc-300 dark:first:fill-muted last:fill-zinc-200 last:dark:fill-gray-900"
style={{
opacity: (1 - settings.backgroundImgOpacity / 100) ** 2,
opacity:
settings.selectedBackgroundImg != null
? Math.max(
(1 - settings.backgroundImgOpacity / 100) ** 2,
minOpacity,
)
: 1,
}}
polarRadius={[70, 60]}
/>
Expand Down
9 changes: 8 additions & 1 deletion src/components/charts/ProcessTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";
import { minOpacity } from "@/consts";
import { useTauriDialog } from "@/hooks/useTauriDialog";
import { type ProcessInfo, commands } from "@/rspc/bindings";
import { ArrowsOut, CaretDown, CaretUp } from "@phosphor-icons/react";
Expand Down Expand Up @@ -101,7 +102,13 @@ export const ProcessesTable = () => {
<div
className="p-4 border rounded-md shadow-md bg-zinc-300 dark:bg-gray-800 dark:text-whit"
style={{
opacity: (1 - settings.backgroundImgOpacity / 100) ** 2,
opacity:
settings.selectedBackgroundImg != null
? Math.max(
(1 - settings.backgroundImgOpacity / 100) ** 2,
minOpacity,
)
: 1,
}}
>
<Dialog>
Expand Down
2 changes: 2 additions & 0 deletions src/consts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./chart";
export * from "./style";
1 change: 1 addition & 0 deletions src/consts/style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const minOpacity = 0.5;
9 changes: 8 additions & 1 deletion src/template/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from "@/components/charts/Bar";
import { DoughnutChart } from "@/components/charts/DoughnutChart";
import { ProcessesTable } from "@/components/charts/ProcessTable";
import { minOpacity } from "@/consts";
import type { StorageInfo } from "@/rspc/bindings";
import type { NameValues } from "@/types/hardwareDataType";
import { useAtom } from "jotai";
Expand All @@ -25,7 +26,13 @@ const InfoTable = ({ data }: { data: { [key: string]: string | number } }) => {
<div
className="px-4 pt-2 pb-4 border rounded-md shadow-md bg-zinc-300 dark:bg-gray-800 dark:text-white"
style={{
opacity: (1 - settings.backgroundImgOpacity / 100) ** 2,
opacity:
settings.selectedBackgroundImg != null
? Math.max(
(1 - settings.backgroundImgOpacity / 100) ** 2,
minOpacity,
)
: 1,
}}
>
<table className="w-full text-left">
Expand Down

0 comments on commit ef68b51

Please sign in to comment.