Skip to content

Commit 30af6da

Browse files
committed
add a story for <DeleteButton>
1 parent 671623a commit 30af6da

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import * as React from 'react';
2+
import { createTheme } from '@mui/material';
3+
import type { PaletteColor } from '@mui/material';
4+
import { DeleteButton } from './DeleteButton';
5+
import { Form } from 'ra-core';
6+
import { AdminContext } from '../AdminContext';
7+
8+
export default { title: 'ra-ui-materialui/button/DeleteButton' };
9+
10+
export const Basic = () => (
11+
<AdminContext>
12+
<Form record={{ id: 1 }}>
13+
<DeleteButton label="Delete" />
14+
</Form>
15+
</AdminContext>
16+
);
17+
18+
export const WithUserDefinedPalette = () => (
19+
<AdminContext theme={theme}>
20+
<Form record={{ id: 1 }}>
21+
<DeleteButton label="Delete" />
22+
</Form>
23+
</AdminContext>
24+
);
25+
26+
/**
27+
* Adding new theme tokens to the palette
28+
* @see https://mui.com/material-ui/experimental-api/css-theme-variables/customization/#typescript
29+
*/
30+
const theme = createTheme({
31+
palette: {
32+
error: {
33+
main: '#FDDBD3',
34+
},
35+
},
36+
});
37+
38+
declare module '@mui/material/styles' {
39+
interface Palette {
40+
userDefined?: PaletteColor;
41+
}
42+
interface PaletteOptions {
43+
userDefined?: PaletteColor;
44+
}
45+
}
46+
47+
/**
48+
* Adding new theme tokens to the Button
49+
* https://mui.com/material-ui/customization/theme-components/#creating-new-component-variants
50+
*/
51+
declare module '@mui/material/Button' {
52+
interface ButtonPropsColorOverrides {
53+
userDefined: true;
54+
}
55+
}

0 commit comments

Comments
 (0)