Skip to content

Commit 380277d

Browse files
authored
feat: implement table
* feat: init table feature * feat: remove comp selectors * feat: update data * refactor: card to tailwind * fix: update cdk dialog * feat: toast to tailwind * feat: input,textarea to tailwind * feat: context-menu to tailwind * feat: popover to tailwind * feat: drawer to tailwind * feat: skeleton to tailwind * feat: select to tailwind * feat: table implemented * feat: add experimental mode * fix: update arrow icon * feat: add selectable to table
1 parent 434cf99 commit 380277d

File tree

59 files changed

+749
-388
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+749
-388
lines changed

projects/docs/src/app/app.routes.ts

+7
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,13 @@ export const routes: Routes = [
258258
(p) => p.DarkModePageComponent
259259
),
260260
},
261+
{
262+
path: 'table',
263+
loadComponent: () =>
264+
import('./features/table-page/table-page.component').then(
265+
(p) => p.TablePageComponent
266+
),
267+
},
261268
{
262269
path: '',
263270
redirectTo: 'introduction',

projects/docs/src/app/blueprint/source-code/source-code.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
[gap]="false"
1616
class="block"
1717
[surface]="surface()"
18-
[outline]="outline()"
18+
[outlined]="outline()"
1919
>
2020
<pre
2121
class="not-prose m-0 max-h-[600px] overflow-auto text-xs"

projects/docs/src/app/examples/context-menu/show-case-context-menu/show-case-context-menu.component.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
import { ContextMenuItemDirective } from '@/ui/context-menu/context-menu-item.directive';
2+
import { ContextMenuTriggerDirective } from '@/ui/context-menu/context-menu-trigger.directive';
3+
import { ContextMenuDirective } from '@/ui/context-menu/context-menu.directive';
4+
import { ToastService } from '@/ui/toast/toast.service';
15
import {
26
ChangeDetectionStrategy,
37
Component,
48
inject,
59
signal,
610
} from '@angular/core';
7-
import { ContextMenuItemDirective } from '@/ui/context-menu/context-menu-item.directive';
8-
import { ContextMenuTriggerDirective } from '@/ui/context-menu/context-menu-trigger.directive';
9-
import { ContextMenuDirective } from '@/ui/context-menu/context-menu.directive';
10-
import { ToastService } from '@/ui/toast/toast.service';
1111

1212
@Component({
1313
selector: 'doc-show-case-context-menu',

projects/docs/src/app/examples/select/show-case-select/show-case-select.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Component } from '@angular/core';
2-
import { FormControl, ReactiveFormsModule, Validators } from '@angular/forms';
31
import { OptionGroupLabelComponent } from '@/ui/select/option-group-label.component';
42
import { OptionGroupComponent } from '@/ui/select/option-group.component';
53
import { OptionComponent } from '@/ui/select/option.component';
64
import { SelectComponent } from '@/ui/select/select.component';
5+
import { Component } from '@angular/core';
6+
import { FormControl, ReactiveFormsModule, Validators } from '@angular/forms';
77
const countries = [
88
{ code: 'KA', name: 'Georgia' },
99
{ code: 'US', name: 'United States' },
Original file line numberDiff line numberDiff line change
@@ -1,5 +0,0 @@
1-
.profile-skeleton {
2-
border-radius: 100%;
3-
width: 60px;
4-
height: 60px;
5-
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<app-skeleton class="profile-skeleton"></app-skeleton>
2-
<app-skeleton></app-skeleton>
3-
<app-skeleton></app-skeleton>
1+
<app-skeleton class="h-16 w-16 rounded-full"></app-skeleton>
2+
<app-skeleton class="my-4 h-6 w-full rounded-md"></app-skeleton>
3+
<app-skeleton class="h-6 w-full rounded-md"></app-skeleton>

projects/docs/src/app/examples/table/show-case-table/show-case-table.component.css

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<app-table-layout class="h-[250px] overflow-auto">
2+
<table
3+
appTable
4+
appSort
5+
selectable
6+
(sortChange)="sortChange($event)"
7+
class="w-full"
8+
>
9+
<thead>
10+
<tr appTrHead sticky>
11+
<th appTh appSortHeader scope="col">Name</th>
12+
<th appTh scope="col">Position</th>
13+
<th appTh scope="col">Weight</th>
14+
<th appTh scope="col">Symbol</th>
15+
</tr>
16+
</thead>
17+
<tbody>
18+
@for (row of data(); track $index) {
19+
<tr appTr (click)="selectRow(row)" [isSelected]="row === selectedRow()">
20+
<td appTd sticky>{{ row.name }}</td>
21+
<td appTd>{{ row.position }}</td>
22+
<td appTd>{{ row.weight }}</td>
23+
<td appTd>{{ row.symbol }}</td>
24+
</tr>
25+
}
26+
</tbody>
27+
</table>
28+
<app-table-pagination
29+
(pageChange)="setPage($event)"
30+
[totalPages]="totalPages()"
31+
[currentPage]="currentPage()"
32+
></app-table-pagination>
33+
</app-table-layout>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import { SortHeaderComponent } from '@/ui/table/sort-header.component';
2+
import { SortDirective } from '@/ui/table/sort.directive';
3+
import { TableLayoutComponent } from '@/ui/table/table-layout.component';
4+
import { TablePaginationComponent } from '@/ui/table/table-pagination.component';
5+
import { TableDirective } from '@/ui/table/table.directive';
6+
import { SortChangeType } from '@/ui/table/table.types';
7+
import { TdDirective } from '@/ui/table/td.directive';
8+
import { ThDirective } from '@/ui/table/th.directive';
9+
import { HeadTrDirective } from '@/ui/table/tr-head.directive';
10+
import { TrDirective } from '@/ui/table/tr.directive';
11+
import {
12+
ChangeDetectionStrategy,
13+
Component,
14+
computed,
15+
signal,
16+
} from '@angular/core';
17+
18+
export interface PeriodicElement {
19+
name: string;
20+
position: number;
21+
weight: number;
22+
symbol: string;
23+
}
24+
25+
const LIMIT = 30;
26+
27+
const elementNames = [
28+
'Hydrogen',
29+
'Helium',
30+
'Lithium',
31+
'Beryllium',
32+
'Boron',
33+
'Carbon',
34+
'Nitrogen',
35+
'Oxygen',
36+
'Fluorine',
37+
'Neon',
38+
];
39+
const elementSymbols = ['H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne'];
40+
41+
export function generatePeriodicElements(count = 500): PeriodicElement[] {
42+
const elements: PeriodicElement[] = [];
43+
44+
for (let i = 0; i < count; i++) {
45+
const randomIndex = Math.floor(Math.random() * elementNames.length);
46+
elements.push({
47+
name: elementNames[randomIndex],
48+
position: i + 1,
49+
weight: parseFloat((Math.random() * 200).toFixed(2)),
50+
symbol: elementSymbols[randomIndex],
51+
});
52+
}
53+
54+
return elements;
55+
}
56+
57+
// Example usage
58+
const ELEMENT_DATA = generatePeriodicElements();
59+
60+
@Component({
61+
selector: 'doc-show-case-table',
62+
imports: [
63+
SortDirective,
64+
TableDirective,
65+
TrDirective,
66+
TdDirective,
67+
ThDirective,
68+
HeadTrDirective,
69+
TableLayoutComponent,
70+
SortHeaderComponent,
71+
SortDirective,
72+
TablePaginationComponent,
73+
],
74+
templateUrl: './show-case-table.component.html',
75+
styleUrl: './show-case-table.component.css',
76+
changeDetection: ChangeDetectionStrategy.OnPush,
77+
})
78+
export class ShowCaseTableComponent {
79+
data = signal(ELEMENT_DATA);
80+
currentPage = signal(0);
81+
totalPages = computed(() => Math.ceil(this.data().length / LIMIT));
82+
83+
selectedRow = signal<PeriodicElement | undefined>(undefined);
84+
85+
sortChange($event: SortChangeType) {
86+
console.log($event);
87+
}
88+
89+
setPage(page: number) {
90+
this.currentPage.set(page);
91+
}
92+
93+
selectRow($event: PeriodicElement) {
94+
this.selectedRow.set($event);
95+
}
96+
}

projects/docs/src/app/examples/toast/show-case-toast/show-case-toast.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</app-form-field>
1313
<app-form-field>
1414
<app-label>Type</app-label>
15-
<app-select class="option" [(ngModel)]="type">
15+
<app-select placeholder="Default" class="option" [(ngModel)]="type">
1616
@for (type of types; track $index) {
1717
<app-option [value]="type">
1818
{{ type }}

projects/docs/src/app/examples/toast/show-case-toast/show-case-toast.component.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { Component, inject, model } from '@angular/core';
2-
import { FormsModule } from '@angular/forms';
31
import { ButtonComponent } from '@/ui/button/button.component';
42
import { FormFieldComponent } from '@/ui/form-field/form-field.component';
53
import { LabelComponent } from '@/ui/form-field/label/label.component';
@@ -10,6 +8,8 @@ import {
108
TOAST_TYPE,
119
ToastService,
1210
} from '@/ui/toast/toast.service';
11+
import { Component, inject, model } from '@angular/core';
12+
import { FormsModule } from '@angular/forms';
1313

1414
@Component({
1515
selector: 'doc-show-case-toast',
@@ -40,16 +40,16 @@ export class ShowCaseToastComponent {
4040
{ value: 'right_bottom', name: 'Right Bottom' },
4141
];
4242

43-
types = ['default', 'success', 'warning', 'danger'];
43+
types = ['success', 'warning', 'danger'];
4444

45-
type = model<TOAST_TYPE>('default');
45+
type = model<TOAST_TYPE | undefined>(undefined);
4646

4747
showToast() {
4848
this.toastService.open({
4949
position: this.position(),
5050
type: this.type(),
5151
message: 'Current time is: ' + new Date().toLocaleTimeString(),
52-
closeDelay: 1000,
52+
closeDelay: 500000,
5353
});
5454
}
5555
}

projects/docs/src/app/features/sidebar/sidebar.component.html

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
class="sidebar-link my-3 ml-0 flex h-8 cursor-pointer items-center justify-between rounded-md pr-2 pl-4 hover:bg-slate-100"
1111
[routerLink]="link.url"
1212
>{{ link.name }}
13+
@if (link.mode === 'experimental') {
14+
<span
15+
class="inline-flex items-center gap-1 rounded-xl bg-slate-200 px-2 py-1 text-xs"
16+
>
17+
{{ link.mode }}
18+
</span>
19+
}
1320
</a>
1421
</li>
1522
}

projects/docs/src/app/features/sidebar/sidebar.component.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface Group {
99
export interface SidebarLink {
1010
name: string;
1111
url: string;
12-
done?: boolean;
12+
mode?: 'experimental';
1313
}
1414

1515
export const SIDEBAR_ROUTES = [
@@ -145,6 +145,11 @@ export const SIDEBAR_ROUTES = [
145145
name: 'Dark Mode',
146146
url: '/doc/dark-mode',
147147
},
148+
{
149+
name: 'Table',
150+
url: '/doc/table',
151+
mode: 'experimental',
152+
},
148153
].sort((a, b) => a.name.localeCompare(b.name)),
149154
},
150155
{

projects/docs/src/app/features/table-page/table-page.component.css

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<doc-blueprint-page
2+
[subTitle]="'Table displayes tabular data'"
3+
[label]="'Table'"
4+
>
5+
<doc-show-case name="table">
6+
<doc-show-case-table></doc-show-case-table>
7+
</doc-show-case>
8+
</doc-blueprint-page>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { ChangeDetectionStrategy, Component } from '@angular/core';
2+
import { BlueprintPageComponent } from '../../blueprint/blueprint-page/blueprint-page.component';
3+
import { ShowCaseComponent } from '../../blueprint/show-case/show-case.component';
4+
import { ShowCaseTableComponent } from '../../examples/table/show-case-table/show-case-table.component';
5+
6+
@Component({
7+
selector: 'doc-table-page',
8+
imports: [BlueprintPageComponent, ShowCaseComponent, ShowCaseTableComponent],
9+
templateUrl: './table-page.component.html',
10+
styleUrl: './table-page.component.css',
11+
changeDetection: ChangeDetectionStrategy.OnPush,
12+
})
13+
export class TablePageComponent {}

projects/docs/src/tree-structure.json

+71-5
Original file line numberDiff line numberDiff line change
@@ -1012,11 +1012,6 @@
10121012
"path": "skeleton",
10131013
"name": "skeleton",
10141014
"files": [
1015-
{
1016-
"path": "skeleton/skeleton.component.css",
1017-
"name": "skeleton.component.css",
1018-
"language": "css"
1019-
},
10201015
{
10211016
"path": "skeleton/skeleton.component.spec.ts",
10221017
"name": "skeleton.component.spec.ts",
@@ -1116,6 +1111,77 @@
11161111
}
11171112
]
11181113
},
1114+
{
1115+
"path": "table",
1116+
"name": "table",
1117+
"files": [
1118+
{
1119+
"path": "table/head-tr.directive.ts",
1120+
"name": "head-tr.directive.ts",
1121+
"language": "ts"
1122+
},
1123+
{
1124+
"path": "table/sort-header.component.ts",
1125+
"name": "sort-header.component.ts",
1126+
"language": "ts"
1127+
},
1128+
{
1129+
"path": "table/sort.directive.ts",
1130+
"name": "sort.directive.ts",
1131+
"language": "ts"
1132+
},
1133+
{
1134+
"path": "table/table-layout.component.ts",
1135+
"name": "table-layout.component.ts",
1136+
"language": "ts"
1137+
},
1138+
{
1139+
"path": "table/table-local-source.ts",
1140+
"name": "table-local-source.ts",
1141+
"language": "ts"
1142+
},
1143+
{
1144+
"path": "table/table-pagination.component.css",
1145+
"name": "table-pagination.component.css",
1146+
"language": "css"
1147+
},
1148+
{
1149+
"path": "table/table-pagination.component.html",
1150+
"name": "table-pagination.component.html",
1151+
"language": "html"
1152+
},
1153+
{
1154+
"path": "table/table-pagination.component.ts",
1155+
"name": "table-pagination.component.ts",
1156+
"language": "ts"
1157+
},
1158+
{
1159+
"path": "table/table.directive.ts",
1160+
"name": "table.directive.ts",
1161+
"language": "ts"
1162+
},
1163+
{
1164+
"path": "table/table.types.ts",
1165+
"name": "table.types.ts",
1166+
"language": "ts"
1167+
},
1168+
{
1169+
"path": "table/td.directive.ts",
1170+
"name": "td.directive.ts",
1171+
"language": "ts"
1172+
},
1173+
{
1174+
"path": "table/th.directive.ts",
1175+
"name": "th.directive.ts",
1176+
"language": "ts"
1177+
},
1178+
{
1179+
"path": "table/tr.directive.ts",
1180+
"name": "tr.directive.ts",
1181+
"language": "ts"
1182+
}
1183+
]
1184+
},
11191185
{
11201186
"path": "textarea",
11211187
"name": "textarea",

0 commit comments

Comments
 (0)