Upload folder using huggingface_hub
Browse files
client/src/pages/TutorialTasks.tsx
CHANGED
|
@@ -71,6 +71,8 @@ const TutorialTasks: React.FC = () => {
|
|
| 71 |
const [expandedSections, setExpandedSections] = useState<{[key: string]: boolean}>({});
|
| 72 |
const [lockedCardHeights, setLockedCardHeights] = useState<{[key: string]: number}>({});
|
| 73 |
const cardRefs = useRef<{[key: string]: HTMLDivElement | null}>({});
|
|
|
|
|
|
|
| 74 |
|
| 75 |
// Move a task up or down by normalizing positions for the current visible list (weeks 4–6 only)
|
| 76 |
const moveTask = async (taskId: string, direction: 'up' | 'down') => {
|
|
@@ -1131,6 +1133,16 @@ const TutorialTasks: React.FC = () => {
|
|
| 1131 |
});
|
| 1132 |
};
|
| 1133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1134 |
return (
|
| 1135 |
<div className="min-h-screen bg-white py-8">
|
| 1136 |
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
|
@@ -1653,6 +1665,7 @@ const TutorialTasks: React.FC = () => {
|
|
| 1653 |
</div>
|
| 1654 |
)}
|
| 1655 |
|
|
|
|
| 1656 |
{tutorialTasks.length === 0 && !addingTask ? (
|
| 1657 |
<div className="text-center py-12">
|
| 1658 |
<DocumentTextIcon className="h-12 w-12 text-gray-400 mx-auto mb-4" />
|
|
@@ -1882,9 +1895,9 @@ const TutorialTasks: React.FC = () => {
|
|
| 1882 |
<label className="block text-xs font-medium text-gray-700 mb-1">Select Your Group</label>
|
| 1883 |
<select
|
| 1884 |
value={selectedGroups[task._id] || ''}
|
| 1885 |
-
onFocus={() => lockCardHeight(task._id)}
|
| 1886 |
-
onChange={(e) => { lockCardHeight(task._id); setSelectedGroups({ ...selectedGroups, [task._id]: parseInt(e.target.value) }); }}
|
| 1887 |
-
onBlur={() => unlockCardHeight(task._id)}
|
| 1888 |
className="w-40 px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 bg-white text-xs"
|
| 1889 |
>
|
| 1890 |
<option value="">Choose...</option>
|
|
@@ -1899,17 +1912,17 @@ const TutorialTasks: React.FC = () => {
|
|
| 1899 |
<textarea
|
| 1900 |
id={`tutorial-translation-${task._id}`}
|
| 1901 |
value={translationText[task._id] || ''}
|
| 1902 |
-
onFocus={() => lockCardHeight(task._id)}
|
| 1903 |
-
onInput={() => lockCardHeight(task._id)}
|
| 1904 |
onChange={(e) => setTranslationText({ ...translationText, [task._id]: e.target.value })}
|
| 1905 |
-
onBlur={() => unlockCardHeight(task._id)}
|
| 1906 |
className="w-full px-4 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 bg-white"
|
| 1907 |
style={{ height: sourceHeights[task._id] ? `${sourceHeights[task._id]}px` : 'auto' }}
|
| 1908 |
rows={4}
|
| 1909 |
placeholder="Enter your group's translation here..."
|
| 1910 |
/>
|
| 1911 |
<div className="flex justify-end mt-2">
|
| 1912 |
-
<button onClick={() => { lockCardHeight(task._id); handleSubmitTranslation(task._id).finally(() => setTimeout(() => unlockCardHeight(task._id), 300)); }} disabled={submitting[task._id]} className="btn-primary disabled:bg-gray-400 text-white px-4 py-2 rounded-lg text-sm">{submitting[task._id] ? 'Submitting...' : 'Submit Translation'}</button>
|
| 1913 |
</div>
|
| 1914 |
</div>
|
| 1915 |
)}
|
|
@@ -2156,6 +2169,7 @@ const TutorialTasks: React.FC = () => {
|
|
| 2156 |
</div>
|
| 2157 |
))
|
| 2158 |
)}
|
|
|
|
| 2159 |
</div>
|
| 2160 |
</>
|
| 2161 |
)}
|
|
|
|
| 71 |
const [expandedSections, setExpandedSections] = useState<{[key: string]: boolean}>({});
|
| 72 |
const [lockedCardHeights, setLockedCardHeights] = useState<{[key: string]: number}>({});
|
| 73 |
const cardRefs = useRef<{[key: string]: HTMLDivElement | null}>({});
|
| 74 |
+
const [listLockedHeight, setListLockedHeight] = useState<number | null>(null);
|
| 75 |
+
const listRef = useRef<HTMLDivElement | null>(null);
|
| 76 |
|
| 77 |
// Move a task up or down by normalizing positions for the current visible list (weeks 4–6 only)
|
| 78 |
const moveTask = async (taskId: string, direction: 'up' | 'down') => {
|
|
|
|
| 1133 |
});
|
| 1134 |
};
|
| 1135 |
|
| 1136 |
+
const lockListHeight = () => {
|
| 1137 |
+
try {
|
| 1138 |
+
const el = listRef.current;
|
| 1139 |
+
if (!el) return;
|
| 1140 |
+
const h = el.getBoundingClientRect().height;
|
| 1141 |
+
if (h && h > 0) setListLockedHeight(Math.ceil(h));
|
| 1142 |
+
} catch {}
|
| 1143 |
+
};
|
| 1144 |
+
const unlockListHeight = () => setListLockedHeight(null);
|
| 1145 |
+
|
| 1146 |
return (
|
| 1147 |
<div className="min-h-screen bg-white py-8">
|
| 1148 |
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
|
|
|
| 1665 |
</div>
|
| 1666 |
)}
|
| 1667 |
|
| 1668 |
+
<div ref={listRef} style={listLockedHeight ? { height: listLockedHeight } : undefined}>
|
| 1669 |
{tutorialTasks.length === 0 && !addingTask ? (
|
| 1670 |
<div className="text-center py-12">
|
| 1671 |
<DocumentTextIcon className="h-12 w-12 text-gray-400 mx-auto mb-4" />
|
|
|
|
| 1895 |
<label className="block text-xs font-medium text-gray-700 mb-1">Select Your Group</label>
|
| 1896 |
<select
|
| 1897 |
value={selectedGroups[task._id] || ''}
|
| 1898 |
+
onFocus={() => { lockListHeight(); lockCardHeight(task._id); }}
|
| 1899 |
+
onChange={(e) => { lockListHeight(); lockCardHeight(task._id); setSelectedGroups({ ...selectedGroups, [task._id]: parseInt(e.target.value) }); }}
|
| 1900 |
+
onBlur={() => { unlockCardHeight(task._id); unlockListHeight(); }}
|
| 1901 |
className="w-40 px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 bg-white text-xs"
|
| 1902 |
>
|
| 1903 |
<option value="">Choose...</option>
|
|
|
|
| 1912 |
<textarea
|
| 1913 |
id={`tutorial-translation-${task._id}`}
|
| 1914 |
value={translationText[task._id] || ''}
|
| 1915 |
+
onFocus={() => { lockListHeight(); lockCardHeight(task._id); }}
|
| 1916 |
+
onInput={() => { lockListHeight(); lockCardHeight(task._id); }}
|
| 1917 |
onChange={(e) => setTranslationText({ ...translationText, [task._id]: e.target.value })}
|
| 1918 |
+
onBlur={() => { unlockCardHeight(task._id); unlockListHeight(); }}
|
| 1919 |
className="w-full px-4 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 bg-white"
|
| 1920 |
style={{ height: sourceHeights[task._id] ? `${sourceHeights[task._id]}px` : 'auto' }}
|
| 1921 |
rows={4}
|
| 1922 |
placeholder="Enter your group's translation here..."
|
| 1923 |
/>
|
| 1924 |
<div className="flex justify-end mt-2">
|
| 1925 |
+
<button onClick={() => { lockListHeight(); lockCardHeight(task._id); handleSubmitTranslation(task._id).finally(() => setTimeout(() => { unlockCardHeight(task._id); unlockListHeight(); }, 300)); }} disabled={submitting[task._id]} className="btn-primary disabled:bg-gray-400 text-white px-4 py-2 rounded-lg text-sm">{submitting[task._id] ? 'Submitting...' : 'Submit Translation'}</button>
|
| 1926 |
</div>
|
| 1927 |
</div>
|
| 1928 |
)}
|
|
|
|
| 2169 |
</div>
|
| 2170 |
))
|
| 2171 |
)}
|
| 2172 |
+
</div>
|
| 2173 |
</div>
|
| 2174 |
</>
|
| 2175 |
)}
|