Ezmary commited on
Commit
ca321c0
·
verified ·
1 Parent(s): b9f6bcf

Update src/App.tsx

Browse files
Files changed (1) hide show
  1. src/App.tsx +46 -48
src/App.tsx CHANGED
@@ -19,8 +19,7 @@ import { IOSModal } from "./components/ios-modal/IOSModal";
19
  import { isIOS } from "./lib/platform";
20
  import cn from "classnames";
21
  import { LiveConfig } from "./multimodal-live-types";
22
- // import { Altair } from "./components/altair/Altair"; // اگر چت جداگانه ندارید، لازم نیست
23
- // import SidePanel from "./components/side-panel/SidePanel"; // اگر چت جداگانه ندارید، لازم نیست
24
 
25
  const myCustomInstruction = `
26
  ت1. هویت دستیار:
@@ -106,6 +105,8 @@ const initialAppConfig: LiveConfig = {
106
  },
107
  };
108
 
 
 
109
  const SvgHumanIcon = () => (
110
  <svg width="70" height="70" viewBox="0 0 88 89" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M75.1481 81.6361H12.9259C9.66667 81.6361 7 78.9721 7 75.7161V58.5112C7 57.5862 7 57.1052 7.44444 56.2172C8.85185 52.9612 13 50.2232 19.4815 47.8922C24.1111 56.6982 33.3704 62.6921 44 62.6921C54.6296 62.6921 63.9259 56.6982 68.5185 47.8922C75 50.1862 79.1852 52.9982 80.5556 56.2172C81 56.6612 81 57.6232 81 58.5112V75.7161C81 78.9721 78.3333 81.6361 75.0741 81.6361H75.1481Z" stroke="currentColor" strokeWidth="6.42146" strokeLinecap="round" strokeLinejoin="round"/><path d="M44.0371 50.1862C33.8519 50.1862 25.5186 41.8612 25.5186 31.6863V26.1363C25.5186 15.9613 33.8519 7.63635 44.0371 7.63635C54.2223 7.63635 62.5556 15.9613 62.5556 26.1363V31.6863C62.5556 41.8612 54.2223 50.1862 44.0371 50.1862Z" stroke="currentColor" strokeWidth="6.42146" strokeLinecap="round" strokeLinejoin="round"/></svg>
111
  );
@@ -142,28 +143,32 @@ const AppInternalLogic: React.FC<{
142
  }, [isMicActive, isCamActive, connected, disconnect]);
143
 
144
  return (
145
- <div className="w-full flex flex-col items-center justify-center min-h-screen text-foreground antialiased">
146
- {/* Wrapper اصلی که در HTML هم وجود دارد */}
 
 
147
  <div className="max-w-3xl w-full flex flex-col items-center justify-center h-full relative">
148
- {/* Header Controls */}
149
  <div className="header-controls">
150
- {/* دکمه بازگشت (در HTML سمت راست بود، اینجا هم طبق آن) */}
151
- <div className="header-button" onClick={() => alert('Back clicked (implement navigation)')}>
152
- <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="m15 18-6-6 6-6"></path></svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
  </div>
154
- {/* دکمه نوتیفیکیشن (در HTML سمت چپ بود) */}
155
- <button
156
- ref={notificationButtonRef}
157
- id="notification-button"
158
- aria-label="Notifications"
159
- className="header-button"
160
- onClick={(e) => {
161
- e.stopPropagation();
162
- setIsNotificationOpen(!isNotificationOpen);
163
- }}
164
- >
165
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="12"></line><line x1="12" y1="16" x2="12.01" y2="16"></line></svg>
166
- </button>
167
  </div>
168
 
169
  {/* Notification Popover */}
@@ -181,40 +186,32 @@ const AppInternalLogic: React.FC<{
181
  </div>
182
  </div>
183
 
184
- {/* MediaToggle Area - این div اصلی برای ویدیو و لوگوی بزرگ است */}
185
- {/* کلاس‌های HTML مرجع: "w-full flex flex-col items-center justify-center h-[90dvh] bg-background top-0 left-0 relative" */}
186
- {/* ما از bg-background روی body استفاده می‌کنیم، پس اینجا لازم نیست تکرار شود */}
187
- {/* h-[90dvh] با flex-grow جایگزین می‌شود تا ارتفاع را پر کند */}
188
- <div className="w-full flex flex-col items-center justify-center flex-grow relative">
189
  <video
190
- id="video-feed"
191
  ref={videoRef}
192
  autoPlay
193
  playsInline
194
  className={cn(
195
- "absolute top-0 left-0 w-full h-full object-cover scale-x-[-1]", // scale-x-[-1] برای آینه‌ای کردن
196
- { "hidden": !isCamActive }
197
  )}
198
  />
199
- {/* large-logo-container */}
200
  <div
201
- id="large-logo-container"
202
  className={cn(
203
- // کلاس‌های HTML: "w-full h-full absolute top-0 left-0 items-center justify-center"
204
- // اما در کد JS، این کانتینر فقط زمانی flex است که لوگو نمایش داده می‌شود
205
- "absolute top-0 left-0 w-full h-full",
206
  {
207
- "flex items-center justify-center": isMicActive && !isCamActive,
208
- "hidden": !isMicActive || isCamActive,
209
  }
210
  )}
211
  >
212
- {/* لوگوی بزرگ فقط زمانی رندر می‌شود که شرایط برقرار باشد */}
213
  {isMicActive && !isCamActive && createLogoFunction(false, true, 'human')}
214
  </div>
215
- {/* اگر Altair/SidePanel وجود دارد، باید اینجا یا در یک لایه دیگر قرار گیرد */}
216
- {/* برای سادگی، Altair را اینجا کامنت می‌کنیم چون در تصاویر شما نبود */}
217
- {/* <div className="absolute bottom-24 left-4 z-20 w-1/3 max-w-md"> <Altair /> </div> */}
218
  </div>
219
 
220
  <ControlTray
@@ -278,16 +275,17 @@ function App() {
278
 
279
  const createLogoFunction = (isMini: boolean, isActive: boolean, type: 'human' | 'ai' = 'human') => {
280
  if (!isActive) return null;
281
- const size = isMini ? 80 : 200;
282
- const iconSize = isMini ? 35 : 70; // آیکون کوچک‌تر برای لوگوی کوچک
283
  const insetBase = isMini
284
- ? { ping: 10, outer: 0, mid: 5, inner: 12, icon: 22 } // مقادیر از JS کد HTML
285
  : { ping: 40, outer: 0, mid: 20, inner: 50, icon: 65 };
286
- const bgColorBase = type === 'human' ? 'blue' : 'green';
287
 
288
- // اطمینان از وجود کلاس‌های Tailwind برای purgeCSS اگر لازم باشد (معمولاً لازم نیست اگر مستقیم استفاده شوند)
289
- // <div className="bg-blue-200 dark:bg-blue-700 bg-blue-300 dark:bg-blue-600 bg-blue-400 dark:bg-blue-500 hidden"></div>
290
- // <div className="bg-green-200 dark:bg-green-700 bg-green-300 dark:bg-green-600 bg-green-400 dark:bg-green-500 hidden"></div>
 
291
 
292
  return (
293
  <div className="relative" style={{ width: `${size}px`, height: `${size}px` }}>
@@ -296,8 +294,8 @@ function App() {
296
  <div className={`absolute rounded-full opacity-50 bg-${bgColorBase}-300 dark:bg-${bgColorBase}-600`} style={{ inset: `${insetBase.mid}px` }}></div>
297
  <div className={`absolute rounded-full opacity-50 bg-${bgColorBase}-400 dark:bg-${bgColorBase}-500`} style={{ inset: `${insetBase.inner}px` }}></div>
298
  <div className="z-10 absolute" style={{ inset: `${insetBase.icon}px`, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
299
- {/* آیکون انسان با استروک currentColor تا از var(--foreground) ارث‌بری کند */}
300
  {type === 'human' && <SvgHumanIcon />}
 
301
  </div>
302
  </div>
303
  );
 
19
  import { isIOS } from "./lib/platform";
20
  import cn from "classnames";
21
  import { LiveConfig } from "./multimodal-live-types";
22
+ // Altair و SidePanel حذف شدند چون در ظاهر جدید جایی ندارند
 
23
 
24
  const myCustomInstruction = `
25
  ت1. هویت دستیار:
 
105
  },
106
  };
107
 
108
+ // آیکون انسان از HTML شما (برای لوگوی بزرگ و کوچک)
109
+ // stroke="currentColor" باعث می‌شود رنگ خطوط از CSS (var(--foreground)) ارث‌بری کند
110
  const SvgHumanIcon = () => (
111
  <svg width="70" height="70" viewBox="0 0 88 89" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M75.1481 81.6361H12.9259C9.66667 81.6361 7 78.9721 7 75.7161V58.5112C7 57.5862 7 57.1052 7.44444 56.2172C8.85185 52.9612 13 50.2232 19.4815 47.8922C24.1111 56.6982 33.3704 62.6921 44 62.6921C54.6296 62.6921 63.9259 56.6982 68.5185 47.8922C75 50.1862 79.1852 52.9982 80.5556 56.2172C81 56.6612 81 57.6232 81 58.5112V75.7161C81 78.9721 78.3333 81.6361 75.0741 81.6361H75.1481Z" stroke="currentColor" strokeWidth="6.42146" strokeLinecap="round" strokeLinejoin="round"/><path d="M44.0371 50.1862C33.8519 50.1862 25.5186 41.8612 25.5186 31.6863V26.1363C25.5186 15.9613 33.8519 7.63635 44.0371 7.63635C54.2223 7.63635 62.5556 15.9613 62.5556 26.1363V31.6863C62.5556 41.8612 54.2223 50.1862 44.0371 50.1862Z" stroke="currentColor" strokeWidth="6.42146" strokeLinecap="round" strokeLinejoin="round"/></svg>
112
  );
 
143
  }, [isMicActive, isCamActive, connected, disconnect]);
144
 
145
  return (
146
+ // کلاس‌های اصلی از body و div والد در HTML مرجع
147
+ // min-h-[90dvh] md:min-h-screen
148
+ <div className="w-full flex flex-col items-center justify-center min-h-screen text-foreground antialiased"> {/* استفاده از min-h-screen برای پر کردن کامل ارتفاع */}
149
+ {/* Wrapper داخلی از HTML: "max-w-3xl w-full flex flex-col items-center justify-center h-full relative" */}
150
  <div className="max-w-3xl w-full flex flex-col items-center justify-center h-full relative">
151
+ {/* Header Controls - ترتیب دکمه‌ها مطابق HTML (نوتیفیکیشن چپ، بازگشت راست) */}
152
  <div className="header-controls">
153
+ <div id="notification-trigger-container"> {/* Wrapper از HTML */}
154
+ <button
155
+ ref={notificationButtonRef}
156
+ id="notification-button"
157
+ aria-label="Notifications"
158
+ className="header-button"
159
+ onClick={(e) => {
160
+ e.stopPropagation();
161
+ setIsNotificationOpen(!isNotificationOpen);
162
+ }}
163
+ >
164
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="12"></line><line x1="12" y1="16" x2="12.01" y2="16"></line></svg>
165
+ </button>
166
+ </div>
167
+ <div className="back-button-container"> {/* Wrapper از HTML */}
168
+ <div className="header-button" onClick={() => alert('Back clicked (implement navigation)')}>
169
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="m15 18-6-6 6-6"></path></svg>
170
+ </div>
171
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  </div>
173
 
174
  {/* Notification Popover */}
 
186
  </div>
187
  </div>
188
 
189
+ {/* MediaToggle Area - از HTML: "w-full flex flex-col items-center justify-center h-[90dvh] bg-background top-0 left-0 relative" */}
190
+ {/* h-[90dvh] با flex-grow جایگزین می‌شود و bg-background از body می‌آید */}
191
+ <div className="w-full flex flex-col items-center justify-center flex-grow relative"> {/* flex-grow برای پر کردن ارتفاع */}
 
 
192
  <video
193
+ id="video-feed" // id از HTML
194
  ref={videoRef}
195
  autoPlay
196
  playsInline
197
  className={cn(
198
+ "absolute top-0 left-0 w-full h-full object-cover scale-x-[-1]", // کلاس‌های HTML
199
+ { "hidden": !isCamActive } // کلاس hidden از HTML
200
  )}
201
  />
202
+ {/* large-logo-container - کلاس hidden و flex از HTML */}
203
  <div
204
+ id="large-logo-container" // id از HTML
205
  className={cn(
206
+ "absolute top-0 left-0 w-full h-full", // برای پوشاندن کل فضا
 
 
207
  {
208
+ "flex items-center justify-center": isMicActive && !isCamActive, // نمایش لوگو با flex
209
+ "hidden": !isMicActive || isCamActive, // مخفی کردن در غیر این صورت
210
  }
211
  )}
212
  >
 
213
  {isMicActive && !isCamActive && createLogoFunction(false, true, 'human')}
214
  </div>
 
 
 
215
  </div>
216
 
217
  <ControlTray
 
275
 
276
  const createLogoFunction = (isMini: boolean, isActive: boolean, type: 'human' | 'ai' = 'human') => {
277
  if (!isActive) return null;
278
+ const size = isMini ? 80 : 200; // مقادیر از JS در HTML
279
+ const iconSize = isMini ? 35 : 70;
280
  const insetBase = isMini
281
+ ? { ping: 10, outer: 0, mid: 5, inner: 12, icon: 22 }
282
  : { ping: 40, outer: 0, mid: 20, inner: 50, icon: 65 };
283
+ const bgColorBase = type === 'human' ? 'blue' : (type === 'ai' ? 'green' : 'gray'); // اضافه کردن gray برای حالت پیش‌فرض
284
 
285
+ // کلاس‌های رنگی باید توسط Tailwind شناسایی شوند
286
+ // مثال: "bg-blue-200", "dark:bg-blue-700"
287
+ // این کلاس‌ها باید در فایل App.scss شما یا در پیکربندی Tailwind تعریف شده باشند اگر از رنگ‌های سفارشی استفاده می‌کنید.
288
+ // در اینجا فرض می‌کنیم Tailwind می‌تواند bg-blue-200 و غیره را به درستی پردازش کند.
289
 
290
  return (
291
  <div className="relative" style={{ width: `${size}px`, height: `${size}px` }}>
 
294
  <div className={`absolute rounded-full opacity-50 bg-${bgColorBase}-300 dark:bg-${bgColorBase}-600`} style={{ inset: `${insetBase.mid}px` }}></div>
295
  <div className={`absolute rounded-full opacity-50 bg-${bgColorBase}-400 dark:bg-${bgColorBase}-500`} style={{ inset: `${insetBase.inner}px` }}></div>
296
  <div className="z-10 absolute" style={{ inset: `${insetBase.icon}px`, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
 
297
  {type === 'human' && <SvgHumanIcon />}
298
+ {/* اگر آیکون AI دارید، اینجا اضافه کنید */}
299
  </div>
300
  </div>
301
  );