New exercise name autofill. Log Set button animation.
This commit is contained in:
@@ -299,6 +299,7 @@ const ActiveSessionView: React.FC<ActiveSessionViewProps> = ({ tracker, activeSe
|
||||
onSave={handleCreateExercise}
|
||||
lang={lang}
|
||||
existingExercises={exercises}
|
||||
initialName={tracker.searchQuery}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { useTracker } from './useTracker';
|
||||
interface SetLoggerProps {
|
||||
tracker: ReturnType<typeof useTracker>;
|
||||
lang: Language;
|
||||
onLogSet: () => void;
|
||||
onLogSet: () => Promise<void> | void;
|
||||
isSporadic?: boolean;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,31 @@ const SetLogger: React.FC<SetLoggerProps> = ({ tracker, lang, onLogSet, isSporad
|
||||
setUnilateralSide
|
||||
} = tracker;
|
||||
|
||||
const [localSuccess, setLocalSuccess] = React.useState(false);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (localSuccess) {
|
||||
const timer = setTimeout(() => {
|
||||
setLocalSuccess(false);
|
||||
}, 750);
|
||||
return () => clearTimeout(timer);
|
||||
}
|
||||
}, [localSuccess]);
|
||||
|
||||
const handleLogClick = async () => {
|
||||
try {
|
||||
const result = onLogSet();
|
||||
if (result instanceof Promise) {
|
||||
await result;
|
||||
}
|
||||
setLocalSuccess(true);
|
||||
} catch (error) {
|
||||
console.error("Failed to log set:", error);
|
||||
}
|
||||
};
|
||||
|
||||
const isPlanFinished = activePlan && currentStepIndex >= activePlan.steps.length;
|
||||
const showSuccess = (isSporadic && sporadicSuccess) || localSuccess;
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
@@ -174,14 +198,14 @@ const SetLogger: React.FC<SetLoggerProps> = ({ tracker, lang, onLogSet, isSporad
|
||||
</div>
|
||||
|
||||
<button
|
||||
onClick={onLogSet}
|
||||
className={`w-full h-14 font-medium text-lg rounded-full shadow-elevation-2 hover:shadow-elevation-3 active:scale-[0.98] transition-all flex items-center justify-center gap-2 ${isSporadic && sporadicSuccess
|
||||
onClick={handleLogClick}
|
||||
className={`w-full h-14 font-medium text-lg rounded-full shadow-elevation-2 hover:shadow-elevation-3 active:scale-[0.98] transition-all flex items-center justify-center gap-2 ${showSuccess
|
||||
? 'bg-green-500 text-white'
|
||||
: 'bg-primary-container text-on-primary-container'
|
||||
}`}
|
||||
>
|
||||
{isSporadic && sporadicSuccess ? <CheckCircle size={24} /> : <Plus size={24} />}
|
||||
<span>{isSporadic && sporadicSuccess ? t('saved', lang) : t('log_set', lang)}</span>
|
||||
{showSuccess ? <CheckCircle size={24} className="animate-in zoom-in spin-in-90 duration-300" /> : <Plus size={24} />}
|
||||
<span>{showSuccess ? t('saved', lang) : t('log_set', lang)}</span>
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -153,6 +153,7 @@ const SporadicView: React.FC<SporadicViewProps> = ({ tracker, lang }) => {
|
||||
onSave={handleCreateExercise}
|
||||
lang={lang}
|
||||
existingExercises={exercises}
|
||||
initialName={tracker.searchQuery}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user