Repository navigation
Expand file tree
/
Copy pathApp.svelte
More file actions
47 lines (41 loc) · 1.35 KB
/
Copy pathApp.svelte
File metadata and controls
47 lines (41 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<script>
import ExtendedTable from "../../src/ExtendedTable.svelte";
import {default as data} from '../../fixtures/fixtures.json';
let columnDefinition = [
{
title: 'Username',
propertyPath: 'username',
},
{
title: 'Name',
value: (rowData) => `${rowData.title} ${rowData.first_name} ${rowData.last_name}`,
propertyPath: 'last_name',
},
{
title: 'Location',
propertyPath: 'location.postcode',
},
];
let rows = data.slice(0, 10);
const getGenderIcon = (person) => {
return person.gender === 'male' ? '♂' : '♀';
};
const getBirthday = (person) => {
if (!person.birthdate) {
return "Unknown";
}
let birthday = new Date(person.birthdate * 1000);
return birthday.toLocaleDateString();
};
</script>
<ExtendedTable columns={columnDefinition} data={rows}>
<!-- Since we are operating on the original data, we can as for gender here -->
<div slot="column-2" let:data={person}>
{@html getGenderIcon(person)} {person.first_name} {person.last_name}
</div>
<tr slot="additionalRow" let:rowData={person}>
<td colspan="3">
Birthday: {getBirthday(person)}; Email: {person.email}
</td>
</tr>
</ExtendedTable>