Files
frontend/src/shared/ui/Spinner/Spinner.tsx
2026-06-29 19:22:24 +03:00

35 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import styles from './Spinner.module.css'
type SpinnerSize = 'sm' | 'md' | 'lg'
interface Props {
/** Размер спиннера. По умолчанию `md`. */
size?: SpinnerSize
/** Подпись под спиннером. */
label?: string
/** Растянуть на всю высоту контейнера и отцентрировать содержимое. */
fullscreen?: boolean
/** Зафиксировать поверх всего экрана с подложкой (для загрузки на весь вьюпорт). */
overlay?: boolean
className?: string
}
export function Spinner({ size = 'md', label, fullscreen, overlay, className }: Props) {
const wrapClass = [
styles.wrap,
fullscreen ? styles.fullscreen : '',
overlay ? styles.overlay : '',
className ?? '',
]
.filter(Boolean)
.join(' ')
return (
<div className={wrapClass} role="status" aria-live="polite" aria-busy="true">
<span className={`${styles.spinner} ${styles[size]}`} aria-hidden="true" />
{label ? <span className={styles.label}>{label}</span> : null}
<span className={styles.srOnly}>{label ?? 'Загрузка'}</span>
</div>
)
}