Skip to content

Commit

Permalink
fix isStriped
Browse files Browse the repository at this point in the history
fix Progress animated
fix Sx ref in TablePagination
comment out some non-working styles with // TODO
  • Loading branch information
naughton committed Sep 27, 2023
1 parent 9c251dd commit 08633ce
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 38 deletions.
2 changes: 1 addition & 1 deletion packages/mantine-react-table/src/body/MRT_TableBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { funcValue, styleValue } from '../funcValue';
interface Props<TData extends Record<string, any> = {}> {
columnVirtualizer?: MRT_Virtualizer<HTMLDivElement, HTMLTableCellElement>;
enableHover?: boolean;
isStriped?: boolean;
isStriped?: boolean | 'odd' | 'even';
table: MRT_TableInstance<TData>;
virtualColumns?: MRT_VirtualItem[];
virtualPaddingLeft?: number;
Expand Down
8 changes: 4 additions & 4 deletions packages/mantine-react-table/src/body/MRT_TableBodyCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import classes from './MRT_TableBodyRow.module.css';

interface Props<TData extends Record<string, any> = {}> {
cell: MRT_Cell<TData>;
isStriped?: boolean;
isStriped?: boolean | 'odd' | 'even';
measureElement?: (element: HTMLTableCellElement) => void;
numRows?: number;
rowIndex: number;
Expand Down Expand Up @@ -184,8 +184,8 @@ export const MRT_TableBodyCell = <TData extends Record<string, any> = {}>({

const { style, className, __vars } = getCommonCellStyles({
column,
isStriped,
row,
// isStriped, TODO: why were these here?
// row,
table,
theme,
tableCellProps,
Expand Down Expand Up @@ -218,7 +218,7 @@ export const MRT_TableBodyCell = <TData extends Record<string, any> = {}>({
'--white-space': density === 'xs' ? 'nowrap' : 'normal',
'--z-index':
draggingColumn?.id === column.id
? 2
? '2'
: column.getIsPinned()
? '1'
: '0',
Expand Down
2 changes: 1 addition & 1 deletion packages/mantine-react-table/src/body/MRT_TableBodyRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import classes from './MRT_TableBodyRow.module.css';
interface Props<TData extends Record<string, any> = {}> {
columnVirtualizer?: MRT_Virtualizer<HTMLDivElement, HTMLTableCellElement>;
enableHover?: boolean;
isStriped?: boolean;
isStriped?: boolean | 'odd' | 'even';
measureElement?: (element: HTMLTableRowElement) => void;
numRows?: number;
row: MRT_Row<TData>;
Expand Down
14 changes: 9 additions & 5 deletions packages/mantine-react-table/src/column.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,11 +393,15 @@ export const MRT_DefaultDisplayColumn = {
export const parseCSSVarId = (id: string) => id.replace(/[^a-zA-Z0-9]/g, '_');

export const getPrimaryShade = (theme: MantineTheme): number =>
(theme.colorScheme === 'dark'
? // @ts-ignore
theme.primaryShade?.dark ?? theme.primaryShade
: // @ts-ignore
theme.primaryShade?.light ?? theme.primaryShade) ?? 7;
typeof theme.primaryShade === 'number'
? theme.primaryShade
: theme.primaryShade?.dark ?? 7;
// TODO: where is colorScheme?
// (theme.colorScheme === 'dark'
// ? // @ts-ignore
// theme.primaryShade?.dark ?? theme.primaryShade
// : // @ts-ignore
// theme.primaryShade?.light ?? theme.primaryShade) ?? 7;

export const getPrimaryColor = (
theme: MantineTheme,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
type MRT_TableInstance,
type MRT_VirtualItem,
} from '../types';
import { funcValue } from '../funcValue';
import { funcValue, styleValue } from '../funcValue';

import classes from './MRT_TableFooterRow.module.css';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Box, Divider } from '@mantine/core';
import { type MRT_Header, type MRT_TableInstance } from '../types';
import { getPrimaryColor } from '../column.utils';

import classes from './MRT_TableHeadCellResizeHandle.module.css';

interface Props<TData extends Record<string, any> = {}> {
Expand Down
17 changes: 10 additions & 7 deletions packages/mantine-react-table/src/menus/MRT_FilterOptionMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,16 @@ export const MRT_FilterOptionMenu = <TData extends Record<string, any> = {}>({
handleSelectFilterMode(option as MRT_FilterOption)
}
color={option === filterOption ? 'blue' : undefined}
style={{
'& > .mantine-Menu-itemLabel': {
display: 'flex',
flexWrap: 'nowrap',
gap: '1ch',
},
}}
style={
{
// TODO: move to module
// '& > .mantine-Menu-itemLabel': {
// display: 'flex',
// flexWrap: 'nowrap',
// gap: '1ch',
// },
}
}
value={option}
>
<Flex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const MRT_ProgressBar = <TData extends Record<string, any> = {}>({
}}
>
<Progress
animate
animated
aria-busy="true"
aria-label="Loading"
radius={0}
Expand Down
44 changes: 27 additions & 17 deletions packages/mantine-react-table/src/toolbar/MRT_TablePagination.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { ActionIcon, Flex, Pagination, Select, Text } from '@mantine/core';
import {
ActionIcon,
Flex,
type MantineStyleProp,
Pagination,
Select,
Text,
} from '@mantine/core';
import { type MRT_TableInstance } from '../types';
import { funcValue } from '../funcValue';

Expand All @@ -7,12 +14,13 @@ interface Props<TData extends Record<string, any> = {}> {
table: MRT_TableInstance<TData>;
}

const commonActionButtonStyles: Sx = {
const commonActionButtonStyles: MantineStyleProp = {
userSelect: 'none',
'&:disabled': {
backgroundColor: 'transparent',
border: 'none',
},
// TODO: move to module
// '&:disabled': {
// backgroundColor: 'transparent',
// border: 'none',
// },
};

export const MRT_TablePagination = <TData extends Record<string, any> = {}>({
Expand Down Expand Up @@ -84,18 +92,20 @@ export const MRT_TablePagination = <TData extends Record<string, any> = {}>({
label={localization.rowsPerPage}
onChange={(value: string) => setPageSize(+value)}
value={pageSize.toString()}
style={{
'@media (min-width: 720px)': {
style={
{
// TODO: move to module
display: 'flex',
alignItems: 'center',
gap: '8px',
},
'& .mantine-Select-input': {
width: '80px',
},
}}
withinPortal
// '@media (min-width: 720px)': {
// display: 'flex',
// alignItems: 'center',
// gap: '8px',
// },
// '& .mantine-Select-input': {
// width: '80px',
// },
}
}
// withinPortal // TODO: doesn't exist anymore.
/>
)}
{paginationDisplayMode === 'pages' ? (
Expand Down

0 comments on commit 08633ce

Please sign in to comment.