Fix Avatar types to follow OwnProps pattern

Make AvatarOwnProps the source of truth with inline type definitions,
and have AvatarProps extend it. This follows the established pattern
used by Button, Checkbox, and Alert components. Export AvatarOwnProps
from the package entry point.

Signed-off-by: Johan Persson <johanopersson@gmail.com>
This commit is contained in:
Johan Persson
2026-02-24 11:18:36 +01:00
parent c286160632
commit 9df65dae02
5 changed files with 140 additions and 18 deletions
+16 -5
View File
@@ -281,12 +281,23 @@ export const AvatarDefinition: {
};
// @public (undocumented)
export interface AvatarProps extends React.ComponentPropsWithoutRef<'div'> {
name: string;
purpose?: 'decoration' | 'informative';
size?: 'x-small' | 'small' | 'medium' | 'large' | 'x-large';
export type AvatarOwnProps = {
src: string;
}
name: string;
size?: 'x-small' | 'small' | 'medium' | 'large' | 'x-large';
purpose?: 'decoration' | 'informative';
children?: React.ReactNode;
className?: string;
style?: React.CSSProperties;
};
// @public (undocumented)
export interface AvatarProps
extends Omit<
React.ComponentPropsWithoutRef<'div'>,
'children' | 'className' | 'style'
>,
AvatarOwnProps {}
// @public (undocumented)
export interface BgContextValue {
+1 -1
View File
@@ -16,4 +16,4 @@
export { Avatar } from './Avatar';
export { AvatarDefinition } from './definition';
export type { AvatarProps } from './types';
export type { AvatarOwnProps, AvatarProps } from './types';
+13 -12
View File
@@ -16,17 +16,6 @@
/** @public */
export type AvatarOwnProps = {
size?: AvatarProps['size'];
purpose?: AvatarProps['purpose'];
src: string;
name: string;
children?: React.ReactNode;
className?: string;
style?: React.CSSProperties;
};
/** @public */
export interface AvatarProps extends React.ComponentPropsWithoutRef<'div'> {
/**
* URL of the image to display
*/
@@ -50,4 +39,16 @@ export interface AvatarProps extends React.ComponentPropsWithoutRef<'div'> {
* @defaultValue 'informative'
*/
purpose?: 'decoration' | 'informative';
}
children?: React.ReactNode;
className?: string;
style?: React.CSSProperties;
};
/** @public */
export interface AvatarProps
extends Omit<
React.ComponentPropsWithoutRef<'div'>,
'children' | 'className' | 'style'
>,
AvatarOwnProps {}