Skip to content

Commit

Permalink
Show ImageInput label by default
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-baer committed Sep 9, 2024
1 parent c7c2a10 commit c0ee224
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/hip-spies-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sumup-oss/circuit-ui': major
---

Made the ImageInput's label visible by default for consistency with other inputs. Use the new `hideLabel` prop to visually hide the label.
22 changes: 21 additions & 1 deletion packages/circuit-ui/components/ImageInput/ImageInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
FieldWrapper,
FieldLabel,
FieldValidationHint,
FieldLabelText,
} from '../Field/index.js';
import { IconButton } from '../Button/index.js';
import { Spinner } from '../Spinner/index.js';
Expand Down Expand Up @@ -89,6 +90,16 @@ export interface ImageInputProps
* An information or error message, displayed below the input.
*/
validationHint?: string;
/**
* Label to indicate that the input is optional. Only displayed when the
* `required` prop is falsy.
*/
optionalLabel?: string;
/**
* Visually hide the label. This should only be used in rare cases and only
* if the purpose of the field can be inferred from other context.
*/
hideLabel?: boolean;
}

/**
Expand All @@ -103,8 +114,11 @@ export const ImageInput = ({
onClear,
disabled,
validationHint,
required,
invalid = false,
loadingLabel,
optionalLabel,
hideLabel,
'component': Component,
className,
style,
Expand Down Expand Up @@ -240,6 +254,7 @@ export const ImageInput = ({
accept="image/*"
onChange={handleInputChange}
onClick={handleClick}
required={required}
disabled={disabled || isLoading}
aria-invalid={invalid && 'true'}
aria-describedby={descriptionIds}
Expand All @@ -257,7 +272,12 @@ export const ImageInput = ({
isDragging && classes.dragging,
)}
>
<span className={utilClasses.hideVisually}>{label}</span>
<FieldLabelText
label={label}
hideLabel={hideLabel}
required={required}
optionalLabel={optionalLabel}
/>
<Component src={src || previewImage} aria-hidden="true" />
</FieldLabel>
{src ? (
Expand Down

0 comments on commit c0ee224

Please sign in to comment.