Skip to content

Commit

Permalink
[angular-xmcloud] Introduce RowSplitter SXA component (#1901)
Browse files Browse the repository at this point in the history
  • Loading branch information
art-alexeyenko authored Aug 22, 2024
1 parent 7fba0bc commit e00cdb0
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Our versioning strategy is as follows:
* Richtext component ([#1864](https://github.com/Sitecore/jss/pull/1864))
* Container component ([#1872](https://github.com/Sitecore/jss/pull/1872))
* Angular SXA layout ([#1873](https://github.com/Sitecore/jss/pull/1873))([#1880](https://github.com/Sitecore/jss/pull/1880))([#1890](https://github.com/Sitecore/jss/pull/1890))
* Row-Splitter ([#1901](https://github.com/Sitecore/jss/pull/1901))
* Link-List ([#1898](https://github.com/Sitecore/jss/pull/1898))
* Column-Splitter ([#1889](https://github.com/Sitecore/jss/pull/1889))

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="component row-splitter" [ngClass]="rowSplitterStyles" [attr.id]="id">
<div *ngFor="let ph of enabledPlaceholders" class="container-fluid" [ngClass]="getRowClass(+ph - 1)">
<div>
<div class="row">
<sc-placeholder [name]="getPlaceholderName(ph)" [rendering]="rendering">
</sc-placeholder>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Component } from '@angular/core';
import { SxaComponent } from '../sxa.component';

@Component({
selector: 'app-row-splitter',
templateUrl: './row-splitter.component.html',
})
export class RowSplitterComponent extends SxaComponent {
get rowSplitterStyles(): string {
return `${this.rendering.params.GridParameters ?? ''} ${this.rendering.params.Styles ??
''}`.trimEnd();
}

get rowStyles(): string[] {
return Array.from({ length: 8 }, (_, i) => this.rendering.params[`Styles${i + 1}`]);
}

get enabledPlaceholders(): string[] {
return this.rendering.params.EnabledPlaceholders.split(',');
}

getRowClass(index: number): string {
const styleClass = this.rowStyles[index] || '';
return `${styleClass}`.trim();
}

getPlaceholderName(ph: string): string {
return `row-${ph}-{*}`;
}
}

0 comments on commit e00cdb0

Please sign in to comment.