import {CSSProperties, FC} from "react";
import {View} from "@tarojs/components";
import styles from './index.module.scss'

interface LoadingProps {
  size?: string | number
  color?: string
}

const Loading: FC<LoadingProps> =  (props) => {
  const size = typeof props.size === 'string' ? props.size : `${props.size ?? 16}px`
  const color = props.color ?? 'currentColor'
  const sizeStyle: CSSProperties = {
    width: size,
    height: size,
    color
  }

  return (
    <View className={styles.loading} style={sizeStyle}>
      <View className={styles.background} />
      <View className={styles.foreground} />
    </View>
  )
}

export default Loading
