diff --git a/frontend/src/app/pages/event-root/create-event/create-event.component.html b/frontend/src/app/pages/event-root/create-event/create-event.component.html index e280ad0..be43da3 100644 --- a/frontend/src/app/pages/event-root/create-event/create-event.component.html +++ b/frontend/src/app/pages/event-root/create-event/create-event.component.html @@ -1,23 +1,18 @@
-
- +
+
+ +
+ +
@if (currentStep() === 0) { @@ -33,29 +28,24 @@ class="w-full bg-base-100 max-w-full sticky bottom-0 z-10 px-4 sm:px-8 py-4">
- @if (currentStep() > 0) { - - } +
@if (currentStep() < steps.length - 1) { }
diff --git a/frontend/src/app/pages/event-root/create-event/create-event.component.ts b/frontend/src/app/pages/event-root/create-event/create-event.component.ts index 6780d54..e6461c3 100644 --- a/frontend/src/app/pages/event-root/create-event/create-event.component.ts +++ b/frontend/src/app/pages/event-root/create-event/create-event.component.ts @@ -9,6 +9,8 @@ import { } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { StepperIndicatorComponent } from '../../../shared/components/stepper-indicator/stepper-indicator.component'; + import { BasicStepComponent } from './steps/basic-step.component'; import { TicketsStepComponent } from './steps/tickets-step.component'; @@ -16,7 +18,12 @@ import { TicketsStepComponent } from './steps/tickets-step.component'; selector: 'app-create-event', standalone: true, providers: [], - imports: [CommonModule, BasicStepComponent, TicketsStepComponent], + imports: [ + CommonModule, + BasicStepComponent, + TicketsStepComponent, + StepperIndicatorComponent, + ], templateUrl: './create-event.component.html', changeDetection: ChangeDetectionStrategy.OnPush, }) @@ -114,9 +121,35 @@ export class CreateEventComponent { } public getNextButtonText(): string { - return this.hasAttemptedNextStep() && !this.isCurrentStepValid() - ? 'Required Fields Need Attention' - : `Next to ${this.steps[this.currentStep() + 1]}`; + if (this.hasAttemptedNextStep() && !this.isCurrentStepValid()) { + return 'Required Fields Need Attention'; + } else { + return `Next to ${this.steps[this.currentStep() + 1]}`; + } + } + + public getNextButtonAriaLabel(): string { + if (this.hasAttemptedNextStep() && !this.isCurrentStepValid()) { + return 'Required Fields Need Attention'; + } else { + return `Next to ${this.steps[this.currentStep() + 1]}`; + } + } + + public getBackButtonText(): string { + if (this.currentStep() === 0) { + return 'Back'; + } else { + return `Back to ${this.steps[this.currentStep() - 1]}`; + } + } + + public getBackButtonAriaLabel(): string { + if (this.currentStep() === 0) { + return 'Back (disabled)'; + } else { + return `Back to ${this.steps[this.currentStep() - 1]}`; + } } private markCurrentStepAsTouched(): void { diff --git a/frontend/src/app/shared/components/stepper-indicator/stepper-indicator.component.html b/frontend/src/app/shared/components/stepper-indicator/stepper-indicator.component.html new file mode 100644 index 0000000..0f854a2 --- /dev/null +++ b/frontend/src/app/shared/components/stepper-indicator/stepper-indicator.component.html @@ -0,0 +1,69 @@ +
+
+ +
+ @for (step of steps; track $index) { + @if ($index < steps.length - 1) { +
+ } + } +
+ + + @for (step of steps; track $index) { +
+ + + {{ step }} + +
+ } +
+
diff --git a/frontend/src/app/shared/components/stepper-indicator/stepper-indicator.component.ts b/frontend/src/app/shared/components/stepper-indicator/stepper-indicator.component.ts new file mode 100644 index 0000000..b1a9498 --- /dev/null +++ b/frontend/src/app/shared/components/stepper-indicator/stepper-indicator.component.ts @@ -0,0 +1,24 @@ +import { CommonModule } from '@angular/common'; +import { Component, Input, Output, EventEmitter } from '@angular/core'; + +@Component({ + selector: 'app-stepper-indicator', + standalone: true, + imports: [CommonModule], + templateUrl: './stepper-indicator.component.html', + styles: [], +}) +export class StepperIndicatorComponent { + @Output() public stepChange: EventEmitter = + new EventEmitter(); + @Input() public steps: string[] = []; + @Input() public currentStep: number = 0; + @Input() public isStepValid: (index: number) => boolean = () => true; + @Input() public canAdvanceToStep: (index: number) => boolean = () => true; + + public goToStep(index: number): void { + if (index <= this.currentStep || this.canAdvanceToStep(index)) { + this.stepChange.emit(index); + } + } +}