# All files / src/Spinner Spinner.tsx

100% Statements 17/17
50% Branches 1/2
100% Functions 1/1
100% Lines 16/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    402x
    2x
    2x
    2x

    2x

    2x

    2x

    2x

    4x

    4x
    4x

    4x

    2x

    2x

    2x

    2x
     import * as React from 'react'
    import classNames from 'classnames'
    import { createUseStyles } from '@fluent-ui/styles'
    import { styles } from './Spinner.styled'
    import { Theme } from '../styles'
    import { SpinnerClassProps, SpinnerProps, SpinnerPropTypes } from './Spinner.type'

    export const name = 'Spinner'

    const useStyles = createUseStyles<Theme, SpinnerClassProps>(styles, { name })

    const Spinner: React.FC<SpinnerProps> = React.forwardRef<HTMLDivElement, SpinnerProps>(
      (props, ref): React.ReactElement => {
        const { as: Component = 'span', className: classNameProp, size = 'medium', ...rest } = props

        const classes = useStyles(props)
        const className = classNames(
          classes.root,
          {
            [classes.sizeSmall]: size === 'small',
            [classes.sizeMedium]: size === 'medium',
            [classes.sizeLarge]: size === 'large'
          },
          classNameProp
        )

        return <Component className={className} ref={ref} {...rest} />
      }
    )

    Spinner.displayName = `F${name}`

    Spinner.propTypes = SpinnerPropTypes

    Spinner.defaultProps = {
      size: 'medium'
    }

    export default Spinner