Skip to content

Commit 5fbd69d

Browse files
committed
chore: add comments for EditImageFormField
1 parent c597ec8 commit 5fbd69d

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

src/Shared/Components/EditImageFormField/EditImageFormField.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ const FallbackImage = ({ showEditIcon, defaultIcon }: FallbackImageProps) => (
2323
)
2424

2525
// NOTE: Have to replace component in UpsertTenantModal with EditImageFormField when prioritized.
26+
/**
27+
* @example
28+
* ```tsx
29+
* <EditImageFormField
30+
* url={icon}
31+
* defaultIcon={<ICSampleIcon className="w-100 h-100 dc__opacity-1 p-5" />}
32+
* errorMessage={formError.icon}
33+
* handleError={handleError}
34+
* handleURLChange={handleURLChange}
35+
* ariaLabelPrefix="Edit icon url"
36+
* dataTestIdPrefix="edit-icon-url"
37+
* altText="Form icon"
38+
* />
39+
* ```
40+
*/
2641
const EditImageFormField = ({
2742
defaultIcon,
2843
errorMessage,
Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,42 @@
11
import { ReactNode } from 'react'
22

33
export interface EditImageFormFieldProps {
4+
/**
5+
* Fallback icon to be shown when image is not available
6+
*/
47
defaultIcon: ReactNode
8+
/**
9+
* Would be shown below input, there are two types of error messages:
10+
* External - Error message handled from state above and would propagate to parent through handleError
11+
* Internal - Error message handled internally and would not propagate to parent, like empty preview URL
12+
*/
513
errorMessage: string
14+
/**
15+
* Would be called when there is an error in the image URL during handleChange or handlePreviewImage
16+
*/
617
handleError: (error: string) => void
18+
/**
19+
* The current value of input field
20+
*/
721
url: string
22+
/**
23+
* Would be called when the URL is changed in the input field
24+
*/
825
handleURLChange: (url: string) => void
26+
/**
27+
* The alt text for the image
28+
*/
929
altText: string
30+
/**
31+
* Prefix for aria-label
32+
*/
1033
ariaLabelPrefix: string
34+
/**
35+
* Prefix for data-testid
36+
*/
1137
dataTestIdPrefix: string
1238
}
1339

1440
export interface FallbackImageProps extends Pick<EditImageFormFieldProps, 'defaultIcon'> {
15-
/**
16-
* @default - false
17-
*/
18-
showEditIcon?: boolean
41+
showEditIcon: boolean
1942
}

0 commit comments

Comments
 (0)