Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v-angular: full width table and sort button #1929

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 52 additions & 17 deletions libs/angular/src/v-angular/table/table.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
<ng-template #sortableThTemplate let-column>
<button class="sg-table-sort" *transloco="let t">
<ng-template #thButtonTemplate>
{{ t(column.label ?? '') }}
</ng-template>
<ng-container
*ngIf="
customHeaderTemplates.get(column.property) as thTemplate;
else thButtonTemplate
"
>
<ng-template
*ngTemplateOutlet="thTemplate || null; context: { $implicit: column }"
>
</ng-template>
</ng-container>
</button>
</ng-template>

<ng-template #notSortableThTemplate let-column>
<ng-template #defaultThTemplate>
<ng-container *transloco="let t">
{{ t(column.label ?? '') }}
</ng-container>
</ng-template>
<ng-container
*ngIf="
customHeaderTemplates.get(column.property) as thTemplate;
else defaultThTemplate
"
>
<ng-template
*ngTemplateOutlet="thTemplate || null; context: { $implicit: column }"
>
</ng-template>
</ng-container>
</ng-template>

<table class="gds-table" *transloco="let t">
<!-- Table header -->
<thead>
Expand Down Expand Up @@ -28,27 +66,24 @@
[attr.aria-label]="getAriaLabel(column)"
[attr.aria-sort]="column.order + 'ending'"
>
<ng-container
*ngIf="
customHeaderTemplates.get(column.property) as thTemplate;
else defaultThTemplate
"
>
<!-- Cannot infer thTemplate as TemplateRef therefore null -->
<ng-template
<ng-container *ngIf="column.sortable">
<ng-container
*ngTemplateOutlet="
thTemplate || null;
context: { $implicit: column }
sortableThTemplate;
context: { $implicit: column, column: column }
"
>
</ng-template>
</ng-container>
</ng-container>
<ng-container *ngIf="!column.sortable">
<ng-container
*ngTemplateOutlet="
notSortableThTemplate;
context: { $implicit: column, column: column }
"
>
</ng-container>
</ng-container>

<ng-template #defaultThTemplate>
<button class="sg-table-sort">
{{ t(column.label ?? '') }}
</button>
</ng-template>
</th>
</tr>
</thead>
Expand Down
3 changes: 3 additions & 0 deletions libs/angular/src/v-angular/table/table.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
--gds-ref-pallet-base500: hsl(0, 0%, 68%);
--sg-table-sort-icon-color-active: #fff;
@include table.add-table();
width: 100%;

border-bottom: none;

Expand Down Expand Up @@ -39,6 +40,8 @@
background-color: rgba(0, 0, 0, 0);
border: 0;
font-family: inherit;
font-size: inherit;
font-weight: inherit;
padding: 0;
cursor: pointer;
}
Expand Down
4 changes: 2 additions & 2 deletions libs/angular/src/v-angular/table/table.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ export const columns: {
{
property: 'currency',
label: 'header.currency',
sortable: true,
sortable: false,
ariaLabelSortable:
'Activate to sort Currency column in {{sortOrder}} order',
},
{
property: 'bookedBalance',
label: 'header.bookedbalance',
valueType: 'numeric',
sortable: true,
sortable: false,
},
{
property: 'datedBalance',
Expand Down
Loading