Skip to content

Commit 15e6404

Browse files
committed
refactor: migrate UpdateToast styles to CSS and update component layout
1 parent 82ec665 commit 15e6404

2 files changed

Lines changed: 93 additions & 60 deletions

File tree

src/components/UpdateToast.css

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
.update-toast {
2+
position: fixed;
3+
bottom: 20px;
4+
right: 20px;
5+
z-index: 99999;
6+
display: flex;
7+
align-items: flex-start;
8+
gap: 24px;
9+
padding: 14px 18px;
10+
border-radius: 12px;
11+
font-family: 'EmOne', sans-serif;
12+
pointer-events: auto;
13+
min-width: 220px;
14+
will-change: transform, opacity;
15+
transform: translateY(calc(100% + 30px));
16+
opacity: 0;
17+
transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
18+
19+
background-color: #260000;
20+
border: 1px solid rgba(138, 0, 0, 0.4);
21+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
22+
}
23+
24+
.update-toast.visible {
25+
transform: translateY(0);
26+
opacity: 1;
27+
}
28+
29+
.update-toast.dismissing {
30+
transition: transform 0.25s ease-in, opacity 0.25s ease-in;
31+
}
32+
33+
.update-toast-text {
34+
flex: 1;
35+
}
36+
37+
.update-toast-title {
38+
font-size: 14px;
39+
font-weight: 700;
40+
color: #DEDADA;
41+
white-space: nowrap;
42+
user-select: none;
43+
line-height: 1.3;
44+
}
45+
46+
.update-toast-subtitle {
47+
font-size: 12px;
48+
font-weight: 400;
49+
color: #BDB5B5;
50+
user-select: none;
51+
margin-top: 3px;
52+
line-height: 1.3;
53+
}
54+
55+
.update-toast-actions {
56+
display: flex;
57+
align-items: center;
58+
gap: 4px;
59+
margin-top: 2px;
60+
}

src/components/UpdateToast.jsx

Lines changed: 33 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState, useEffect } from 'react';
22
import { RotateCcw, X } from 'lucide-react';
33
import PanelIconButton from './shared/PanelIconButton.jsx';
4-
import { useTheme } from '../hooks/useTheme.js';
4+
import './UpdateToast.css';
55

66
/**
77
* UpdateToast — bottom-right notification shown when an Electron auto-update
@@ -11,13 +11,12 @@ export default function UpdateToast() {
1111
const [updateInfo, setUpdateInfo] = useState(null);
1212
const [dismissed, setDismissed] = useState(false);
1313
const [visible, setVisible] = useState(false);
14-
const theme = useTheme();
14+
const [dismissing, setDismissing] = useState(false);
1515

1616
useEffect(() => {
1717
if (!window.electron?.updater?.onUpdateReady) return;
1818
window.electron.updater.onUpdateReady((info) => {
1919
setUpdateInfo(info);
20-
// Trigger slide-in on next frame
2120
requestAnimationFrame(() => setVisible(true));
2221
});
2322
}, []);
@@ -29,69 +28,43 @@ export default function UpdateToast() {
2928
};
3029

3130
const handleDismiss = () => {
31+
setDismissing(true);
3232
setVisible(false);
33-
// Wait for slide-out animation before unmounting
3433
setTimeout(() => setDismissed(true), 250);
3534
};
3635

37-
const containerStyle = {
38-
position: 'fixed',
39-
bottom: 20,
40-
right: 20,
41-
zIndex: 99999,
42-
display: 'flex',
43-
alignItems: 'center',
44-
gap: 10,
45-
padding: '10px 14px',
46-
borderRadius: 10,
47-
backgroundColor: theme.darkMode ? '#1a1616' : '#f5f0f0',
48-
border: `1px solid ${theme.canvas.border}`,
49-
boxShadow: theme.darkMode
50-
? '0 4px 20px rgba(0,0,0,0.5)'
51-
: '0 4px 20px rgba(0,0,0,0.15)',
52-
transform: visible ? 'translateY(0)' : 'translateY(calc(100% + 30px))',
53-
opacity: visible ? 1 : 0,
54-
transition: 'transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease',
55-
fontFamily: "'EmOne', sans-serif",
56-
pointerEvents: 'auto',
57-
};
58-
59-
const textStyle = {
60-
fontSize: 13,
61-
fontWeight: 600,
62-
color: theme.canvas.textPrimary,
63-
whiteSpace: 'nowrap',
64-
userSelect: 'none',
65-
};
66-
67-
const versionStyle = {
68-
fontSize: 11,
69-
color: theme.canvas.textSecondary,
70-
marginLeft: 2,
71-
};
36+
const className = [
37+
'update-toast',
38+
visible && 'visible',
39+
dismissing && 'dismissing',
40+
].filter(Boolean).join(' ');
7241

7342
return (
74-
<div style={containerStyle}>
75-
<span style={textStyle}>
76-
Restart to Update
77-
{updateInfo.version && (
78-
<span style={versionStyle}>v{updateInfo.version}</span>
79-
)}
80-
</span>
81-
<PanelIconButton
82-
icon={RotateCcw}
83-
size={15}
84-
onClick={handleRestart}
85-
title="Restart and install update"
86-
variant="outline"
87-
/>
88-
<PanelIconButton
89-
icon={X}
90-
size={15}
91-
onClick={handleDismiss}
92-
title="Dismiss"
93-
variant="ghost"
94-
/>
43+
<div className={className}>
44+
<div className="update-toast-text">
45+
<div className="update-toast-title">
46+
Version {updateInfo.version || 'update'} released
47+
</div>
48+
<div className="update-toast-subtitle">
49+
Restart to update
50+
</div>
51+
</div>
52+
<div className="update-toast-actions">
53+
<PanelIconButton
54+
icon={RotateCcw}
55+
size={15}
56+
onClick={handleRestart}
57+
title="Restart and install update"
58+
variant="outline"
59+
/>
60+
<PanelIconButton
61+
icon={X}
62+
size={15}
63+
onClick={handleDismiss}
64+
title="Dismiss"
65+
variant="ghost"
66+
/>
67+
</div>
9568
</div>
9669
);
9770
}

0 commit comments

Comments
 (0)