-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettingsToggle.jsx
135 lines (129 loc) · 3.77 KB
/
SettingsToggle.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
const React = require("react");
function SettingsToggle({
label,
description,
value,
onChange,
previewBefore,
previewAfter,
helpText,
onPreviewClick,
}) {
const [showHelp, setShowHelp] = React.useState(false);
const [isAnimating, setIsAnimating] = React.useState(false);
const handleToggle = () => {
setIsAnimating(true);
onChange();
setTimeout(() => setIsAnimating(false), 300);
};
return (
<div
className={`mt-4 defaultColor_a595eb setting-toggle ${isAnimating ? "animating" : ""}`}
style={{
width: "100%",
padding: "16px",
backgroundColor: "var(--background-secondary-alt)",
borderRadius: "8px",
transition: "transform 0.2s ease, background-color 0.2s ease",
border: "1px solid var(--background-modifier-accent)",
}}
>
<div
style={{
display: "flex",
justifyContent: "space-between",
alignItems: "flex-start",
marginBottom: previewBefore || previewAfter ? "8px" : "0",
}}
>
<div style={{ flex: 1 }}>
<h3 className="text-md/normal_dc00ef" style={{ marginBottom: "4px" }}>
{label}
</h3>
<p className="text-sm/normal_dc00ef" style={{ opacity: 0.7 }}>
{description}
</p>
</div>
<Nekocord.webpackModules.commonModules.Switch
checked={value}
onChange={handleToggle}
/>
</div>
<div
style={{
display: "flex",
gap: "8px",
marginTop: "8px",
alignItems: "center",
}}
>
{helpText && (
<div
className="help-icon"
onClick={() => setShowHelp(!showHelp)}
style={{
cursor: "pointer",
width: "16px",
height: "16px",
display: "flex",
alignItems: "center",
justifyContent: "center",
borderRadius: "50%",
backgroundColor: "var(--background-tertiary)",
color: "var(--text-muted)",
fontSize: "12px",
fontWeight: "bold",
}}
>
?
</div>
)}
{(previewBefore || previewAfter) && (
<button
onClick={() => onPreviewClick(previewBefore, previewAfter)}
style={{
backgroundColor: "transparent",
border: "none",
borderRadius: "4px",
padding: "4px 8px",
cursor: "pointer",
display: "flex",
alignItems: "center",
gap: "4px",
color: "var(--interactive-normal)",
fontSize: "12px",
marginTop: "8px",
}}
>
<svg width="16" height="16" viewBox="0 0 24 24">
<path
fill="currentColor"
d="M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"
/>
</svg>
Preview
</button>
)}
</div>
{showHelp && helpText && (
<div
className="help-tooltip"
style={{
backgroundColor: "var(--background-floating)",
padding: "12px",
borderRadius: "4px",
marginTop: "8px",
color: "var(--text-normal)",
fontSize: "14px",
lineHeight: "1.4",
boxShadow: "0 2px 10px rgba(0,0,0,0.2)",
border: "1px solid var(--background-modifier-accent)",
}}
>
{helpText}
</div>
)}
</div>
);
}
module.exports = SettingsToggle;