Spaces:
Running
Running
Update src/App.tsx
Browse files- src/App.tsx +23 -64
src/App.tsx
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
// ... (لایسنس،
|
2 |
import React, { useEffect, useRef, useState } from "react";
|
3 |
import './App.scss';
|
4 |
import { LiveAPIProvider, useLiveAPIContext } from "./contexts/LiveAPIContext";
|
@@ -100,40 +100,16 @@ const SvgHumanIcon = () => (
|
|
100 |
</svg>
|
101 |
);
|
102 |
|
103 |
-
// SVG آیکون میکروفون از HTML مرجع شما - transform scale را موقتا حذف میکنیم یا به 1 تغییر میدهیم تا CSS کنترل کند
|
104 |
const SvgReferenceMicrophoneIcon = () => (
|
105 |
-
|
106 |
-
<svg className="reference-mic-svg" viewBox="0 0 69 68" fill="none" xmlns="http://www.w3.org/2000/svg"> {/* کلاس اضافه شده */}
|
107 |
<path opacity="0.4" d="M49.9479 27.1824C49.0803 27.1824 48.3907 27.872 48.3907 28.7396V32.2544C48.3907 40.1293 41.984 46.5361 34.109 46.5361C26.234 46.5361 19.8273 40.1293 19.8273 32.2544V28.7173C19.8273 27.8497 19.1377 27.1601 18.2701 27.1601C17.4025 27.1601 16.7129 27.8497 16.7129 28.7173V32.2321C16.7129 41.2861 23.6758 48.7384 32.5518 49.5393V54.2776C32.5518 55.1452 33.2414 55.8348 34.109 55.8348C34.9766 55.8348 35.6662 55.1452 35.6662 54.2776V49.5393C44.52 48.7607 51.5051 41.2861 51.5051 32.2321V28.7173C51.4829 27.872 50.7933 27.1824 49.9479 27.1824Z" fill="#BE123C"/>
|
108 |
<path d="M34.1099 11.3434C28.682 11.3434 24.2773 15.7481 24.2773 21.176V32.5658C24.2773 37.9938 28.682 42.3984 34.1099 42.3984C39.5379 42.3984 43.9425 37.9938 43.9425 32.5658V21.176C43.9425 15.7481 39.5379 11.3434 34.1099 11.3434ZM37.0241 26.8042C36.8684 27.3826 36.3567 27.7608 35.7784 27.7608C35.6671 27.7608 35.5559 27.7385 35.4447 27.7163C34.5771 27.4716 33.665 27.4716 32.7974 27.7163C32.0856 27.9165 31.396 27.4938 31.218 26.8042C31.0178 26.1146 31.4404 25.4027 32.1301 25.2247C33.4426 24.8688 34.8218 24.8688 36.1343 25.2247C36.8017 25.4027 37.2021 26.1146 37.0241 26.8042ZM38.2031 22.4885C38.0029 23.0224 37.5135 23.3339 36.9796 23.3339C36.8239 23.3339 36.6904 23.3116 36.5347 23.2671C34.9775 22.6887 33.2423 22.6887 31.6852 23.2671C31.0178 23.5118 30.2614 23.1559 30.0167 22.4885C29.772 21.8212 30.128 21.0648 30.7953 20.8423C32.9309 20.0637 35.289 20.0637 37.4245 20.8423C38.0919 21.087 38.4478 21.8212 38.2031 22.4885Z" fill="#BE123C"/>
|
109 |
</svg>
|
110 |
);
|
111 |
|
112 |
-
|
113 |
-
// (
|
114 |
-
const
|
115 |
-
isMicActive: boolean;
|
116 |
-
isCamActive: boolean;
|
117 |
-
setIsMicActive: React.Dispatch<React.SetStateAction<boolean>>;
|
118 |
-
setIsCamActive: React.Dispatch<React.SetStateAction<boolean>>;
|
119 |
-
createLogoFunction: (isMini: boolean, isActive: boolean, type?: 'human' | 'ai', forFooter?: boolean) => React.ReactNode;
|
120 |
-
videoRef: React.RefObject<HTMLVideoElement>;
|
121 |
-
notificationPopoverRef: React.RefObject<HTMLDivElement>;
|
122 |
-
notificationButtonRef: React.RefObject<HTMLButtonElement>;
|
123 |
-
isNotificationOpen: boolean;
|
124 |
-
setIsNotificationOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
125 |
-
}> = ({
|
126 |
-
isMicActive,
|
127 |
-
isCamActive,
|
128 |
-
setIsMicActive,
|
129 |
-
setIsCamActive,
|
130 |
-
createLogoFunction,
|
131 |
-
videoRef,
|
132 |
-
notificationPopoverRef,
|
133 |
-
notificationButtonRef,
|
134 |
-
isNotificationOpen,
|
135 |
-
setIsNotificationOpen
|
136 |
-
}) => {
|
137 |
const { connected, disconnect } = useLiveAPIContext();
|
138 |
|
139 |
useEffect(() => {
|
@@ -221,29 +197,11 @@ const AppInternalLogic: React.FC<{
|
|
221 |
</div>
|
222 |
</div>
|
223 |
);
|
224 |
-
}
|
225 |
-
|
226 |
-
const logoColorConfig = {
|
227 |
-
blue: {
|
228 |
-
ping: "bg-blue-200 dark:bg-blue-700",
|
229 |
-
outer: "bg-blue-200 dark:bg-blue-700",
|
230 |
-
mid: "bg-blue-300 dark:bg-blue-600",
|
231 |
-
inner: "bg-blue-400 dark:bg-blue-500",
|
232 |
-
},
|
233 |
-
green: {
|
234 |
-
ping: "bg-green-200 dark:bg-green-700",
|
235 |
-
outer: "bg-green-200 dark:bg-green-700",
|
236 |
-
mid: "bg-green-300 dark:bg-green-600",
|
237 |
-
inner: "bg-green-400 dark:bg-green-500",
|
238 |
-
},
|
239 |
-
gray: {
|
240 |
-
ping: "bg-gray-200 dark:bg-gray-700",
|
241 |
-
outer: "bg-gray-200 dark:bg-gray-700",
|
242 |
-
mid: "bg-gray-300 dark:bg-gray-600",
|
243 |
-
inner: "bg-gray-400 dark:bg-gray-500",
|
244 |
-
}
|
245 |
};
|
246 |
|
|
|
|
|
|
|
247 |
function App() {
|
248 |
const videoRef = useRef<HTMLVideoElement>(null);
|
249 |
const [showIOSModal, setShowIOSModal] = useState(false);
|
@@ -296,26 +254,28 @@ function App() {
|
|
296 |
|
297 |
const size = isMini ? 80 : 200;
|
298 |
const iconDisplaySize = isMini ? 35 : 70;
|
299 |
-
|
300 |
const iconInset = (size - iconDisplaySize) / 2;
|
301 |
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
icon: iconInset
|
308 |
-
};
|
309 |
|
310 |
const IconComponent = type === 'human' ? SvgHumanIcon : null;
|
311 |
|
312 |
return (
|
313 |
<div className={cn("logo-animation-wrapper", {"for-footer": forFooter})} style={{ width: `${size}px`, height: `${size}px` }}>
|
314 |
-
|
315 |
-
<div className={`absolute rounded-full opacity-50 ${currentColors.
|
316 |
-
|
317 |
-
<div className={`absolute rounded-full opacity-50 ${currentColors.
|
318 |
-
|
|
|
|
|
|
|
|
|
|
|
319 |
{IconComponent && <IconComponent />}
|
320 |
</div>
|
321 |
</div>
|
@@ -340,5 +300,4 @@ function App() {
|
|
340 |
</LiveAPIProvider>
|
341 |
);
|
342 |
}
|
343 |
-
|
344 |
export default App;
|
|
|
1 |
+
// ... (لایسنس، ایمپورتها، myCustomInstruction, initialAppConfig، SvgHumanIcon, SvgReferenceMicrophoneIcon، AppInternalLogic بدون تغییر از پاسخ قبلی) ...
|
2 |
import React, { useEffect, useRef, useState } from "react";
|
3 |
import './App.scss';
|
4 |
import { LiveAPIProvider, useLiveAPIContext } from "./contexts/LiveAPIContext";
|
|
|
100 |
</svg>
|
101 |
);
|
102 |
|
|
|
103 |
const SvgReferenceMicrophoneIcon = () => (
|
104 |
+
<svg className="reference-mic-svg" viewBox="0 0 69 68" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
|
105 |
<path opacity="0.4" d="M49.9479 27.1824C49.0803 27.1824 48.3907 27.872 48.3907 28.7396V32.2544C48.3907 40.1293 41.984 46.5361 34.109 46.5361C26.234 46.5361 19.8273 40.1293 19.8273 32.2544V28.7173C19.8273 27.8497 19.1377 27.1601 18.2701 27.1601C17.4025 27.1601 16.7129 27.8497 16.7129 28.7173V32.2321C16.7129 41.2861 23.6758 48.7384 32.5518 49.5393V54.2776C32.5518 55.1452 33.2414 55.8348 34.109 55.8348C34.9766 55.8348 35.6662 55.1452 35.6662 54.2776V49.5393C44.52 48.7607 51.5051 41.2861 51.5051 32.2321V28.7173C51.4829 27.872 50.7933 27.1824 49.9479 27.1824Z" fill="#BE123C"/>
|
106 |
<path d="M34.1099 11.3434C28.682 11.3434 24.2773 15.7481 24.2773 21.176V32.5658C24.2773 37.9938 28.682 42.3984 34.1099 42.3984C39.5379 42.3984 43.9425 37.9938 43.9425 32.5658V21.176C43.9425 15.7481 39.5379 11.3434 34.1099 11.3434ZM37.0241 26.8042C36.8684 27.3826 36.3567 27.7608 35.7784 27.7608C35.6671 27.7608 35.5559 27.7385 35.4447 27.7163C34.5771 27.4716 33.665 27.4716 32.7974 27.7163C32.0856 27.9165 31.396 27.4938 31.218 26.8042C31.0178 26.1146 31.4404 25.4027 32.1301 25.2247C33.4426 24.8688 34.8218 24.8688 36.1343 25.2247C36.8017 25.4027 37.2021 26.1146 37.0241 26.8042ZM38.2031 22.4885C38.0029 23.0224 37.5135 23.3339 36.9796 23.3339C36.8239 23.3339 36.6904 23.3116 36.5347 23.2671C34.9775 22.6887 33.2423 22.6887 31.6852 23.2671C31.0178 23.5118 30.2614 23.1559 30.0167 22.4885C29.772 21.8212 30.128 21.0648 30.7953 20.8423C32.9309 20.0637 35.289 20.0637 37.4245 20.8423C38.0919 21.087 38.4478 21.8212 38.2031 22.4885Z" fill="#BE123C"/>
|
107 |
</svg>
|
108 |
);
|
109 |
|
110 |
+
const AppInternalLogic: React.FC<{ /* ...props... */ }> = ({ /* ...props... */ }) => {
|
111 |
+
// ... (بدون تغییر)
|
112 |
+
const { isMicActive, isCamActive, setIsMicActive, setIsCamActive, createLogoFunction, videoRef, notificationPopoverRef, notificationButtonRef, isNotificationOpen, setIsNotificationOpen } = arguments[0];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
const { connected, disconnect } = useLiveAPIContext();
|
114 |
|
115 |
useEffect(() => {
|
|
|
197 |
</div>
|
198 |
</div>
|
199 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
};
|
201 |
|
202 |
+
|
203 |
+
const logoColorConfig = { /* ... (بدون تغییر) ... */ };
|
204 |
+
// ... (App و createLogoFunction مثل قبل، با تمرکز روی صحت رندر حلقهها) ...
|
205 |
function App() {
|
206 |
const videoRef = useRef<HTMLVideoElement>(null);
|
207 |
const [showIOSModal, setShowIOSModal] = useState(false);
|
|
|
254 |
|
255 |
const size = isMini ? 80 : 200;
|
256 |
const iconDisplaySize = isMini ? 35 : 70;
|
|
|
257 |
const iconInset = (size - iconDisplaySize) / 2;
|
258 |
|
259 |
+
// مقادیر inset برای حلقهها از HTML مرجع شما
|
260 |
+
// این مقادیر باید ثابت باشند تا ظاهر انیمیشن حفظ شود
|
261 |
+
const insetValues = isMini
|
262 |
+
? { ping: 10, outer: 0, mid: 5, inner: 12 } // مقادیر برای لوگوی کوچک
|
263 |
+
: { ping: 40, outer: 0, mid: 20, inner: 50 }; // مقادیر برای لوگوی بزرگ
|
|
|
|
|
264 |
|
265 |
const IconComponent = type === 'human' ? SvgHumanIcon : null;
|
266 |
|
267 |
return (
|
268 |
<div className={cn("logo-animation-wrapper", {"for-footer": forFooter})} style={{ width: `${size}px`, height: `${size}px` }}>
|
269 |
+
{/* حلقه Ping */}
|
270 |
+
<div className={`absolute rounded-full opacity-50 animate-ping ${currentColors.ping}`} style={{ inset: `${insetValues.ping}px` }}></div>
|
271 |
+
{/* حلقه بیرونی */}
|
272 |
+
<div className={`absolute rounded-full opacity-50 ${currentColors.outer}`} style={{ inset: `${insetValues.outer}px` }}></div>
|
273 |
+
{/* حلقه میانی */}
|
274 |
+
<div className={`absolute rounded-full opacity-50 ${currentColors.mid}`} style={{ inset: `${insetValues.mid}px` }}></div>
|
275 |
+
{/* حلقه داخلی */}
|
276 |
+
<div className={`absolute rounded-full opacity-50 ${currentColors.inner}`} style={{ inset: `${insetValues.inner}px` }}></div>
|
277 |
+
{/* کانتینر آیکون */}
|
278 |
+
<div className="z-10 absolute flex items-center justify-center" style={{ inset: `${iconInset}px`, width: `${iconDisplaySize}px`, height: `${iconDisplaySize}px` }}>
|
279 |
{IconComponent && <IconComponent />}
|
280 |
</div>
|
281 |
</div>
|
|
|
300 |
</LiveAPIProvider>
|
301 |
);
|
302 |
}
|
|
|
303 |
export default App;
|