Skip to content

Commit 4cc50cd

Browse files
committed
docs and bug fixes.
1 parent 896071c commit 4cc50cd

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

src/pg/table/README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
The `pg-table` component allows a standard way to create static tables. While it has features like the datatable it is much more lightweight lacking features like column resize and edit.
44

5-
- `TableHeaderText`
6-
- `TableCellText`
7-
- `TableCellButton`
8-
- `TableCellButtonIcon`
5+
- `PgTableHeaderText`
6+
- `PgTableCellText` - default `string` cell type
7+
- `PgTableCellNumber` - default `number` cell type
8+
- `PgTableCellCheck` - default `boolean` cell type
9+
- `PgTableCellButton`
10+
- `PgTableCellButtonIcon`
911

1012
```typescript
1113
import '@pictogrammers/components/pg/table';
@@ -23,8 +25,7 @@ import PgTable, { createTableItem } from '@pictogrammers/components/pg/table';
2325

2426
| CSS Variable | Default | Description |
2527
| ------------------- | --------- | ----------- |
26-
| `--pg-tree-font-size` | `inherit` | Font size |
27-
| `--pg-tree-border-color` | `3rem` | Width |
28+
| `--pg-table-font-size` | `inherit` | Font size |
2829
| `--pg-table-row-background-color` | `#f1f1f1` | Row background |
2930

3031
## Columns
@@ -51,6 +52,8 @@ this.$table.columns = [{
5152

5253
## Data
5354

55+
The `createTableItem` unrolls the `{ key: value }` shorthand to `items: [{ key, value}]` object to support the mutable data.
56+
5457
```typescript
5558
const IconStar = 'M12,17.27L18.18,21L16.54,13.97L22,9.24L14.81,8.62L12,2L9.19,8.62L2,9.24L7.45,13.97L5.82,21L12,17.27Z';
5659
const IconStarOutline = 'M12,15.39L8.24,17.66L9.23,13.38L5.91,10.5L10.29,10.13L12,6.09L13.71,10.13L18.09,10.5L14.77,13.38L15.76,17.66M22,9.24L14.81,8.63L12,2L9.19,8.63L2,9.24L7.45,13.97L5.82,21L12,17.27L18.18,21L16.54,13.97L22,9.24Z';
@@ -80,8 +83,9 @@ All events dispatched will be the same `action` name. This allows the insert of
8083

8184
```typescript
8285
this.$table.addEventListener('action', (e: any) => {
83-
const { getColumn, value } = e.detail;
84-
getColumn('field1').value = value;
86+
const { getColumn, value, key } = e.detail;
87+
// do custom logic based on key
88+
getColumn(key).value = value;
8589
});
8690
```
8791

@@ -90,7 +94,7 @@ From a custom cell component...
9094
```typescript
9195
this.dispatchEvent(new CustomEvent('action', {
9296
detail {
93-
other: 'new value',
97+
other: 'other data',
9498
},
9599
}))
96100
```

src/pg/table/__examples__/basic/basic.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ export default class XPgTableBasic extends HTMLElement {
6464
const { getColumn, key } = e.detail;
6565
switch(key) {
6666
case 'favorite':
67-
getColumn('favorite').value = !getColumn('favorite').value;
68-
if (getColumn('favorite').value) {
69-
getColumn('favorite').icon = IconStar;
67+
getColumn(key).value = !getColumn(key).value;
68+
if (getColumn(key).value) {
69+
getColumn(key).icon = IconStar;
7070
} else {
71-
getColumn('favorite').icon = IconStarOutline;
71+
getColumn(key).icon = IconStarOutline;
7272
}
7373
break;
7474
case 'selected':
75-
getColumn('selected').value = e.detail.value;
75+
getColumn(key).value = e.detail.value;
7676
break;
7777
}
7878
// CSV

src/pg/table/table.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
:host {
22
display: inline-flex;
3-
color: var(--pg-icon-color, #222);
43
}
54

65
[part=table] {

0 commit comments

Comments
 (0)