-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtable_columns.tsx
More file actions
87 lines (82 loc) · 2.11 KB
/
table_columns.tsx
File metadata and controls
87 lines (82 loc) · 2.11 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import styled from '@emotion/styled';
import { IdcodeSvgRenderer } from 'react-ocl';
import {
ValueRenderers,
createTableColumnHelper,
} from '../../src/components/index.js';
import type { table } from '../data/data.js';
const Truncate = styled.div`
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
`;
const columnHelper = createTableColumnHelper<(typeof table)[number]>();
export const columns = [
columnHelper.accessor('ocl.idCode', {
header: 'Molecule',
cell: ({ getValue }) => <IdcodeSvgRenderer idcode={getValue()} />,
meta: { color: 'yellow', width: 400 },
}),
columnHelper.accessor('name', {
header: 'Name',
enableSorting: true,
sortingFn: 'textCaseSensitive',
cell: ({ getValue }) => <Truncate>{getValue()}</Truncate>,
meta: {
color: 'lightblue',
width: 200,
},
}),
columnHelper.accessor('rn', { header: 'RN' }),
columnHelper.accessor('mw', {
header: 'MW',
cell: ({ getValue }) => (
<ValueRenderers.Number value={getValue()} fixed={4} />
),
}),
columnHelper.accessor('em', {
header: 'EM',
sortingFn: 'basic',
enableSorting: true,
cell: ({ getValue }) => (
<ValueRenderers.Number value={getValue()} fixed={4} />
),
}),
columnHelper.accessor('isExpensive', {
header: 'Is expensive',
sortingFn: (row) => {
return row.original.isExpensive ? 1 : -1;
},
enableSorting: true,
}),
columnHelper.accessor('color', {
header: 'Color',
meta: {
thStyle: {
color: 'transparent',
backgroundImage:
'linear-gradient(to left, violet, indigo, blue, green, orange, red)',
backgroundClip: 'text',
},
},
}),
];
export const columnsNativeMeta = [
columnHelper.accessor('ocl.idCode', {
header: 'Molecule',
cell: ({ getValue }) => <IdcodeSvgRenderer idcode={getValue()} />,
}),
columnHelper.accessor('name', {
header: 'Name',
meta: {
thStyle: {
backgroundColor: 'black',
color: '#FFF903',
},
tdStyle: {
backgroundColor: '#DB261D',
color: '#FFF903',
},
},
}),
];