Skip to content

Commit b613ea4

Browse files
authored
Merge pull request #325 from cal-smith/list
Add list components
2 parents 7ae2736 + 9f5b84a commit b613ea4

15 files changed

+647
-213
lines changed

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export * from "./icon/icon.module";
1414
export * from "./inline-loading/inline-loading.module";
1515
export * from "./input/input.module";
1616
export * from "./link/link.module";
17-
export * from "./list-group/list-group.module";
17+
export * from "./list/list.module";
1818
export * from "./loading/loading.module";
1919
export * from "./modal/modal.module";
2020
export * from "./notification/notification.module";
@@ -26,6 +26,7 @@ export * from "./progress-indicator/progress-indicator.module";
2626
export * from "./radio/radio.module";
2727
export * from "./search/search.module";
2828
export * from "./select/select.module";
29+
export * from "./structured-list/structured-list.module";
2930
export * from "./switch/switch.module";
3031
export * from "./table/table.module";
3132
export * from "./tabs/tabs.module";

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

Lines changed: 0 additions & 70 deletions
This file was deleted.

src/list-group/list-group.component.ts

Lines changed: 0 additions & 116 deletions
This file was deleted.

src/list-group/list-group.module.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/list/list-item.directive.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Directive, HostBinding } from "@angular/core";
2+
3+
/**
4+
* Applies list styling to the item it is used on. Best used with `li`s.
5+
*/
6+
@Directive({
7+
selector: "[ibmListItem]"
8+
})
9+
export class ListItemDirective {
10+
@HostBinding("class.bx--list__item") wrapper = true;
11+
}

src/list/list.directive.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { Directive, ElementRef, HostBinding } from "@angular/core";
2+
3+
/**
4+
* Applies either ordered or unordered styling to the list container it is applied to.
5+
*
6+
* For `ul`s it will apply unordered list styles, and for `ol`s it will apply ordered list styles.
7+
*
8+
* If a `ul` or `ol` is nested within a `li` the directive will apply nested list styling.
9+
*/
10+
@Directive({
11+
selector: "[ibmList]"
12+
})
13+
export class List {
14+
@HostBinding("class.bx--list--ordered") get ordered() {
15+
if (this.nested) { return false; }
16+
return this.elementRef.nativeElement.tagName === "OL";
17+
}
18+
19+
@HostBinding("class.bx--list--unordered") get unordered() {
20+
if (this.nested) { return false; }
21+
return this.elementRef.nativeElement.tagName === "UL";
22+
}
23+
24+
@HostBinding("class.bx--list--nested") get nested() {
25+
return this.elementRef.nativeElement.parentElement.tagName === "LI";
26+
}
27+
28+
constructor(protected elementRef: ElementRef) {}
29+
}

src/list/list.module.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { NgModule } from "@angular/core";
2+
import { CommonModule } from "@angular/common";
3+
4+
import { ListItemDirective } from "./list-item.directive";
5+
import { List } from "./list.directive";
6+
7+
@NgModule({
8+
declarations: [
9+
ListItemDirective,
10+
List
11+
],
12+
exports: [
13+
ListItemDirective,
14+
List
15+
],
16+
imports: [CommonModule]
17+
})
18+
class ListModule {}
19+
20+
export {
21+
ListModule,
22+
ListItemDirective,
23+
List
24+
};

0 commit comments

Comments
 (0)