Skip to content

Commit 30d07b0

Browse files
authored
Merge pull request #2287 from Akshat55/structured-list-next
feat: Add option to align content to margin
2 parents e7fbe33 + 8809d12 commit 30d07b0

File tree

4 files changed

+17
-20
lines changed

4 files changed

+17
-20
lines changed

src/structured-list/list-column.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { Component, HostBinding, Input } from "@angular/core";
2020
export class ListColumn {
2121
@Input() skeleton = false;
2222

23+
@HostBinding("attr.role") role = "cell";
2324
@HostBinding("class.cds--structured-list-th") isHeaderColumn = true;
2425
@HostBinding("class.cds--structured-list-td") isBodyColumn = true;
2526
/**

src/structured-list/list-header.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ import { ListColumn } from "./list-column.component";
2323
@Component({
2424
selector: "ibm-list-header",
2525
template: `
26-
<div class="cds--structured-list-row cds--structured-list-row--header-row">
26+
<div class="cds--structured-list-row cds--structured-list-row--header-row" role="row">
2727
<ng-content></ng-content>
2828
<div *ngIf="selection" class="cds--structured-list-th"></div>
2929
</div>
3030
`
3131
})
3232
export class ListHeader implements AfterContentInit {
3333
@HostBinding("class.cds--structured-list-thead") wrapper = true;
34+
@HostBinding("attr.role") role = "rowgroup";
3435

3536
@Input()
3637
set skeleton(value: any) {

src/structured-list/structured-list.component.spec.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ import { IconModule } from "../icon/index";
1111
@Component({
1212
template: `
1313
<ibm-structured-list
14-
border="true"
14+
flushed="true"
1515
[condensed]="condensed"
16-
nowrap="false"
1716
selection="true"
1817
[(ngModel)]="valueSelected"
1918
(selected)="onSelected()">
@@ -64,11 +63,11 @@ describe("StructuredList", () => {
6463
expect(fixture.componentInstance instanceof StructuredList).toBe(true);
6564
});
6665

67-
it("should set cds--structured-list--border class", () => {
66+
it("should set cds--structured-list--flushed class", () => {
6867
fixture = TestBed.createComponent(StructuredListTest);
6968
fixture.detectChanges();
7069
element = fixture.debugElement.query(By.css("ibm-structured-list"));
71-
expect(element.nativeElement.querySelector(".cds--structured-list--border")).toBeTruthy();
70+
expect(element.nativeElement.querySelector(".cds--structured-list--flush")).toBeTruthy();
7271
});
7372

7473
it("should change valueSelected to row1 on click and emit selected event", () => {
@@ -83,12 +82,12 @@ describe("StructuredList", () => {
8382
expect(wrapper.onSelected).toHaveBeenCalled();
8483
});
8584

86-
it("should set cds--structured-list-content--nowrap class", () => {
85+
it("should set cds--structured-list--condensed class", () => {
8786
fixture = TestBed.createComponent(StructuredListTest);
88-
fixture.detectChanges();
8987
wrapper = fixture.componentInstance;
9088
wrapper.condensed = true;
89+
fixture.detectChanges();
9190
element = fixture.debugElement.query(By.css("ibm-structured-list"));
92-
expect(element.nativeElement.querySelector(".cds--structured-list-content--nowrap")).toBeTruthy();
91+
expect(element.nativeElement.querySelector(".cds--structured-list--condensed")).toBeTruthy();
9392
});
9493
});

src/structured-list/structured-list.component.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,20 @@ import { NG_VALUE_ACCESSOR, ControlValueAccessor } from "@angular/forms";
5454
@Component({
5555
selector: "ibm-structured-list",
5656
template: `
57-
<section
57+
<div
5858
class="cds--structured-list"
59+
role="table"
5960
[ngClass]="{
60-
'cds--structured-list--border': border,
61+
'cds--structured-list--flush': flushed,
6162
'cds--structured-list--selection': selection,
6263
'cds--structured-list--condensed': condensed,
63-
'cds--structured-list-content--nowrap': nowrap,
6464
'cds--skeleton': skeleton
6565
}">
6666
<ng-content select="ibm-list-header"></ng-content>
67-
<div class="cds--structured-list-tbody">
67+
<div class="cds--structured-list-tbody" role="rowgroup">
6868
<ng-content></ng-content>
6969
</div>
70-
</section>
70+
</div>
7171
`,
7272
providers: [
7373
{
@@ -87,17 +87,13 @@ export class StructuredList implements AfterContentInit, ControlValueAccessor {
8787
*/
8888
@Input() selection = false;
8989
/**
90-
* Set to `true` to apply a border and white background.
90+
* Set to `true` to align content with margin
9191
*/
92-
@Input() border = false;
92+
@Input() flushed = false;
9393
/**
9494
* Set to `true` to apply a condensed style to the headers and rows.
9595
*/
9696
@Input() condensed = false;
97-
/**
98-
* Set to `true` to apply `white-space: nowrap` on _all_ conent.
99-
*/
100-
@Input() nowrap = false;
10197
/**
10298
* Used when `selection = true` as the row radio group `name`
10399
*/
@@ -151,7 +147,7 @@ export class StructuredList implements AfterContentInit, ControlValueAccessor {
151147
this.rows.forEach(row => {
152148
setSelection(row);
153149
row.name = this.name;
154-
row.tabindex = this.selection ? "0" : "null";
150+
row.tabindex = this.selection ? "0" : null;
155151
row.change.subscribe(() => {
156152
this.selected.emit({
157153
value: row.value,

0 commit comments

Comments
 (0)