linguabot commited on
Commit
71f7e93
·
verified ·
1 Parent(s): e1f82f5

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. client/src/components/Refinity.tsx +9 -6
client/src/components/Refinity.tsx CHANGED
@@ -1,4 +1,5 @@
1
  import React from 'react';
 
2
  import { motion, AnimatePresence } from 'framer-motion';
3
  import { Swiper as SwiperRoot, SwiperSlide } from 'swiper/react';
4
  import type { Swiper as SwiperInstance } from 'swiper';
@@ -766,6 +767,8 @@ const EditorPane: React.FC<{ source: string; initialTranslation: string; onBack:
766
  const [diffHtml, setDiffHtml] = React.useState<string>('');
767
  const [showDiff, setShowDiff] = React.useState<boolean>(false);
768
  const [revDownloadOpen, setRevDownloadOpen] = React.useState<boolean>(false);
 
 
769
  const sourceRef = React.useRef<HTMLDivElement>(null);
770
  const [textareaHeight, setTextareaHeight] = React.useState('420px');
771
 
@@ -825,8 +828,8 @@ const EditorPane: React.FC<{ source: string; initialTranslation: string; onBack:
825
  <div className="w-1/2">
826
  <div className="mb-2 text-gray-700 text-sm">Source</div>
827
  <div className="relative rounded-lg overflow-hidden">
828
- <div className="absolute inset-0 rounded-lg" style={{ background: 'radial-gradient(120%_120%_at_0%_0%, #e0e7ff 0%, #ffffff 55%, #eef2ff 100%)' }} />
829
- <div ref={sourceRef} className="relative rounded-lg bg-white/70 backdrop-blur-md ring-1 ring-inset ring-indigo-200 shadow p-4 min-h-[420px] whitespace-pre-wrap text-gray-900">
830
  {source}
831
  </div>
832
  </div>
@@ -846,12 +849,12 @@ const EditorPane: React.FC<{ source: string; initialTranslation: string; onBack:
846
  <div className="mt-4 flex gap-3 relative">
847
  <button onClick={save} disabled={saving} className="relative overflow-hidden inline-flex items-center justify-center gap-2 px-4 py-2 text-sm font-medium rounded-2xl text-white ring-1 ring-inset ring-white/50 backdrop-blur-md backdrop-brightness-110 backdrop-saturate-150 bg-indigo-600/70 disabled:bg-gray-400 active:translate-y-0.5 transition-all duration-200">{saving? 'Saving…':'Save'}</button>
848
  <div className="relative inline-block align-top">
849
- <button onClick={(e)=>{ e.preventDefault(); e.stopPropagation(); setRevDownloadOpen(v=>!v); }} className="relative overflow-hidden inline-flex items-center justify-center gap-2 px-4 py-2 text-sm font-medium rounded-2xl text-black ring-1 ring-inset ring-white/50 backdrop-blur-md bg-white/30 active:translate-y-0.5 transition-all duration-200">Download ▾</button>
850
- {revDownloadOpen && (
851
- <div className="absolute right-0 translate-y-2 w-44 rounded-md border border-gray-200 bg-white shadow-lg z-50 text-left">
852
  <button onClick={(e)=>{ e.preventDefault(); setRevDownloadOpen(false); downloadWithTrackChanges(); }} className="block w-full text-left px-3 py-2 text-sm hover:bg-gray-50">Track Changes</button>
853
  <button onClick={(e)=>{ e.preventDefault(); setRevDownloadOpen(false); compareNow(); }} className="block w-full text-left px-3 py-2 text-sm hover:bg-gray-50">Inline Diff (Preview)</button>
854
- </div>
855
  )}
856
  </div>
857
  <button onClick={onBack} className="ml-auto relative overflow-hidden inline-flex items-center justify-center gap-2 px-4 py-2 text-sm font-medium rounded-2xl text-black ring-1 ring-inset ring-white/50 backdrop-blur-md bg-white/30 active:translate-y-0.5 transition-all duration-200">Back</button>
 
1
  import React from 'react';
2
+ import { createPortal } from 'react-dom';
3
  import { motion, AnimatePresence } from 'framer-motion';
4
  import { Swiper as SwiperRoot, SwiperSlide } from 'swiper/react';
5
  import type { Swiper as SwiperInstance } from 'swiper';
 
767
  const [diffHtml, setDiffHtml] = React.useState<string>('');
768
  const [showDiff, setShowDiff] = React.useState<boolean>(false);
769
  const [revDownloadOpen, setRevDownloadOpen] = React.useState<boolean>(false);
770
+ const [revMenuPos, setRevMenuPos] = React.useState<{ left: number; top: number } | null>(null);
771
+ const revBtnRef = React.useRef<HTMLButtonElement | null>(null);
772
  const sourceRef = React.useRef<HTMLDivElement>(null);
773
  const [textareaHeight, setTextareaHeight] = React.useState('420px');
774
 
 
828
  <div className="w-1/2">
829
  <div className="mb-2 text-gray-700 text-sm">Source</div>
830
  <div className="relative rounded-lg overflow-hidden">
831
+ <div className="absolute inset-0 rounded-lg" style={{ background: 'radial-gradient(120%_120%_at_0%_0%, #dbeafe 0%, #ffffff 50%, #c7d2fe 100%)' }} />
832
+ <div ref={sourceRef} className="relative rounded-lg bg-white/60 backdrop-blur-md ring-1 ring-inset ring-indigo-300 shadow p-4 min-h-[420px] whitespace-pre-wrap text-gray-900">
833
  {source}
834
  </div>
835
  </div>
 
849
  <div className="mt-4 flex gap-3 relative">
850
  <button onClick={save} disabled={saving} className="relative overflow-hidden inline-flex items-center justify-center gap-2 px-4 py-2 text-sm font-medium rounded-2xl text-white ring-1 ring-inset ring-white/50 backdrop-blur-md backdrop-brightness-110 backdrop-saturate-150 bg-indigo-600/70 disabled:bg-gray-400 active:translate-y-0.5 transition-all duration-200">{saving? 'Saving…':'Save'}</button>
851
  <div className="relative inline-block align-top">
852
+ <button ref={revBtnRef} onClick={(e)=>{ e.preventDefault(); e.stopPropagation(); const r=(e.currentTarget as HTMLElement).getBoundingClientRect(); setRevMenuPos({ left: r.left, top: r.bottom + 8 }); setRevDownloadOpen(v=>!v); }} className="relative overflow-hidden inline-flex items-center justify-center gap-2 px-4 py-2 text-sm font-medium rounded-2xl text-black ring-1 ring-inset ring-white/50 backdrop-blur-md bg-white/30 active:translate-y-0.5 transition-all duration-200">Download ▾</button>
853
+ {revDownloadOpen && revMenuPos && createPortal(
854
+ <div onClick={(e)=>e.stopPropagation()} style={{ position: 'fixed', left: revMenuPos.left, top: revMenuPos.top, zIndex: 10000 }} className="w-44 rounded-md border border-gray-200 bg-white shadow-lg text-left">
855
  <button onClick={(e)=>{ e.preventDefault(); setRevDownloadOpen(false); downloadWithTrackChanges(); }} className="block w-full text-left px-3 py-2 text-sm hover:bg-gray-50">Track Changes</button>
856
  <button onClick={(e)=>{ e.preventDefault(); setRevDownloadOpen(false); compareNow(); }} className="block w-full text-left px-3 py-2 text-sm hover:bg-gray-50">Inline Diff (Preview)</button>
857
+ </div>, document.body
858
  )}
859
  </div>
860
  <button onClick={onBack} className="ml-auto relative overflow-hidden inline-flex items-center justify-center gap-2 px-4 py-2 text-sm font-medium rounded-2xl text-black ring-1 ring-inset ring-white/50 backdrop-blur-md bg-white/30 active:translate-y-0.5 transition-all duration-200">Back</button>