diff --git a/src/app/components/input-section/input-section.component.scss b/src/app/components/input-section/input-section.component.scss index 58a6987..d493c45 100644 --- a/src/app/components/input-section/input-section.component.scss +++ b/src/app/components/input-section/input-section.component.scss @@ -32,6 +32,6 @@ } & textarea { - height: calc(var(--height) - 2rem); + height: calc(var(--height) - 2rem) !important; } } diff --git a/src/app/components/stepper/stepper.component.html b/src/app/components/stepper/stepper.component.html index 8eaaeca..355832a 100644 --- a/src/app/components/stepper/stepper.component.html +++ b/src/app/components/stepper/stepper.component.html @@ -1,6 +1,6 @@
@for (item of controls; track $index) { -
+
diff --git a/src/app/components/stepper/stepper.component.ts b/src/app/components/stepper/stepper.component.ts index e7e6442..7dcd80d 100644 --- a/src/app/components/stepper/stepper.component.ts +++ b/src/app/components/stepper/stepper.component.ts @@ -6,53 +6,48 @@ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; import { expandTrigger } from '../../animations.helper'; @Component({ - selector: 'app-stepper', - standalone: true, - imports: [ - CommonModule, - MatButtonModule, - MatIconModule, - MatProgressSpinnerModule, - ], - templateUrl: './stepper.component.html', - styleUrl: './stepper.component.scss', - animations: [ expandTrigger('next') ] + selector: 'app-stepper', + standalone: true, + imports: [CommonModule, MatButtonModule, MatIconModule, MatProgressSpinnerModule], + templateUrl: './stepper.component.html', + styleUrl: './stepper.component.scss', + animations: [expandTrigger('next')], }) export class StepperComponent { - @Input({ alias: 'controls', required: true }) - controls!: T[]; - - @Input({ alias: 'template', required: true }) - template!: TemplateRef; - - @Output('completed') - completed = new EventEmitter(); - - private step = 0; - done = false; - - get last(): boolean { - return this.step >= this.controls.length - 1; - } - - get progress(): number { - return (this.step + 1) / this.controls.length * 100; - } - - show(index: number): boolean { - return index <= this.step; - } - - disabled(index: number): boolean { - return index !== this.step; - } - - next(): void { - this.step++; - - if (this.step === this.controls.length) { - this.done = true; - this.completed.emit(); + @Input({ alias: 'controls', required: true }) + controls!: T[]; + + @Input({ alias: 'template', required: true }) + template!: TemplateRef; + + @Output('completed') + completed = new EventEmitter(); + + private step = 0; + done = false; + + get last(): boolean { + return this.step >= this.controls.length - 1; + } + + get progress(): number { + return ((this.step + 1) / this.controls.length) * 100; + } + + show(index: number): 'expanded' | 'collapsed' { + return index <= this.step ? 'expanded' : 'collapsed'; + } + + disabled(index: number): boolean { + return index !== this.step; + } + + next(): void { + this.step++; + + if (this.step === this.controls.length) { + this.done = true; + this.completed.emit(); + } } - } } diff --git a/src/app/models/page.model.ts b/src/app/models/page.model.ts index e58abfa..57cd574 100644 --- a/src/app/models/page.model.ts +++ b/src/app/models/page.model.ts @@ -30,9 +30,8 @@ export interface HeroSection { image: string; } -type PageContent = MarkdownContent - | QuoteContent - | FormStepperContent - | IFrameContent - | SectionContent - | SliderContent; \ No newline at end of file +export type PageContent = MarkdownContent + | FormStepperContent + | IFrameContent + | SectionContent + | SliderContent; \ No newline at end of file diff --git a/src/app/pages/page/page.component.html b/src/app/pages/page/page.component.html index 7a9290e..d4b5076 100644 --- a/src/app/pages/page/page.component.html +++ b/src/app/pages/page/page.component.html @@ -4,26 +4,27 @@ @for (item of page.content; track $index) { + @if (item.type === 'iframe' && item.value) { -
+
} @else if (item.type === 'text') { -
+
} @else if (item.type === 'stepper') { -
- +
+
} @else if (item.type === 'slider') { - + } @else { -
{{item.value | json}}
+
{{item.value | json}}
} } @@ -38,14 +39,14 @@ } @if (page.nextIndex !== undefined) { + [routerLink]="[ '/p', unitIndex, page.nextIndex ]" [disabled]="disabled"> Weiter  } @else { + routerLink="/" [disabled]="disabled"> Abschließen  diff --git a/src/app/pages/page/page.component.ts b/src/app/pages/page/page.component.ts index 41c5ed6..769bc1a 100644 --- a/src/app/pages/page/page.component.ts +++ b/src/app/pages/page/page.component.ts @@ -12,6 +12,7 @@ import { StepperComponent } from '../../components/stepper/stepper.component'; import { GuideService } from '../../services/guide.service'; import { SafeUrlPipe } from '../../pipes/safe-url.pipe'; import { MarkedPipe } from '../../pipes/marked.pipe'; +import { PageContent } from '../../models/page.model'; import { expandTrigger } from '../../animations.helper'; @Component({ @@ -38,6 +39,10 @@ export class PageComponent { private route = inject(ActivatedRoute); readonly unitIndex = +this.route.snapshot.params['unit']; + private step = 0; + done = false; + next!: () => void; + readonly guideService = inject(GuideService); readonly currentPage$ = combineLatest([from(this.guideService.getPages(this.unitIndex)), this.route.params]).pipe( switchMap(([pages, params]) => { @@ -50,6 +55,31 @@ export class PageComponent { nextIndex: next, }); }), - tap((page) => document.title = page.title + " | Why App") + tap(page => { + this.initBreakpoints(page.content); + document.title = page.title + " | Why App"; + }) ); + + private initBreakpoints(content: PageContent[]) { + const breakpoints = content.reduce((acc, item, index) => { + if (item.type === 'stepper') { + acc.push(index); + } + return acc; + }, [] as number[]); + this.next = () => { + this.step = breakpoints.shift() ?? content.length; + this.done = this.step === content.length; + } + this.next(); + } + + show(index: number): 'expanded' | 'collapsed' { + return index <= this.step ? 'expanded' : 'collapsed'; + } + + get disabled() { + return !this.done; + } }