Skip to content

Commit

Permalink
Common Details Overview Section Card Content (#1599)
Browse files Browse the repository at this point in the history
* Created a reusable component for content in common section card

* Removed Data array processing in CommonSectionCardContentComponent and refactored its html

---------

Co-authored-by: khanjan <[email protected]>
  • Loading branch information
KD1712 and khanjan authored Jun 4, 2024
1 parent 53fc82f commit 361ccf6
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<app-common-section-card-list>
<app-feature-flag-overview-details-section-card section-card></app-feature-flag-overview-details-section-card>
<app-feature-flag-inclusions-section-card *ngIf="(activeTabIndex$ | async) === 0" section-card>inclusions-card</app-feature-flag-inclusions-section-card>
<app-feature-flag-exclusions-section-card *ngIf="(activeTabIndex$ | async) === 0" section-card>exclusions-card</app-feature-flag-exclusions-section-card>
<app-feature-flag-exposures-section-card *ngIf="(activeTabIndex$ | async) === 1" section-card>exposures-card</app-feature-flag-exposures-section-card>
<app-feature-flag-inclusions-section-card *ngIf="(activeTabIndex$ | async) === 0" section-card
>inclusions-card</app-feature-flag-inclusions-section-card
>
<app-feature-flag-exclusions-section-card *ngIf="(activeTabIndex$ | async) === 0" section-card
>exclusions-card</app-feature-flag-exclusions-section-card
>
<app-feature-flag-exposures-section-card *ngIf="(activeTabIndex$ | async) === 1" section-card
>exposures-card</app-feature-flag-exposures-section-card
>
</app-common-section-card-list>

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<app-common-tabbed-section-card-footer
[tabLabels]="tabLabels"
(selectedTabChange)="onSelectedTabChange($event)"
></app-common-tabbed-section-card-footer>
></app-common-tabbed-section-card-footer>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<app-common-section-card class="details-overview-card">
<div header-left style="background-color: beige; height: 90px; width: 100%">header-left</div>
<div header-right style="background-color: beige; height: 90px; width: 100%">header-right</div>
<div content style="background-color: beige; height: 90px; width: 100%">content: Details Overview</div>
<app-feature-flag-overview-details-footer footer></app-feature-flag-overview-details-footer>
</app-common-section-card>
<app-common-section-card class="details-overview-card">
<div header-left style="background-color: beige; height: 90px; width: 100%">header-left</div>
<div header-right style="background-color: beige; height: 90px; width: 100%">header-right</div>
<div content style="background-color: beige; height: 90px; width: 100%">content: Details Overview</div>
<app-feature-flag-overview-details-footer footer></app-feature-flag-overview-details-footer>
</app-common-section-card>
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@
color: var(--dark-grey);
padding: 16px;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div class="content-section">
<div *ngFor="let obj of data">
<div *ngFor="let item of obj | keyvalue">
<span style="font-weight: bold">{{ item.key }}:</span>
<ng-container *ngIf="item.key !== 'tags'; else chipSection">
<span>{{ item.value }}</span>
</ng-container>

<ng-template #chipSection>
<mat-chip-list>
<mat-chip *ngFor="let tag of item.value">{{ tag }}</mat-chip>
</mat-chip-list>
</ng-template>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.content-section {
width: 100%;
border: 1px solid var(--light-grey);
border-radius: 4px;
background-color: var(--white);
padding: 0 32px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { CommonSectionCardContentComponent } from './common-section-card-content.component';

describe('CommonSectionCardContentComponent', () => {
let component: CommonSectionCardContentComponent;
let fixture: ComponentFixture<CommonSectionCardContentComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [CommonSectionCardContentComponent],
}).compileComponents();

fixture = TestBed.createComponent(CommonSectionCardContentComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { SharedModule } from '../../../shared/shared.module';

@Component({
selector: 'app-common-section-card-content',
standalone: true,
//Here imported SharedModule which exports CommonModule and MatChipModule
imports: [SharedModule],

templateUrl: './common-section-card-content.component.html',
styleUrl: './common-section-card-content.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
})

// This component processes the provided data and splits it into two arrays: 'keys' and 'values'.
// It then maps and displays the content from these arrays.
//
// Example Usage:
//
// contentDetails = [
// { key: 'name' },
// { description: 'something' },
// { tags: ['Tag1', 'Tag2'] },
// { Appcontext: 'Context1' },
// ];
//
// Simply pass the data to the component as shown below:
// <app-common-section-card-content [data]="contentDetails"></app-common-section-card-content>
export class CommonSectionCardContentComponent {
@Input() data: { key: string; value: string }[] = [];
}
2 changes: 1 addition & 1 deletion types/src/Experiment/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,4 @@ export interface CaliperEnvelope {
export interface IMenuButtonItem {
name: string;
disabled: boolean;
}
}

0 comments on commit 361ccf6

Please sign in to comment.