-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[angular-xmcloud] Introduce column-splitter component for angular (#1889
) * add column splitter * update changelog * update changelog -2 * refactor component --------- Co-authored-by: Addy Pathania <[email protected]>
- Loading branch information
1 parent
fcaf928
commit b6b87f3
Showing
3 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...mplates/angular-xmcloud/src/app/components/column-splitter/column-splitter.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<div class="row component column-splitter" [ngClass]="columnSplitterStyles" [attr.id]="id"> | ||
<div *ngFor="let ph of enabledPlaceholders" [ngClass]="getColumnClass(+ph - 1)"> | ||
<div class="row"> | ||
<sc-placeholder | ||
[name]="getPlaceholderName(ph)" | ||
[rendering]="rendering"> | ||
</sc-placeholder> | ||
</div> | ||
</div> | ||
</div> |
35 changes: 35 additions & 0 deletions
35
...templates/angular-xmcloud/src/app/components/column-splitter/column-splitter.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Component } from '@angular/core'; | ||
import { SxaComponent } from '../sxa.component'; | ||
|
||
@Component({ | ||
selector: 'app-column-splitter', | ||
templateUrl: './column-splitter.component.html', | ||
}) | ||
export class ColumnSplitterComponent extends SxaComponent { | ||
get columnSplitterStyles(): string { | ||
return `${this.rendering.params.GridParameters ?? ''} ${this.rendering.params.Styles ?? | ||
''}`.trimEnd(); | ||
} | ||
|
||
get columnWidths(): string[] { | ||
return Array.from({ length: 8 }, (_, i) => this.rendering.params[`ColumnWidth${i + 1}`]); | ||
} | ||
|
||
get columnStyles(): string[] { | ||
return Array.from({ length: 8 }, (_, i) => this.rendering.params[`Styles${i + 1}`]); | ||
} | ||
|
||
get enabledPlaceholders(): string[] { | ||
return this.rendering.params.EnabledPlaceholders.split(','); | ||
} | ||
|
||
getColumnClass(index: number): string { | ||
const widthClass = this.columnWidths[index] || ''; | ||
const styleClass = this.columnStyles[index] || ''; | ||
return `${widthClass} ${styleClass}`.trim(); | ||
} | ||
|
||
getPlaceholderName(ph: string): string { | ||
return `column-${ph}-{*}`; | ||
} | ||
} |