Skip to content

Commit

Permalink
refactor(upload card): refactors label and button logic
Browse files Browse the repository at this point in the history
  • Loading branch information
anechol committed Sep 19, 2023
1 parent 74ac197 commit 31f5f3d
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions packages/sage-react/lib/UploadCard/UploadCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,23 @@ export const UploadCard = ({
);

const renderLabel = () => {
if ((selectionLabel || replaceLabel) && !customFileInputField) {
return (
<>
<label htmlFor={id} className="sage-upload-card__input-label sage-btn sage-btn--secondary">{selectionLabel || replaceLabel}</label>
</>
);
}

if (actions) {
if (!customFileInputField) {
return (
<label htmlFor={id} className="visually-hidden">{selectionLabel || replaceLabel}</label>
);
let classnames = 'visually-hidden';
const CustomLabel = () => (
<>
<label htmlFor={id} className={classnames}>
{selectionLabel || replaceLabel}
</label>
</>
);
if ((selectionLabel || replaceLabel) && customFileInputField === false) {
classnames = 'sage-upload-card__input-label sage-btn sage-btn--secondary';
} else if (actions !== null) {
if (customFileInputField === false) {
classnames = 'visually-hidden';
}
return actions;
}
return actions;
return <CustomLabel />;
};

return (
Expand Down

0 comments on commit 31f5f3d

Please sign in to comment.