Skip to content

Commit

Permalink
object fit
Browse files Browse the repository at this point in the history
  • Loading branch information
hassanad94 committed Sep 4, 2023
1 parent 08454de commit 78bc525
Showing 1 changed file with 28 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,40 @@ export const ReferencePicker: React.FC<ReferencePickerProps<GenericContentWithIs
return isFolder ? 'folder' : 'insert_drive_file'
}

const renderIcon = (item: GenericContentWithIsParent) =>
props.repository.schemas.isContentFromType<User>(item, 'User') ? (
(item as User).Avatar?.Url ? (
<Avatar
alt={item.DisplayName}
src={`${props.repository.configuration.repositoryUrl}${(item as User).Avatar!.Url}`}
/>
) : (
const renderIcon = (item: GenericContentWithIsParent | User | Image) => {
console.log('item', item)

if (props.repository.schemas.isContentFromType<User>(item, 'User')) {
const avatarUrl = item.Avatar?.Url
if (avatarUrl) {
return <Avatar alt={item.DisplayName} src={`${props.repository.configuration.repositoryUrl}${avatarUrl}`} />

Check warning on line 56 in packages/sn-controls-react/src/fieldcontrols/reference-grid/reference-picker.tsx

View check run for this annotation

Codecov / codecov/patch

packages/sn-controls-react/src/fieldcontrols/reference-grid/reference-picker.tsx#L56

Added line #L56 was not covered by tests
}

return (
<Avatar alt={item.DisplayName}>
{item.DisplayName?.split(' ')
.map((namePart) => namePart[0])
.join('.')}
</Avatar>
)
) : props.repository.schemas.isContentFromType<Image>(item, 'Image') ? (
<img
alt=""
src={`${props.repository.configuration.repositoryUrl}${(item as Image).Path}`}
style={{ width: '3em', height: '3em' }}
/>
) : props.renderIcon ? (
props.renderIcon(item)
) : (
renderIconDefault(iconName(item.IsFolder))
)
}

if (props.repository.schemas.isContentFromType<Image>(item, 'Image')) {
return (

Check warning on line 69 in packages/sn-controls-react/src/fieldcontrols/reference-grid/reference-picker.tsx

View check run for this annotation

Codecov / codecov/patch

packages/sn-controls-react/src/fieldcontrols/reference-grid/reference-picker.tsx#L68-L69

Added lines #L68 - L69 were not covered by tests
<img
alt=""
src={`${props.repository.configuration.repositoryUrl}${item.Path}`}
style={{ width: '3em', height: '3em', objectFit: 'scale-down' }}
/>
)
}

if (props.renderIcon) {
return props.renderIcon(item)

Check warning on line 79 in packages/sn-controls-react/src/fieldcontrols/reference-grid/reference-picker.tsx

View check run for this annotation

Codecov / codecov/patch

packages/sn-controls-react/src/fieldcontrols/reference-grid/reference-picker.tsx#L78-L79

Added lines #L78 - L79 were not covered by tests
}

return renderIconDefault(iconName(item.IsFolder))

Check warning on line 82 in packages/sn-controls-react/src/fieldcontrols/reference-grid/reference-picker.tsx

View check run for this annotation

Codecov / codecov/patch

packages/sn-controls-react/src/fieldcontrols/reference-grid/reference-picker.tsx#L82

Added line #L82 was not covered by tests
}

return (
<Picker
Expand Down

0 comments on commit 78bc525

Please sign in to comment.