forked from Kuechlin/mantine-data-grid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataGrid.styles.ts
118 lines (109 loc) · 2.84 KB
/
DataGrid.styles.ts
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import { createStyles, CSSObject } from '@mantine/core';
import { PaginationMode } from './types';
export type DataGridStylesParams = {
height?: string | number;
width?: string | number;
noEllipsis?: boolean;
withFixedHeader?: boolean;
paginationMode?: PaginationMode;
};
const ellipsis: CSSObject = {
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
};
export default createStyles(
(theme, { height, width, withFixedHeader, paginationMode = 'default' }: DataGridStylesParams) => ({
wrapper: {
height: height ? height + 'px' : undefined,
width: width ? width + 'px' : undefined,
overflow: 'hidden',
},
scrollArea: {
position: 'relative',
paddingBottom: theme.spacing.lg,
},
table: {
borderCollapse: 'separate',
borderSpacing: 0,
borderLeft: 'none',
borderRight: 'none',
},
thead: {
position: 'relative',
'::after': {
content: "' '",
backgroundColor: theme.colors.dark[4],
position: 'absolute',
left: 0,
right: 0,
bottom: 0,
height: '2px',
},
...(withFixedHeader && {
position: 'sticky',
top: 0,
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[7] : theme.white,
transition: 'box-shadow 150ms ease',
zIndex: 2,
}),
},
tbody: {
minHeight: '160px',
},
tr: {
display: 'flex',
},
th: { position: 'relative', display: 'flex', height: 'inherit', justifyContent: 'space-between' },
td: { display: 'flex', justifyContent: 'space-between' },
headerCellContent: ellipsis,
headerCellButtons: {
display: 'inline-flex',
gap: '4px',
alignItems: 'center',
},
dataCellContent: ellipsis,
resizer: {
position: 'absolute',
top: 0,
bottom: 0,
right: 0,
width: 4,
borderRight: `1px dashed ${theme.colors.dark[5]}`,
cursor: 'col-resize',
':hover': {
backgroundColor: theme.colors.dark[5],
},
},
isResizing: {
userSelect: 'none',
backgroundColor: theme.fn.primaryColor(theme.colorScheme),
},
sorter: {},
filter: {},
globalFilter: {},
pagination: {
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
[`@media (min-width: ${theme.breakpoints.xl})`]: {
justifyContent: paginationMode === 'default' ? 'space-between' : 'flex-end',
},
},
pagination_info: {
display: 'none',
[`@media (min-width: ${theme.breakpoints.xl})`]: {
display: 'inline-block',
},
},
pagination_size: {
display: 'none',
[`@media (min-width: ${theme.breakpoints.xl})`]: {
display: 'flex',
alignItems: 'center',
gap: `${theme.spacing.xs}px`,
},
},
pagination_page: {},
})
);