Skip to content

Commit

Permalink
feat(Thumbnail): if label is empty string and no onRename given, hide…
Browse files Browse the repository at this point in the history
… thumbnail label
  • Loading branch information
liamross committed May 27, 2020
1 parent 77c0c0e commit 04b791e
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/components/Thumbnail/Thumbnail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export interface ThumbnailProps<F> extends ClickableDivProps {
*/
file: F;
/**
* Optional label. Will use file name if not provided.
* Optional label. Will fallback to file name if not provided. To remove label
* you can set `label` to an empty string.
*/
label?: string;
/**
Expand Down Expand Up @@ -147,16 +148,18 @@ export function Thumbnail<F extends FileLike>({
))}
</div>
{selectedIcon ? <div className="ui__thumbnail__selectedIcon">{selectedIcon}</div> : undefined}
<EditableText
className="ui__thumbnail__label"
value={label ?? name}
centerText
disabled={disabled}
locked={!onRename || otherDragging}
onSave={handleOnSave}
onCancel={handleOnCancel}
onEdit={handleOnEdit}
/>
{(label ?? name) || onRename ? (
<EditableText
className="ui__thumbnail__label"
value={label ?? name}
centerText
disabled={disabled}
locked={!onRename || otherDragging}
onSave={handleOnSave}
onCancel={handleOnCancel}
onEdit={handleOnEdit}
/>
) : undefined}
</ClickableDiv>
);
}

0 comments on commit 04b791e

Please sign in to comment.