import styled from '@emotion/styled'; import {space, ValidSize} from 'sentry/styles/space'; export interface PlaceholderProps { bottomGutter?: ValidSize; children?: React.ReactNode; className?: string; error?: React.ReactNode; height?: string; shape?: 'rect' | 'circle'; testId?: string; width?: string; } const defaultProps = { shape: 'rect', bottomGutter: 0 as Parameters[0], width: '100%', height: '60px', testId: 'loading-placeholder', } satisfies Partial; const Placeholder = styled(({className, children, error, testId}: PlaceholderProps) => { return (
{error || children}
); })` display: flex; flex-direction: column; flex-shrink: 0; justify-content: center; align-items: center; background-color: ${p => (p.error ? p.theme.red100 : p.theme.backgroundSecondary)}; ${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)};` : ''} `; Placeholder.defaultProps = defaultProps; export default Placeholder;