import { useTheme } from 'gloss' import React, { HTMLAttributes, memo, useRef } from 'react' import { useDefaultProps } from './hooks/useDefaultProps' import { useVisibility } from './Visibility' // https://github.com/chantastic/react-svg-spinner export type SpinnerProps = HTMLAttributes & { color?: any thickness?: number gap?: number speed?: 'fast' | 'slow' size?: string } export const Spinner = memo((directProps: SpinnerProps) => { const visibility = useVisibility() const nodeRef = useRef() // const intersection = useIntersectionObserver({ // ref: nodeRef, // }) // const isIntersecting = intersection && intersection.some(x => x.isIntersecting) const isIntersecting = false const theme = useTheme() const { color, gap, thickness, size, speed, ...rest } = useDefaultProps( { color: theme.color, gap: 4, thickness: 4, size: '1em', speed: 'slow', }, directProps, ) if (!visibility) { return null } return ( Circle loading spinner Image of a partial circle indicating "loading." ) }) function speedSwitch(speed) { if (speed === 'fast') return 600 if (speed === 'slow') return 900 return 750 } // attempt to reduce gpu usage but something else is going on // while this spinner is based on: https://projects.lukehaas.me/css-loaders/ // which runs at 5% cpu usage on my computer // running the same thing in orbit is 65% cpu usage, so must be due to nesting, inline css, something else.... // import { Base, Box, gloss, useTheme } from 'gloss' // import React, { memo } from 'react' // export type SpinnerProps = { // size?: number // color?: any // } // export const Spinner = memo(({ color, size }: SpinnerProps) => { // const theme = useTheme() // return ( // // // // //