Skip to content

Commit

Permalink
feat: add basic accordion implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
StephGit committed Dec 20, 2024
1 parent 5fc3aba commit f93f412
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,22 @@
Loaded resource:
{{ this.resource()?.name || this.resourceType()?.name }}
</div>
<div id="accordion-view">
<app-tile-component
[title]="'Templates'"
[actionName]="'New Template'"
[canAction]="true"
[isVisible]="false"
[lists]="templatesData()"
(tileAction)="add()"
(listAction)="doListAction($event)"
></app-tile-component>

<app-tile-component
[title]="'Templates'"
[actionName]="'New Template'"
[canAction]="true"
[lists]="templatesData()"
(tileAction)="add()"
(listAction)="doListAction($event)"
></app-tile-component>

<app-resources-edit-functions
[resourceId]="resource()?.id"
[contextId]="contextId()"
></app-resources-edit-functions>
<app-resources-edit-functions
[resourceId]="resource()?.id"
[contextId]="contextId()"
></app-resources-edit-functions>
</div>
}
</div>
</app-page>
10 changes: 9 additions & 1 deletion AMW_angular/io/src/app/shared/tile/tile.component.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
.tile {
border: 1px solid #ddd;
padding: 1em;
margin: 0.5em;
margin: 0.5em 0.5em 1.5em;

.tile-header {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
cursor: pointer;
line-height: 18px;
}

.opened {
border-bottom: 1px solid #ddd;
padding-bottom: 0.5em;
}

.tile-title {
Expand Down
19 changes: 16 additions & 3 deletions AMW_angular/io/src/app/shared/tile/tile.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ import { TileListComponent, TileListEntry, TileListEntryOutput } from './tile-li
selector: 'app-tile-component',
template: `
<div class="tile">
<div class="tile-header">
<div class="tile-title">{{ title() }}</div>
<div class="tile-header" (click)="toggleBody()" [ngClass]="showBody() ? 'opened' : 'closed'">
<div class="tile-title">
@if (showBody()) {
<app-icon icon="caret-down"></app-icon>} @else {
<app-icon icon="caret-right"></app-icon>
}
{{ title() }}
</div>
@if (canAction()) {
<div class="tile-action-bar">
<app-button [variant]="'primary'" [size]="'sm'" (click)="tileAction.emit()">
Expand All @@ -21,7 +27,7 @@ import { TileListComponent, TileListEntry, TileListEntryOutput } from './tile-li
</div>
}
</div>
@if (showBody()) {
<div class="tile-body">
@if (!lists()) {
<div class="no-content">
Expand All @@ -46,6 +52,7 @@ import { TileListComponent, TileListEntry, TileListEntryOutput } from './tile-li
></app-tile-list>
}
</div>
}
</div>
`,
styleUrls: ['./tile.component.scss'],
Expand All @@ -67,6 +74,7 @@ export class TileComponent {
title = input.required<string>();
actionName = input.required<string>();
canAction = input<boolean>(false);
isVisible = input<boolean>(false);
lists = input.required<
{
title: string;
Expand All @@ -78,4 +86,9 @@ export class TileComponent {
>();
tileAction = output<void>();
listAction = output<TileListEntryOutput>();

showBody = signal(this.isVisible());
toggleBody() {
this.showBody.set(!this.showBody());
}
}

0 comments on commit f93f412

Please sign in to comment.