File size: 5,466 Bytes
415a17d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
08f60f4
 
415a17d
d9c705e
 
08f60f4
 
415a17d
 
 
08f60f4
 
415a17d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<script lang="ts">
  import type { MonsterWorkflowStep } from '$lib/types';
  
  interface Props {
    currentStep: MonsterWorkflowStep;
    error?: string | null;
  }
  
  let { currentStep, error = null }: Props = $props();
  
  interface StepInfo {
    id: MonsterWorkflowStep;
    label: string;
    description: string;
  }
  
  const steps: StepInfo[] = [
    {
      id: 'upload',
      label: 'Upload Photo',
      description: 'Select your image'
    },
    {
      id: 'captioning',
      label: 'Monster Design',
      description: 'Creating concept & lore'
    },
    {
      id: 'statsGenerating',
      label: 'Battle Stats',
      description: 'Generating abilities'
    },
    {
      id: 'generating',
      label: 'Image Generation',
      description: 'Creating monster art'
    },
    {
      id: 'complete',
      label: 'Complete',
      description: 'Your monster is ready!'
    }
  ];
  
  function getStepIndex(step: MonsterWorkflowStep): number {
    return steps.findIndex(s => s.id === step);
  }
  
  function getStepStatus(step: StepInfo): 'completed' | 'current' | 'pending' | 'error' {
    const currentIndex = getStepIndex(currentStep);
    const stepIndex = getStepIndex(step.id);
    
    if (error && step.id === currentStep) return 'error';
    if (stepIndex < currentIndex) return 'completed';
    if (stepIndex === currentIndex) return 'current';
    return 'pending';
  }
</script>

<div class="workflow-progress">
  <div class="steps-container">
    {#each steps as step, i}
      {@const status = getStepStatus(step)}
      <div class="step" class:completed={status === 'completed'} class:current={status === 'current'} class:error={status === 'error'}>
        <div class="step-indicator">
          {#if status === 'completed'}
            <svg width="20" height="20" viewBox="0 0 20 20" fill="currentColor">
              <path d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 111.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"/>
            </svg>
          {:else if status === 'error'}
            <svg width="20" height="20" viewBox="0 0 20 20" fill="currentColor">
              <path d="M10 2a8 8 0 100 16 8 8 0 000-16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z"/>
            </svg>
          {:else}
            <span class="step-number">{i + 1}</span>
          {/if}
        </div>
        <div class="step-content">
          <div class="step-label">{step.label}</div>
          <div class="step-description">{step.description}</div>
        </div>
        {#if i < steps.length - 1}
          <div class="step-connector" class:active={status === 'completed'}></div>
        {/if}
      </div>
    {/each}
  </div>
  
  {#if error}
    <div class="error-message">
      <svg width="20" height="20" viewBox="0 0 20 20" fill="currentColor">
        <path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z"/>
      </svg>
      <span>{error}</span>
    </div>
  {/if}
</div>

<style>
  .workflow-progress {
    max-width: 800px;
    margin: 2rem auto;
  }
  
  .steps-container {
    display: flex;
    justify-content: space-between;
    position: relative;
    padding: 0 20px;
  }
  
  .step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    flex: 1;
  }
  
  .step-indicator {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e9ecef;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
    z-index: 2;
  }
  
  .step.completed .step-indicator {
    background: #28a745;
    color: white;
  }
  
  .step.current .step-indicator {
    background: #007bff;
    color: white;
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.2);
    animation: pulse 2s infinite;
  }
  
  .step.error .step-indicator {
    background: #dc3545;
    color: white;
  }
  
  .step-number {
    font-size: 0.9rem;
  }
  
  .step-content {
    text-align: center;
  }
  
  .step-label {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
  }
  
  .step-description {
    font-size: 0.8rem;
    color: #666;
  }
  
  .step-connector {
    position: absolute;
    top: 20px;
    left: 50%;
    width: 100%;
    height: 2px;
    background: #e9ecef;
    z-index: 1;
  }
  
  .step-connector.active {
    background: #28a745;
  }
  
  .error-message {
    margin-top: 2rem;
    padding: 1rem;
    background: #f8d7da;
    color: #721c24;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
  
  @keyframes pulse {
    0% {
      box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.4);
    }
    70% {
      box-shadow: 0 0 0 10px rgba(0, 123, 255, 0);
    }
    100% {
      box-shadow: 0 0 0 0 rgba(0, 123, 255, 0);
    }
  }
  
  @media (max-width: 768px) {
    .steps-container {
      flex-direction: column;
      padding: 0;
    }
    
    .step {
      flex-direction: row;
      margin-bottom: 1rem;
    }
    
    .step-indicator {
      margin-right: 1rem;
      margin-bottom: 0;
    }
    
    .step-content {
      text-align: left;
      flex: 1;
    }
    
    .step-connector {
      display: none;
    }
  }
</style>