Skip to content

Commit

Permalink
chore: code tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismclarke committed Oct 1, 2024
1 parent 4749b2c commit c308379
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<!-- content -->
@for(step of content.steps; track $index){
<mat-tab>
<div class="tab-content">
<div class="tab-content" [attr.data-tool-content]="toolTabIndex() === $index">
@for(block of step; track $index){ @switch (block.type) {

<!-- Text -->
Expand All @@ -38,8 +38,6 @@ <h2>{{ 'Review' | translate }}</h2>
<router-outlet #toolRouter></router-outlet>
</div>
} } }
<!-- show title on first tab -->
@if($first){ }
</div>
</mat-tab>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,10 @@
max-height: var(--tab-height);
overflow: auto;
}
.tab-content[data-tool-content='true'] {
--page-padding: 0px;
}
// HACK - reduce page size when using header
.page[data-has-header='true'] {
max-height: calc(var(--tab-height) - 3.5rem);
}
// HACK - remove page padding from nested tool routes
.tool-route {
--page-padding: 0px;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CommonModule } from '@angular/common';
import { ChangeDetectionStrategy, Component, computed, effect, model, OnDestroy, OnInit } from '@angular/core';
import { ChangeDetectionStrategy, Component, computed, effect, model, OnDestroy, OnInit, signal } from '@angular/core';
import { toSignal } from '@angular/core/rxjs-interop';
import { MatTabsModule } from '@angular/material/tabs';
import { ActivatedRoute, Router, RouterOutlet } from '@angular/router';
Expand Down Expand Up @@ -50,6 +50,9 @@ export class FarmerContentModuleHomeComponent implements OnInit, OnDestroy {
/** Selected tab index. Used to programatically change tabs from custom footer */
public selectedIndex = model(0);

/** Track whether tool is active in mat-stepper */
public toolTabIndex = signal(-1);

/** Store any user-generated photos within a folder named after module */
public photoAlbum = computed(() => {
const content = this.content();
Expand Down Expand Up @@ -100,6 +103,7 @@ export class FarmerContentModuleHomeComponent implements OnInit, OnDestroy {
private handleContentChangeEffects(stepContent: IFarmerContentStep[]) {
const toolBlock = stepContent.find((b) => b.type === 'tool') as StepTool | undefined;
if (toolBlock) {
this.toolTabIndex.set(this.selectedIndex());
this.setToolUrl(toolBlock.tool);
}
// toogle app header if required by tool
Expand Down

0 comments on commit c308379

Please sign in to comment.