Skip to content

Commit

Permalink
fix(react19): Remove default props from Placeholder (#83453)
Browse files Browse the repository at this point in the history
  • Loading branch information
scttcper authored Jan 15, 2025
1 parent ed40fe0 commit c97ace3
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions static/app/components/placeholder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@ export interface PlaceholderProps {
width?: string;
}

const defaultProps = {
shape: 'rect',
bottomGutter: 0 as Parameters<typeof space>[0],
width: '100%',
height: '60px',
testId: 'loading-placeholder',
} satisfies Partial<PlaceholderProps>;

const Placeholder = styled(
({className, children, error, testId, style}: PlaceholderProps) => {
({
className,
children,
error,
testId = 'loading-placeholder',
style,
}: PlaceholderProps) => {
return (
<div data-test-id={testId} className={className} style={style}>
{error || children}
Expand All @@ -41,15 +39,13 @@ const Placeholder = styled(
background-color: ${p => (p.error ? p.theme.red100 : p.theme.backgroundTertiary)};
${p => p.error && `color: ${p.theme.red200};`}
width: ${p => p.width};
height: ${p => p.height};
${p => (p.shape === 'circle' ? 'border-radius: 100%;' : '')}
${p =>
typeof p.bottomGutter === 'number' && p.bottomGutter > 0
? `margin-bottom: ${space(p.bottomGutter)};`
width: ${p => p.width ?? '100%'};
height: ${p => p.height ?? '60px'};
${({shape = 'rect'}) => (shape === 'circle' ? 'border-radius: 100%;' : '')}
${({bottomGutter = 0}) =>
typeof bottomGutter === 'number' && bottomGutter > 0
? `margin-bottom: ${space(bottomGutter as Parameters<typeof space>[0])};`
: ''}
`;

Placeholder.defaultProps = defaultProps;

export default Placeholder;

0 comments on commit c97ace3

Please sign in to comment.