1import { Component, Input } from "@angular/core";
2import {SimpleTableComponent} from "@simple-table/angular";import type { AngularHeaderObject, Row, Theme } from "@simple-table/angular";
3import { columnAlignmentConfig } from "./column-alignment.demo-data";
4import "@simple-table/angular/styles.css";
5
6@Component({
7 selector: "column-alignment-demo",
8 standalone: true,
9 imports: [SimpleTableComponent],
10 template: `
11 <simple-table
12 [rows]="rows"
13 [defaultHeaders]="headers"
14 [height]="height"
15 [theme]="theme"
16 ></simple-table>
17 `,
18})
19export class ColumnAlignmentDemoComponent {
20 @Input() height: string | number = "400px";
21 @Input() theme?: Theme;
22
23 readonly rows: Row[] = columnAlignmentConfig.rows;
24 readonly headers: AngularHeaderObject[] = columnAlignmentConfig.headers;
25}
26
27
28// column-alignment.demo-data.ts
29// Self-contained demo table setup for this example.
30import type { AngularHeaderObject } from "@simple-table/angular";
31
32
33export const columnAlignmentHeaders: AngularHeaderObject[] = [
34 { accessor: "id", label: "ID", width: 80, align: "left", type: "number" },
35 { accessor: "name", label: "Name", minWidth: 100, width: "1fr", align: "center", type: "string" },
36 { accessor: "score", label: "Score", width: 120, align: "right", type: "number" },
37 { accessor: "rating", label: "Rating", width: 120, align: "right", type: "number" },
38 { accessor: "status", label: "Status", width: 120, align: "left", type: "string" },
39];
40
41export const columnAlignmentData = [
42 { id: 1, name: "Camila Rodriguez", score: 94, rating: 4.9, status: "Active" },
43 { id: 2, name: "Enzo Silva", score: 89, rating: 4.6, status: "Active" },
44 { id: 3, name: "Yuki Kim", score: 96, rating: 4.8, status: "Active" },
45 { id: 4, name: "Leandro Nakamura", score: 81, rating: 4.2, status: "Injured" },
46 { id: 5, name: "Nadia Petrov", score: 87, rating: 4.4, status: "Active" },
47 { id: 6, name: "Taj Chen", score: 92, rating: 4.7, status: "Active" },
48 { id: 7, name: "Mira Thompson", score: 90, rating: 4.5, status: "Active" },
49 { id: 8, name: "Juno Garcia", score: 84, rating: 4.3, status: "Inactive" },
50 { id: 9, name: "Caspian Williams", score: 95, rating: 4.9, status: "Active" },
51 { id: 10, name: "Vera Martinez", score: 88, rating: 4.4, status: "Active" },
52 { id: 11, name: "Zion Hassan", score: 93, rating: 4.8, status: "Active" },
53 { id: 12, name: "Kira Kumar", score: 91, rating: 4.6, status: "Resting" },
54];
55
56export const columnAlignmentConfig = {
57 headers: columnAlignmentHeaders,
58 rows: columnAlignmentData,
59} as const;
60