Skip to content

Commit b375f5b

Browse files
committed
feat: Enhance wizard navigation with error handling and button state management
1 parent d500c54 commit b375f5b

3 files changed

Lines changed: 93 additions & 7 deletions

File tree

site/css/phase3.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,11 +409,17 @@
409409
cursor: pointer;
410410
transition: all 0.3s ease;
411411
position: relative;
412+
user-select: none;
413+
}
414+
415+
.wizard-option * {
416+
pointer-events: none; /* Ensure clicks bubble up to the option */
412417
}
413418

414419
.wizard-option:hover {
415420
border-color: var(--color-primary);
416421
background: rgba(0, 255, 136, 0.05);
422+
transform: translateY(-2px);
417423
}
418424

419425
.wizard-option.selected {

site/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@
118118
<nav class="navbar">
119119
<div class="container navbar-content">
120120
<div class="navbar-brand">
121-
<i class="fas fa-project-diagram"></i>
122121
STRUCT
123122
</div>
124123
<ul class="navbar-nav">
@@ -145,7 +144,7 @@
145144
<!-- Hero Section -->
146145
<section class="hero">
147146
<div class="container hero-content">
148-
<h1 class="hero-title">🚀 STRUCT</h1>
147+
<h1 class="hero-title">STRUCT</h1>
149148
<p class="hero-subtitle">
150149
Powerful, flexible tool for automating project structure creation through YAML configurations.
151150
Generate consistent project layouts, boilerplate code, and configurations with template variables.

site/js/phase3.js

Lines changed: 86 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ variables:
367367
<button class="wizard-btn wizard-btn-secondary" onclick="structPhase3.previousWizardStep()" ${index === 0 ? 'disabled' : ''}>
368368
Previous
369369
</button>
370-
<button class="wizard-btn" onclick="structPhase3.nextWizardStep()" ${index === wizardSteps.length - 1 ? 'style="display:none"' : ''}>
370+
<button class="wizard-btn" onclick="structPhase3.nextWizardStep()" ${index === wizardSteps.length - 1 ? 'style="display:none"' : ''} ${!step.isResult ? 'disabled style="opacity: 0.5"' : ''}>
371371
Next
372372
</button>
373373
${index === wizardSteps.length - 1 ? `
@@ -403,23 +403,57 @@ variables:
403403

404404
setupWizardNavigation() {
405405
document.addEventListener('click', (e) => {
406-
if (e.target.matches('.wizard-option')) {
407-
const panel = e.target.closest('.wizard-panel');
406+
// Check if the clicked element is a wizard option or its child
407+
const wizardOption = e.target.closest('.wizard-option');
408+
if (wizardOption) {
409+
const panel = wizardOption.closest('.wizard-panel');
410+
if (!panel || !panel.classList.contains('active')) {
411+
return; // Only handle clicks in the active panel
412+
}
413+
414+
// Remove selection from all options in this panel
408415
panel.querySelectorAll('.wizard-option').forEach(opt => opt.classList.remove('selected'));
409-
e.target.classList.add('selected');
416+
wizardOption.classList.add('selected');
410417

411418
const step = parseInt(panel.dataset.panel);
412-
const value = e.target.dataset.value;
419+
const value = wizardOption.dataset.value;
413420
this.wizardData[step] = value;
421+
422+
console.log(`Wizard step ${step} selected: ${value}`); // Debug log
423+
424+
// Remove any existing error when selection is made
425+
const existingError = panel.querySelector('.wizard-error');
426+
if (existingError) {
427+
existingError.remove();
428+
}
429+
430+
// Enable the Next button
431+
const nextBtn = panel.querySelector('.wizard-btn:not(.wizard-btn-secondary)');
432+
if (nextBtn && !nextBtn.textContent.includes('Download')) {
433+
nextBtn.disabled = false;
434+
nextBtn.style.opacity = '1';
435+
}
414436
}
415437
});
416438
}
417439

418440
nextWizardStep() {
441+
// Validate that current step has a selection
442+
if (!this.wizardData[this.currentWizardStep]) {
443+
this.showWizardError('Please make a selection before continuing.');
444+
return;
445+
}
446+
419447
if (this.currentWizardStep < 2) {
420448
this.currentWizardStep++;
421449
this.updateWizardStep();
422450

451+
// Debug: Log current step and check if panel exists
452+
console.log(`Advanced to step ${this.currentWizardStep}`);
453+
const activePanel = document.querySelector('.wizard-panel.active');
454+
console.log('Active panel:', activePanel);
455+
console.log('Wizard options in active panel:', activePanel ? activePanel.querySelectorAll('.wizard-option').length : 0);
456+
423457
if (this.currentWizardStep === 2) {
424458
this.generateWizardResult();
425459
}
@@ -433,6 +467,38 @@ variables:
433467
}
434468
}
435469

470+
showWizardError(message) {
471+
// Remove any existing error
472+
const existingError = document.querySelector('.wizard-error');
473+
if (existingError) {
474+
existingError.remove();
475+
}
476+
477+
// Create and show error message
478+
const activePanel = document.querySelector('.wizard-panel.active');
479+
const errorDiv = document.createElement('div');
480+
errorDiv.className = 'wizard-error';
481+
errorDiv.style.cssText = `
482+
background-color: var(--color-error);
483+
color: white;
484+
padding: var(--space-3);
485+
border-radius: var(--radius-md);
486+
margin: var(--space-4) 0;
487+
font-size: var(--text-sm);
488+
`;
489+
errorDiv.textContent = message;
490+
491+
const actions = activePanel.querySelector('.wizard-actions');
492+
actions.parentNode.insertBefore(errorDiv, actions);
493+
494+
// Auto-hide error after 3 seconds
495+
setTimeout(() => {
496+
if (errorDiv.parentNode) {
497+
errorDiv.remove();
498+
}
499+
}, 3000);
500+
}
501+
436502
updateWizardStep() {
437503
// Update progress
438504
const progress = (this.currentWizardStep / 2) * 100;
@@ -453,6 +519,21 @@ variables:
453519
panel.classList.remove('active');
454520
if (index === this.currentWizardStep) {
455521
panel.classList.add('active');
522+
523+
// Update button states for the active panel
524+
const nextBtn = panel.querySelector('.wizard-btn:not(.wizard-btn-secondary)');
525+
const hasSelection = this.wizardData[index] !== undefined;
526+
527+
if (nextBtn && !nextBtn.textContent.includes('Download')) {
528+
nextBtn.disabled = !hasSelection;
529+
nextBtn.style.opacity = hasSelection ? '1' : '0.5';
530+
}
531+
532+
// Update Previous button
533+
const prevBtn = panel.querySelector('.wizard-btn-secondary');
534+
if (prevBtn) {
535+
prevBtn.disabled = index === 0;
536+
}
456537
}
457538
});
458539
}

0 commit comments

Comments
 (0)