Skip to content

Commit

Permalink
Update ImageInput component prop types (#2067)
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-baer committed Apr 27, 2023
1 parent 06faaae commit 4f78573
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/khaki-baboons-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sumup/circuit-ui': major
---

Changed the signature of the ImageInput's `component` prop. The `component` should now accept `aria-hidden` instead of `alt`.
9 changes: 5 additions & 4 deletions packages/circuit-ui/components/ImageInput/ImageInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ export interface ImageInputProps
*/
label: string;
/**
* The visual component to render as an image input. It should accept an src
* prop to render the image.
* The visual component to render as an image input.
* It should accept a `src` prop to render the image, and `aria-hidden` to
* hide it from assistive technology.
*/
component: (props: { src?: string; alt: string }) => JSX.Element;
component: (props: { 'src'?: string; 'aria-hidden': 'true' }) => JSX.Element;
/**
* A callback function to call when the user has selected an image.
*/
Expand Down Expand Up @@ -458,7 +459,7 @@ export const ImageInput = ({
onDrop={handleDrop}
>
<span css={hideVisually()}>{label}</span>
<Component src={src || previewImage} alt="" />
<Component src={src || previewImage} aria-hidden="true" />
</Label>
{src ? (
<ActionButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,7 @@ exports[`ImageInput > Styles > should render with an existing image 1`] = `
</span>
<img
alt=""
aria-hidden="true"
class="circuit-5"
src="/images/illustration-coffee.jpg"
/>
Expand Down

0 comments on commit 4f78573

Please sign in to comment.