Skip to content

Commit d85c986

Browse files
author
Moritz Gramlich
committed
refactor and update documentation
1 parent e5e2779 commit d85c986

3 files changed

Lines changed: 20 additions & 7 deletions

File tree

docs/FileInput.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Files are accepted or rejected based on the `accept`, `multiple`, `minSize` and
6262
| `multiple` | Optional | `boolean` | `false` | Whether the inputs can accept multiple files. |
6363
| `options` | Optional | `Object` | `{}` | Additional options passed to react-dropzone's `useDropzone()` hook. |
6464
| `placeholder` | Optional | `ReactNode` | - | Invite displayed in the drop zone |
65+
| `removeIcon` | Optional | `ReactNode` | - | The clickable icon for removing images |
6566
| `validateFile Removal` | Optional | `function` | - | Allows to cancel the removal of files |
6667

6768
`<FileInput>` also accepts the [common input props](./Inputs.md#common-input-props).
@@ -152,6 +153,10 @@ If that's not enough, you can pass a `placeholder` prop to overwrite it. The val
152153
</FileInput>
153154
```
154155

156+
## `removeIcon`
157+
158+
Optionally overwrite the [default icon](https://mui.com/material-ui/material-icons/?query=removeCir&selected=RemoveCircle) for removing files.
159+
155160
## `sx`: CSS API
156161

157162
The `<FileInput>` component accepts the usual `className` prop. You can also override many styles of the inner components thanks to the `sx` property (as most MUI components, see their [documentation about it](https://mui.com/customization/how-to-customize/#overriding-nested-component-styles)). This property accepts the following subclasses:

docs/ImageInput.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,14 @@ Files are accepted or rejected based on the `accept`, `multiple`, `minSize` and
5353

5454
| Prop | Required | Type | Default | Description |
5555
|------------------------|----------|---------------------|------------|---------------------------------------------------------------------|
56-
| `accept` | Optional | `string | string[]` | - | Accepted file type(s). When empty, all file types are accepted. |
56+
| `accept` | Optional | `string | string[]` | - | Accepted file type(s). When empty, all file types are accepted. |
5757
| `children` | Optional | `ReactNode` | - | Element used to preview file(s) |
5858
| `minSize` | Optional | `number` | 0 | Minimum file size (in bytes), e.g. 5000 for 5KB |
5959
| `maxSize` | Optional | `number` | `Infinity` | Maximum file size (in bytes), e.g. 5000000 for 5MB |
6060
| `multiple` | Optional | `boolean` | `false` | Whether the inputs can accept multiple files. |
6161
| `options` | Optional | `Object` | `{}` | Additional options passed to react-dropzone's `useDropzone()` hook. |
6262
| `placeholder` | Optional | `ReactNode` | - | Invite displayed in the drop zone |
63+
| `removeIcon` | Optional | `ReactNode` | - | The clickable icon for removing images |
6364
| `validateFile Removal` | Optional | `function` | - | Allows to cancel the removal of files |
6465

6566
`<ImageInput>` also accepts the [common input props](./Inputs.md#common-input-props).
@@ -149,6 +150,10 @@ If that's not enough, you can pass a `placeholder` prop to overwrite it. The val
149150
</ImageInput>
150151
```
151152

153+
## `removeIcon`
154+
155+
Optionally overwrite the [default icon](https://mui.com/material-ui/material-icons/?query=removeCir&selected=RemoveCircle) for removing images.
156+
152157
## `sx`: CSS API
153158

154159
The `<ImageInput>` component accepts the usual `className` prop. You can also override many styles of the inner components thanks to the `sx` property (as most MUI components, see their [documentation about it](https://mui.com/customization/how-to-customize/#overriding-nested-component-styles)). This property accepts the following subclasses:

packages/ra-ui-materialui/src/input/FileInputPreview.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@ import { useTranslate } from 'ra-core';
88
import { SvgIconProps } from '@mui/material';
99

1010
export const FileInputPreview = (props: FileInputPreviewProps) => {
11-
const { children, className, onRemove, file, removeIcon, ...rest } = props;
11+
const {
12+
children,
13+
className,
14+
onRemove,
15+
file,
16+
removeIcon = RemoveCircle,
17+
...rest
18+
} = props;
1219

1320
const translate = useTranslate();
1421

@@ -31,11 +38,7 @@ export const FileInputPreview = (props: FileInputPreviewProps) => {
3138
title={translate('ra.action.delete')}
3239
size="small"
3340
>
34-
{removeIcon ?? (
35-
<RemoveCircle
36-
className={FileInputPreviewClasses.removeIcon}
37-
/>
38-
)}
41+
{removeIcon}
3942
</IconButton>
4043
{children}
4144
</Root>

0 commit comments

Comments
 (0)