Spaces:
Running
on
A100
Running
on
A100
File size: 5,203 Bytes
ae238b3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
import React from "react";
import {useTranscriptionStore} from "../stores/transcriptionStore";
interface QuickGuideProps {
currentStep?: string; // Optional override for current step
}
type GuideStep = {
id: string;
text: string;
icon?: string;
isActive: (state: any) => boolean;
isCompleted: (state: any) => boolean;
};
const QuickGuide: React.FC<QuickGuideProps> = ({currentStep}) => {
const {
file,
transcription,
isLoading,
selectedSegmentIndex,
currentSegments,
currentTime
} = useTranscriptionStore();
// Define all the steps with their conditions
const steps: GuideStep[] = [
{
id: "upload",
text: "Upload or record audio",
icon: "π",
isActive: (state) => !state.file,
isCompleted: (state) => !!state.file,
},
{
id: "transcribe",
text: "Click transcribe to process",
icon: "π―",
isActive: (state) =>
!!state.file && !state.transcription && !state.isLoading,
isCompleted: (state) => !!state.transcription || state.isLoading,
},
{
id: "play",
text: "Play media",
icon: "βΆοΈ",
isActive: (state) => !!state.transcription,
isCompleted: () => (currentTime ?? 0) > 0, // Always in progress when transcription available
},
// {
// id: "jump",
// text: "Click segments to jump",
// icon: "π΅",
// isActive: (state) => !!state.transcription,
// isCompleted: () => false, // Always in progress when transcription available
// },
// {
// id: "drag",
// text: "Drag segments to move/resize",
// icon: "βοΈ",
// isActive: (state) => !!state.transcription,
// isCompleted: () => false, // Always in progress when transcription available
// },
// {
// id: "combine",
// text: "Use slider to combine segments",
// icon: "π",
// isActive: (state) => !!state.transcription,
// isCompleted: () => false, // Always in progress when transcription available
// },
// {
// id: "download",
// text: "Download subtitles",
// icon: "πΎ",
// isActive: (state) => !!state.transcription,
// isCompleted: () => false, // Always in progress when transcription available
// },
];
// Create state object for condition checking
const storeState = {
file,
transcription,
isLoading,
selectedSegmentIndex,
currentSegments,
};
// Determine step states
const getStepState = (step: GuideStep) => {
// Override with currentStep prop if provided
if (currentStep) {
if (step.id === currentStep) return "active";
if (step.isCompleted(storeState)) return "completed";
return "inactive";
}
// Default logic based on store state
if (step.isCompleted(storeState)) return "completed";
if (step.isActive(storeState)) return "active";
return "inactive";
};
// Get the appropriate CSS classes for each step state
const getStepClasses = (stepState: string) => {
switch (stepState) {
case "active":
return "text-blue-300 bg-blue-900/30 border-blue-500/50 font-medium";
case "completed":
return "text-green-300 bg-green-900/20 border-green-500/30";
default:
return "text-gray-400 bg-transparent border-transparent";
}
};
// Get icon for step state
const getStepIcon = (step: GuideStep, stepState: string) => {
if (stepState === "completed") return "β";
if (stepState === "active") return "β";
return step.icon || "β’";
};
return (
<div className="border-t border-gray-700 py-3">
<h3 className="text-xs font-semibold mb-2 text-gray-200">Quick Guide</h3>
<div className="space-y-1">
{steps.map((step) => {
const stepState = getStepState(step);
const stepClasses = getStepClasses(stepState);
const icon = getStepIcon(step, stepState);
return (
<div
key={step.id}
className={`text-xs px-2 py-1 rounded border transition-all duration-200 ${stepClasses}`}
>
<span
className="inline-block w-4 text-center mr-1"
aria-label={`Step ${step.id}`}
>
{icon}
</span>
{step.text}
</div>
);
})}
</div>
{/* Progress indicator */}
{transcription && (
<div className="mt-2 pt-2 border-t border-gray-600">
<div className="text-xs text-gray-400">
{selectedSegmentIndex !== null ? (
<span className="text-yellow-400">βοΈ Editing mode active</span>
) : (
<span className="text-green-400">
β Ready for playback & editing
</span>
)}
</div>
</div>
)}
{/* Loading indicator */}
{isLoading && (
<div className="mt-2 pt-2 border-t border-gray-600">
<div className="text-xs text-blue-400 animate-pulse">
β³ Processing... Please wait
</div>
</div>
)}
</div>
);
};
export default QuickGuide;
|