Skip to content

Commit 2414266

Browse files
authored
Merge pull request #3 from yunying1/feat-staring-status
feat: New staring status
2 parents b4529e7 + d491f5f commit 2414266

File tree

3 files changed

+58
-3
lines changed

3 files changed

+58
-3
lines changed

src/Components/Button/index.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.button {
2+
position: relative;
23
background-color: #16A34A;
34
padding: 8px 10px;
45
border-radius: 4px;
@@ -18,4 +19,14 @@
1819
.small {
1920
padding: 4px 10px;
2021
font-size: 10px;
22+
}
23+
24+
.loading {
25+
opacity: .65;
26+
pointer-events: none;
27+
}
28+
29+
.loading-icon {
30+
position: absolute;
31+
right: 10px;
2132
}

src/Components/Button/index.jsx

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,49 @@
11
import "./index.css";
22

33
function Button(props) {
4-
const { size, className, children, ...args } = props;
5-
return <div className={`button ${size || ""} ${className}`} {...args}>{children}</div>;
4+
const { size, className, children, isLoding, ...args } = props;
5+
return (
6+
<div
7+
className={`button ${size || ""} ${className} ${isLoding && "loading"}`}
8+
{...args}
9+
>
10+
{children}
11+
{isLoding && (
12+
<svg
13+
xmlns="http://www.w3.org/2000/svg"
14+
width="1em"
15+
height="1em"
16+
preserveAspectRatio="xMidYMid meet"
17+
viewBox="0 0 24 24"
18+
className="loading-icon"
19+
>
20+
<path
21+
fill="none"
22+
stroke="currentColor"
23+
stroke-dasharray="15"
24+
stroke-dashoffset="15"
25+
stroke-linecap="round"
26+
stroke-width="2"
27+
d="M12 3C16.9706 3 21 7.02944 21 12"
28+
>
29+
<animate
30+
fill="freeze"
31+
attributeName="stroke-dashoffset"
32+
dur="0.3s"
33+
values="15;0"
34+
/>
35+
<animateTransform
36+
attributeName="transform"
37+
dur="1s"
38+
repeatCount="indefinite"
39+
type="rotate"
40+
values="0 12 12;360 12 12"
41+
/>
42+
</path>
43+
</svg>
44+
)}
45+
</div>
46+
);
647
}
748

849
export default Button;

src/app.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const App = () => {
2626
const [isStarted, setIsStarted] = useState(false);
2727
const [serviceUrl, setServiceUrl] = useState("");
2828
const [isShowTips, setIsShowTips] = useState(false);
29+
const [isStaring, setIsStaring] = useState(false);
2930

3031
/**
3132
* @desc start service
@@ -36,11 +37,13 @@ const App = () => {
3637
alert(t("Please select a directory!"));
3738
return;
3839
}
40+
setIsStaring(true);
3941
const params = { directoryPath, port, publicIP, username, password };
4042
window.electronAPI
4143
.emit("sharing", { type: shareType, params })
4244
.then((res) => {
4345
if (res.success) {
46+
setIsStaring(false);
4447
setIsStarted(true);
4548
setServiceUrl(res.url);
4649
QRCode.toDataURL(res.url).then((res) => {
@@ -278,7 +281,7 @@ const App = () => {
278281
</div>
279282
</div>
280283
<div style={{ flex: 1 }}></div>
281-
<Button className="btn btn-start" onClick={onStartServiceHandle}>
284+
<Button className="btn btn-start" onClick={onStartServiceHandle} isLoding={isStaring}>
282285
{t("Start Service")}
283286
</Button>
284287
</div>

0 commit comments

Comments
 (0)