Expose size for primary repository avatar extension point

This commit is contained in:
Eduard Heimbuch
2023-01-31 11:00:21 +01:00
parent 63d6c765ea
commit 3730434f7b
3 changed files with 6 additions and 3 deletions

View File

@@ -0,0 +1,2 @@
- type: fixed
description: Avatar size must not leave boundaries

View File

@@ -36,12 +36,13 @@ type Props = {
size?: 16 | 24 | 32 | 48 | 64 | 96 | 128; size?: 16 | 24 | 32 | 48 | 64 | 96 | 128;
}; };
const renderExtensionPoint = (repository: Repository) => { const renderExtensionPoint = (repository: Repository, size: Props["size"]) => {
return ( return (
<ExtensionPoint<extensionPoints.PrimaryRepositoryAvatar> <ExtensionPoint<extensionPoints.PrimaryRepositoryAvatar>
name="repos.repository-avatar.primary" name="repos.repository-avatar.primary"
props={{ props={{
repository, repository,
size: size || 64
}} }}
> >
<ExtensionPoint<extensionPoints.RepositoryAvatar> <ExtensionPoint<extensionPoints.RepositoryAvatar>
@@ -57,7 +58,7 @@ const renderExtensionPoint = (repository: Repository) => {
}; };
const RepositoryAvatar: FC<Props> = ({ repository, size = 64 }) => { const RepositoryAvatar: FC<Props> = ({ repository, size = 64 }) => {
return <Avatar className={`image is-${size}x${size}`}>{renderExtensionPoint(repository)}</Avatar>; return <Avatar className={`image is-${size}x${size}`}>{renderExtensionPoint(repository, size)}</Avatar>;
}; };
export default RepositoryAvatar; export default RepositoryAvatar;

View File

@@ -433,7 +433,7 @@ export type RepositoryAvatar = RenderableExtensionPointDefinition<
*/ */
export type PrimaryRepositoryAvatar = RenderableExtensionPointDefinition< export type PrimaryRepositoryAvatar = RenderableExtensionPointDefinition<
"repos.repository-avatar.primary", "repos.repository-avatar.primary",
{ repository: Repository } { repository: Repository, size: number }
>; >;
/** /**