refactor: remove mui from gpgui helper

This commit is contained in:
Kevin Yue committed 2026-08-07 23:34:22 +08:00
1 parent cd8eb1d9eb
commit 842df3201b
9 files changed
+130 -755

No files matched your search

+46 -55
View File
@@ -1,4 +1,3 @@
import { Box, Button, CssBaseline, LinearProgress, Typography } from "@mui/material";
import { getCurrentWindow } from "@tauri-apps/api/window";
import logo from "../../assets/icon-small.svg";
import { useEffect, useState } from "react";
@@ -48,80 +47,72 @@ export default function App() {
};
return (
<>
<CssBaseline />
<Box className="update-window" data-tauri-drag-region>
<Box
component="img"
src={logo}
alt="GPGUI"
className="update-logo"
data-tauri-drag-region
/>
<Box className="update-content" data-tauri-drag-region>
{error ? <DownloadFailed onRetry={handleRetry} /> : <DownloadIndicator progress={progress} />}
</Box>
</Box>
</>
<div className="update-window" data-tauri-drag-region>
<img src={logo} alt="" className="update-logo" data-tauri-drag-region />
<div className="update-content" data-tauri-drag-region>
{error ? (
<DownloadFailed onRetry={handleRetry} />
) : (
<DownloadIndicator progress={progress} />
)}
</div>
</div>
);
}
function DownloadIndicator({ progress }: { progress: number | null }) {
return (
<Box className="update-status" data-tauri-drag-region>
<Typography component="h1" className="update-title" data-tauri-drag-region>
<div className="update-status" data-tauri-drag-region>
<h1 className="update-title" data-tauri-drag-region>
Downloading GPGUI
</Typography>
<Typography className="update-description" data-tauri-drag-region>
</h1>
<p className="update-description" data-tauri-drag-region>
This may take a moment.
</Typography>
<LinearProgressWithLabel value={progress} />
</Box>
</p>
<ProgressWithLabel value={progress} />
</div>
);
}
function DownloadFailed({ onRetry }: { onRetry: () => void }) {
return (
<Box className="update-status error-status" data-tauri-drag-region>
<Typography component="h1" className="update-title" data-tauri-drag-region>
GPGUI couldn’t be downloaded
</Typography>
<Box className="error-actions" data-tauri-drag-region>
<Typography className="update-description" data-tauri-drag-region>
Check your connection and try again.
</Typography>
<Button
variant="contained"
size="small"
onClick={onRetry}
className="retry-button"
>
Retry
</Button>
</Box>
</Box>
<div className="update-status error-status" data-tauri-drag-region>
<div className="error-copy" role="alert" data-tauri-drag-region>
<h1 className="update-title" data-tauri-drag-region>
GPGUI update failed
</h1>
<p className="update-description" data-tauri-drag-region>
Please try again.
</p>
</div>
<button type="button" onClick={onRetry} className="retry-button">
Retry
</button>
</div>
);
}
function LinearProgressWithLabel(props: { value: number | null }) {
const { value } = props;
function ProgressWithLabel({ value }: { value: number | null }) {
const isDeterminate = value !== null;
return (
<Box className="progress-row">
<Box className="progress-track">
<LinearProgress
variant={value === null ? "indeterminate" : "determinate"}
value={value ?? 0}
className="progress-bar"
aria-label="Update progress"
/>
</Box>
<Typography
<div className="progress-row">
<div
className={`progress-bar${isDeterminate ? "" : " progress-bar-indeterminate"}`}
role="progressbar"
aria-label="Update progress"
aria-valuemin={isDeterminate ? 0 : undefined}
aria-valuemax={isDeterminate ? 100 : undefined}
aria-valuenow={isDeterminate ? Math.round(value) : undefined}
>
<div className="progress-fill" style={isDeterminate ? { width: `${value}%` } : undefined} />
</div>
<span
className={`progress-label${value === null ? " progress-label-hidden" : ""}`}
aria-hidden={value === null}
>
{value === null ? "100%" : `${Math.round(value)}%`}
</Typography>
</Box>
</span>
</div>
);
}
+72 -27
View File
@@ -1,6 +1,7 @@
html,
body,
#root {
box-sizing: border-box;
height: 100%;
margin: 0;
padding: 0;
@@ -14,7 +15,16 @@ body {
background: #f6f5f4;
color: #2e3436;
font-family:
Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
Inter,
ui-sans-serif,
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
sans-serif;
}
button {
font: inherit;
}
.update-window {
@@ -40,7 +50,8 @@ body {
width: 100%;
}
.update-title.MuiTypography-root {
.update-title {
margin: 0;
color: #2e3436;
font-size: 16px;
font-weight: 600;
@@ -48,8 +59,8 @@ body {
letter-spacing: -0.01em;
}
.update-description.MuiTypography-root {
margin-top: 3px;
.update-description {
margin: 3px 0 0;
color: #5e5c64;
font-size: 12px;
line-height: 1.4;
@@ -62,25 +73,50 @@ body {
margin-top: 9px;
}
.progress-track {
.progress-bar {
position: relative;
flex: 1;
min-width: 0;
}
.progress-bar.MuiLinearProgress-root {
height: 6px;
overflow: hidden;
border-radius: 3px;
background-color: #d5d3d1;
}
.progress-bar .MuiLinearProgress-bar {
.progress-fill {
height: 100%;
border-radius: 3px;
background: #3584e4;
transition: transform 180ms ease-out;
transition: width 180ms ease-out;
}
.progress-label.MuiTypography-root {
.progress-bar-indeterminate .progress-fill {
width: 35%;
animation: progress-indeterminate 1.4s ease-in-out infinite;
}
@keyframes progress-indeterminate {
from {
transform: translateX(-110%);
}
to {
transform: translateX(300%);
}
}
@media (prefers-reduced-motion: reduce) {
.progress-fill {
transition: none;
}
.progress-bar-indeterminate .progress-fill {
animation: none;
transform: translateX(90%);
}
}
.progress-label {
min-width: 36px;
color: #3d3846;
font-size: 12px;
@@ -89,38 +125,47 @@ body {
text-align: right;
}
.progress-label-hidden.MuiTypography-root {
.progress-label-hidden {
visibility: hidden;
}
.error-status .update-title.MuiTypography-root {
color: #9c2f2f;
}
.error-actions {
.error-status {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
margin-top: 8px;
}
.error-actions .update-description.MuiTypography-root {
margin-top: 0;
.error-status .update-title {
color: #9c2f2f;
}
.retry-button.MuiButton-root {
.error-copy {
min-width: 0;
}
.retry-button {
min-width: 68px;
padding: 4px 14px;
border: 0;
border-radius: 8px;
background: #3584e4;
box-shadow: none;
background: #1c71d8;
color: #ffffff;
cursor: pointer;
font-size: 12px;
font-weight: 600;
line-height: 1.5;
text-transform: none;
}
.retry-button.MuiButton-root:hover {
background: #1c71d8;
box-shadow: none;
.retry-button:hover {
background: #1a5fb4;
}
.retry-button:active {
background: #174a8b;
}
.retry-button:focus-visible {
outline: 2px solid #1a5fb4;
outline-offset: 2px;
}