-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
onExpanded event is triggered when the list status changes Closes closes #7
- Loading branch information
1 parent
749d4fc
commit 22aeb11
Showing
7 changed files
with
173 additions
and
100 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
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,22 @@ | ||
:host { | ||
background: rgb(184, 218, 215); | ||
display: block; | ||
height: 100%; | ||
padding-top: 50px; | ||
box-sizing: border-box; | ||
} | ||
|
||
.content-wrapper { | ||
max-width: 600px; | ||
margin: 0 auto; | ||
} | ||
|
||
.button { | ||
margin: 10px 0; | ||
border: 1px solid #333; | ||
background: #eee; | ||
color: #000; | ||
font-size: 14px; | ||
border-radius: 4px; | ||
padding: 5px 15px; | ||
} |
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,50 @@ | ||
<div class="content-wrapper"> | ||
<button class="button" | ||
(click)="toggleMe()"> Toggle List</button> | ||
<p>List status: {{ listAExpanded ? 'Expanded' : 'Collapsed' }}</p> | ||
|
||
<expandable-list class="expandable-list"> | ||
<expandable-list-item *ngFor="let item of items" | ||
[isExpanded]="listAExpanded" | ||
(onExpanded)="updateStatus($event)"> | ||
<span title>{{ item.title }}</span> | ||
<a item *ngFor="let i of item.items" | ||
[href]="i.link"> | ||
{{ i.title }} | ||
</a> | ||
</expandable-list-item> | ||
|
||
<expandable-list-item disabled> | ||
<span title>Manual</span> | ||
<span secondary>disabled</span> | ||
</expandable-list-item> | ||
|
||
<expandable-list-item [isExpanded]="listCExpanded"> | ||
<span title>Manual</span> | ||
<span secondary>first</span> | ||
|
||
<a href="http://www.goo.gl">THIS WON'T BE RENDERED!</a> | ||
|
||
<a item href="http://www.goo.gl">Google</a> | ||
<a item href="http://www.goo.gl">Google</a> | ||
<a item href="http://www.goo.gl">Google</a> | ||
|
||
<expandable-list-divider></expandable-list-divider> | ||
|
||
<a item href="http://www.goo.gl">Google after</a> | ||
</expandable-list-item> | ||
|
||
<expandable-list-item [isExpanded]="listBExpanded" disabled> | ||
<span title>Manual</span> | ||
<span secondary>second</span> | ||
<a href="http://www.goo.gl">Something else</a> | ||
<a item href="http://www.goo.gl">Google</a> | ||
<a item href="http://www.goo.gl">Google</a> | ||
<a item href="http://www.goo.gl">Google</a> | ||
|
||
<expandable-list-divider></expandable-list-divider> | ||
|
||
<a item href="http://www.goo.gl">Google</a> | ||
</expandable-list-item> | ||
</expandable-list> | ||
</div> |
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 |
---|---|---|
@@ -1,107 +1,56 @@ | ||
import { Component } from '@angular/core'; | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app', | ||
styles: [` | ||
:host { | ||
background: rgb(184, 218, 215); | ||
display: block; | ||
height: 100%; | ||
padding-top: 50px; | ||
box-sizing: border-box; | ||
} | ||
.expandable-list { | ||
max-width: 600px; | ||
margin: 0 auto; | ||
} | ||
`], | ||
template: ` | ||
<expandable-list class="expandable-list"> | ||
<expandable-list-item *ngFor="let item of items" [isExpanded]="listAExpanded"> | ||
<span title>{{ item.title }}</span> | ||
<a item *ngFor="let i of item.items" | ||
[href]="i.link"> | ||
{{ i.title }} | ||
</a> | ||
</expandable-list-item> | ||
<expandable-list-item disabled> | ||
<span title>Manual</span> | ||
<span secondary>disabled</span> | ||
</expandable-list-item> | ||
<expandable-list-item [isExpanded]="listCExpanded"> | ||
<span title>Manual</span> | ||
<span secondary>first</span> | ||
<a href="http://www.goo.gl">THIS WON'T BE RENDERED!</a> | ||
<a item href="http://www.goo.gl">Google</a> | ||
<a item href="http://www.goo.gl">Google</a> | ||
<a item href="http://www.goo.gl">Google</a> | ||
<expandable-list-divider></expandable-list-divider> | ||
<a item href="http://www.goo.gl">Google after</a> | ||
</expandable-list-item> | ||
<expandable-list-item [isExpanded]="listBExpanded" disabled> | ||
<span title>Manual</span> | ||
<span secondary>second</span> | ||
<a href="http://www.goo.gl">Something else</a> | ||
<a item href="http://www.goo.gl">Google</a> | ||
<a item href="http://www.goo.gl">Google</a> | ||
<a item href="http://www.goo.gl">Google</a> | ||
<expandable-list-divider></expandable-list-divider> | ||
<a item href="http://www.goo.gl">Google</a> | ||
</expandable-list-item> | ||
</expandable-list> | ||
` | ||
styleUrls: ['./app.component.css'], | ||
templateUrl: './app.component.html', | ||
}) | ||
export class AppComponent { | ||
export class AppComponent implements OnInit { | ||
items: any; | ||
listAExpanded = false; | ||
listBExpanded = true; | ||
listCExpanded = false; | ||
|
||
constructor() { | ||
this.items = [ | ||
{ | ||
title: 'Spices', | ||
items: [ | ||
{ | ||
title: 'salt', | ||
link: 'https://en.wikipedia.org/wiki/Salt' | ||
}, | ||
{ | ||
title: 'Black pepper', | ||
link: 'https://en.wikipedia.org/wiki/Black_pepper' | ||
}, | ||
] | ||
}, | ||
{ | ||
title: 'Cats', | ||
items: [ | ||
{ | ||
title: 'Siberian', | ||
link: 'https://en.wikipedia.org/wiki/Siberian_cat' | ||
}, | ||
{ | ||
title: 'Maine Coon', | ||
link: 'https://en.wikipedia.org/wiki/Maine_Coon' | ||
}, | ||
{ | ||
title: 'American Bobtail', | ||
link: 'https://en.wikipedia.org/wiki/American_Bobtail' | ||
}, | ||
{ | ||
title: 'British Longhair', | ||
link: 'https://en.wikipedia.org/wiki/British_Longhair' | ||
}, | ||
] | ||
}, | ||
]; | ||
constructor() { } | ||
|
||
ngOnInit(): void { | ||
this.items = [{ | ||
title: 'Spices', | ||
items: [ | ||
{ | ||
title: 'salt', | ||
link: 'https://en.wikipedia.org/wiki/Salt' | ||
}, { | ||
title: 'Black pepper', | ||
link: 'https://en.wikipedia.org/wiki/Black_pepper' | ||
} | ||
] | ||
}, { | ||
title: 'Cats', | ||
items: [ | ||
{ | ||
title: 'Siberian', | ||
link: 'https://en.wikipedia.org/wiki/Siberian_cat' | ||
}, { | ||
title: 'Maine Coon', | ||
link: 'https://en.wikipedia.org/wiki/Maine_Coon' | ||
}, { | ||
title: 'American Bobtail', | ||
link: 'https://en.wikipedia.org/wiki/American_Bobtail' | ||
}, { | ||
title: 'British Longhair', | ||
link: 'https://en.wikipedia.org/wiki/British_Longhair' | ||
} | ||
] | ||
}]; | ||
} | ||
|
||
toggleMe(): void { | ||
this.listAExpanded = !this.listAExpanded; | ||
} | ||
|
||
updateStatus(event: boolean) { | ||
console.log(event); | ||
this.listAExpanded = event; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
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