import { View } from '@tarojs/components'
import { memo, useMemo } from 'react'
import style from './index.module.scss'

const Loading = ({ width = 60, color = '#6190e8' }: { width?: number; color?: string }) => {
  const styleObj = useMemo(() => {
    let obj = {}
    if (width > 0) { obj = { width: `${width}rpx`, height: `${width}rpx` } }
    if (color) { obj = { ...obj, borderColor: `${color} transparent transparent` } }
    return obj
  }, [width, color])
  return (
    <View className={style.loading}
      style={styleObj}
    >
      <View style={styleObj} className={style.loading__ring}></View>
      <View style={styleObj} className={style.loading__ring}></View>
      <View style={styleObj} className={style.loading__ring}></View>
    </View>
  )
}
export default memo(Loading)
