Skip to content

Commit 4134d15

Browse files
authored
move complex styles out of style tag into module (#145)
1 parent 2bc9682 commit 4134d15

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.root {
2+
--first-last-color: light-dark(
3+
var(--mantine-color-gray-3),
4+
var(--mantine-color-gray-8)
5+
);
6+
& tr:first-of-type td {
7+
border-top: 1px solid var(--first-last-color);
8+
}
9+
& tr:last-of-type td {
10+
border-bottom: 1px solid var(--first-last-color);
11+
}
12+
display: table;
13+
[data-layout='grid'] {
14+
display: grid;
15+
}
16+
:not([data-layout='grid'])[data-column-resizing] {
17+
table-layout: fixed;
18+
}
19+
}

packages/mantine-react-table/src/table/MRT_Table.tsx

+5-13
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { parseCSSVarId } from '../column.utils';
1212
import { type MRT_TableInstance, type MRT_Virtualizer } from '../types';
1313
import { funcValue, styleValue } from '../funcValue';
1414

15+
import classes from './MRT_Table.module.css';
16+
1517
interface Props<TData extends Record<string, any> = {}> {
1618
table: MRT_TableInstance<TData>;
1719
}
@@ -142,24 +144,14 @@ export const MRT_Table = <TData extends Record<string, any> = {}>({
142144

143145
return (
144146
<Table
147+
className={classes.root}
145148
highlightOnHover
146149
horizontalSpacing={density}
147150
verticalSpacing={density}
148151
{...tableProps}
152+
data-layout={layoutMode}
153+
{...(enableColumnResizing ? { 'data-column-resizing': true } : null)}
149154
style={(theme) => ({
150-
display: layoutMode === 'grid' ? 'grid' : 'table',
151-
tableLayout:
152-
layoutMode !== 'grid' && enableColumnResizing ? 'fixed' : undefined,
153-
'& tr:first-of-type td': {
154-
borderTop: `1px solid ${
155-
theme.colors.gray[8] // TODO: [theme.colorScheme === 'dark' ? 8 : 3]
156-
}`,
157-
},
158-
'& tr:last-of-type td': {
159-
borderBottom: `1px solid ${
160-
theme.colors.gray[8] // TODO: [theme.colorScheme === 'dark' ? 8 : 3]
161-
}`,
162-
},
163155
...columnSizeVars,
164156
...styleValue(tableProps, theme),
165157
})}

0 commit comments

Comments
 (0)