Tristan Yu commited on
Commit
09e9c7d
·
1 Parent(s): b424529

Add dynamic transition duration and spinner loading for WeeklyPractice week switches

Browse files
client/src/components/Layout.tsx CHANGED
@@ -53,6 +53,18 @@ const Layout: React.FC<{ children: React.ReactNode }> = ({ children }) => {
53
  transitionDuration = 1200; // Longer for content-heavy pages
54
  }
55
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  // End transition after content is loaded (wait for DOM updates)
57
  const timer = setTimeout(() => {
58
  setIsTransitioning(false);
 
53
  transitionDuration = 1200; // Longer for content-heavy pages
54
  }
55
 
56
+ // Special case: Weekly Practice → Tutorial Tasks Week 2 (longer duration)
57
+ if (location.pathname === '/tutorial-tasks' &&
58
+ previousPath &&
59
+ previousPath.includes('/weekly-practice')) {
60
+ // Check if navigating to Week 2
61
+ const urlParams = new URLSearchParams(window.location.search);
62
+ const week = urlParams.get('week');
63
+ if (week === '2') {
64
+ transitionDuration = 1500; // Extended duration for Week 2
65
+ }
66
+ }
67
+
68
  // End transition after content is loaded (wait for DOM updates)
69
  const timer = setTimeout(() => {
70
  setIsTransitioning(false);
client/src/pages/WeeklyPractice.tsx CHANGED
@@ -1149,8 +1149,16 @@ const WeeklyPractice: React.FC = () => {
1149
  </div>
1150
  </div>
1151
 
 
 
 
 
 
 
 
 
1152
  {/* Translation Brief - Shown once at the top */}
1153
- {weeklyPracticeWeek && weeklyPracticeWeek.translationBrief ? (
1154
  <div className="bg-gradient-to-r from-blue-50 to-indigo-50 rounded-xl p-8 mb-8 border border-blue-200">
1155
  <div className="flex items-center justify-between mb-4">
1156
  <div className="flex items-center space-x-2">
@@ -1671,18 +1679,20 @@ const WeeklyPractice: React.FC = () => {
1671
  </div>
1672
  )}
1673
 
1674
- {weeklyPractice.length === 0 && !addingPractice ? (
1675
- <div className="text-center py-12">
1676
- <DocumentTextIcon className="h-12 w-12 text-gray-400 mx-auto mb-4" />
1677
- <h3 className="text-lg font-medium text-gray-900 mb-2">
1678
- No practice examples available
1679
- </h3>
1680
- <p className="text-gray-600">
1681
- Practice examples for Week {selectedWeek} haven't been set up yet.
1682
- </p>
1683
- </div>
1684
- ) : (
1685
- weeklyPractice.map((practice) => (
 
 
1686
  <div key={practice._id} className="bg-white rounded-xl shadow-lg border border-gray-100 p-8 hover:shadow-xl transition-shadow duration-300">
1687
  <div className="mb-6">
1688
  <div className="flex items-center justify-between mb-4">
@@ -2003,6 +2013,8 @@ const WeeklyPractice: React.FC = () => {
2003
  </div>
2004
  ))
2005
  )}
 
 
2006
  </div>
2007
  )}
2008
  </div>
 
1149
  </div>
1150
  </div>
1151
 
1152
+ {/* Week Transition Loading Spinner */}
1153
+ {isWeekTransitioning && (
1154
+ <div className="flex items-center justify-center py-12">
1155
+ <div className="animate-spin rounded-full h-8 w-8 border-b-2 border-indigo-600"></div>
1156
+ <span className="ml-3 text-gray-600">Loading week {selectedWeek}...</span>
1157
+ </div>
1158
+ )}
1159
+
1160
  {/* Translation Brief - Shown once at the top */}
1161
+ {!isWeekTransitioning && weeklyPracticeWeek && weeklyPracticeWeek.translationBrief ? (
1162
  <div className="bg-gradient-to-r from-blue-50 to-indigo-50 rounded-xl p-8 mb-8 border border-blue-200">
1163
  <div className="flex items-center justify-between mb-4">
1164
  <div className="flex items-center space-x-2">
 
1679
  </div>
1680
  )}
1681
 
1682
+ {!isWeekTransitioning && (
1683
+ <>
1684
+ {weeklyPractice.length === 0 && !addingPractice ? (
1685
+ <div className="text-center py-12">
1686
+ <DocumentTextIcon className="h-12 w-12 text-gray-400 mx-auto mb-4" />
1687
+ <h3 className="text-lg font-medium text-gray-900 mb-2">
1688
+ No practice examples available
1689
+ </h3>
1690
+ <p className="text-gray-600">
1691
+ Practice examples for Week {selectedWeek} haven't been set up yet.
1692
+ </p>
1693
+ </div>
1694
+ ) : (
1695
+ weeklyPractice.map((practice) => (
1696
  <div key={practice._id} className="bg-white rounded-xl shadow-lg border border-gray-100 p-8 hover:shadow-xl transition-shadow duration-300">
1697
  <div className="mb-6">
1698
  <div className="flex items-center justify-between mb-4">
 
2013
  </div>
2014
  ))
2015
  )}
2016
+ </>
2017
+ )}
2018
  </div>
2019
  )}
2020
  </div>