Skip to content

Commit 8fe4f1c

Browse files
committed
Remove theme props override from view components, fix infinite list test.
1 parent f80fa27 commit 8fe4f1c

File tree

9 files changed

+38
-25
lines changed

9 files changed

+38
-25
lines changed

packages/ra-ui-materialui/src/detail/Create.stories.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,13 @@ export const Themed = () => (
283283
defaultProps: {
284284
className: 'custom-class',
285285
},
286+
styleOverrides: {
287+
root: {
288+
['& .RaCreate-card']: {
289+
color: 'red',
290+
},
291+
},
292+
},
286293
},
287294
},
288295
} as ThemeOptions)}

packages/ra-ui-materialui/src/detail/CreateView.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,14 @@ import {
66
styled,
77
type SxProps,
88
type Theme,
9-
useThemeProps,
109
} from '@mui/material';
1110
import { useCreateContext } from 'ra-core';
1211
import clsx from 'clsx';
1312

1413
import { Title } from '../layout';
1514
import { CreateProps } from './Create';
1615

17-
export const CreateView = (inProps: CreateViewProps) => {
18-
const props = useThemeProps({
19-
props: inProps,
20-
name: PREFIX,
21-
});
16+
export const CreateView = (props: CreateViewProps) => {
2217
const {
2318
actions,
2419
aside,

packages/ra-ui-materialui/src/detail/Edit.stories.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,13 @@ export const Themed = () => (
375375
defaultProps: {
376376
className: 'custom-class',
377377
},
378+
styleOverrides: {
379+
root: {
380+
['& .RaEdit-card']: {
381+
color: 'red',
382+
},
383+
},
384+
},
378385
},
379386
},
380387
} as ThemeOptions)}

packages/ra-ui-materialui/src/detail/EditView.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
styled,
88
type SxProps,
99
type Theme,
10-
useThemeProps,
1110
} from '@mui/material';
1211
import clsx from 'clsx';
1312
import { useEditContext, useResourceDefinition } from 'ra-core';
@@ -18,11 +17,7 @@ import { EditProps } from './Edit';
1817

1918
const defaultActions = <EditActions />;
2019

21-
export const EditView = (inProps: EditViewProps) => {
22-
const props = useThemeProps({
23-
props: inProps,
24-
name: PREFIX,
25-
});
20+
export const EditView = (props: EditViewProps) => {
2621
const {
2722
actions,
2823
aside,

packages/ra-ui-materialui/src/detail/Show.stories.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,13 @@ export const Themed = () => (
258258
defaultProps: {
259259
className: 'custom-class',
260260
},
261+
styleOverrides: {
262+
root: {
263+
['& .RaShow-card']: {
264+
color: 'red',
265+
},
266+
},
267+
},
261268
},
262269
},
263270
} as ThemeOptions)}

packages/ra-ui-materialui/src/detail/ShowView.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
styled,
77
type SxProps,
88
type Theme,
9-
useThemeProps,
109
} from '@mui/material';
1110
import clsx from 'clsx';
1211
import { useShowContext, useResourceDefinition } from 'ra-core';
@@ -16,11 +15,7 @@ import { ShowProps } from './Show';
1615

1716
const defaultActions = <ShowActions />;
1817

19-
export const ShowView = (inProps: ShowViewProps) => {
20-
const props = useThemeProps({
21-
props: inProps,
22-
name: PREFIX,
23-
});
18+
export const ShowView = (props: ShowViewProps) => {
2419
const {
2520
actions,
2621
aside,

packages/ra-ui-materialui/src/list/InfiniteList.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22
import expect from 'expect';
33
import { render, screen } from '@testing-library/react';
44

5-
import { Themed } from './List.stories';
5+
import { Themed } from './InfiniteList.stories';
66

77
describe('<InfiniteList />', () => {
88
it('should be customized by a theme', async () => {

packages/ra-ui-materialui/src/list/InfiniteList.stories.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,18 @@ export const Themed = () => (
452452
perPage: 5,
453453
},
454454
},
455+
RaList: {
456+
styleOverrides: {
457+
root: {
458+
background: 'pink',
459+
460+
['& .MuiListItemText-primary']: {
461+
color: 'hotpink',
462+
fontWeight: 'bold',
463+
},
464+
},
465+
},
466+
},
455467
},
456468
} as ThemeOptions)}
457469
>

packages/ra-ui-materialui/src/list/ListView.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
styled,
55
type SxProps,
66
type Theme,
7-
useThemeProps,
87
} from '@mui/material/styles';
98
import type { ReactElement, ReactNode, ElementType } from 'react';
109
import Card from '@mui/material/Card';
@@ -24,12 +23,8 @@ const defaultEmpty = <Empty />;
2423
const DefaultComponent = Card;
2524

2625
export const ListView = <RecordType extends RaRecord = any>(
27-
inProps: ListViewProps
26+
props: ListViewProps
2827
) => {
29-
const props = useThemeProps({
30-
props: inProps,
31-
name: PREFIX,
32-
});
3328
const {
3429
actions = defaultActions,
3530
aside,

0 commit comments

Comments
 (0)