import React from 'react'; import { skeletonStyle, skeletonTextStyle } from './styles'; import type { VariantProps } from '@gluestack-ui/nativewind-utils'; type ISkeletonProps = React.ComponentPropsWithoutRef<'div'> & VariantProps & { startColor?: string; isLoaded?: boolean; }; const Skeleton = React.forwardRef( function Skeleton( { className, variant = 'rounded', children, speed = 2, startColor = 'bg-background-200', isLoaded = false, ...props }, ref ) { if (!isLoaded) { return (
); } else { return children; } } ); type ISkeletonTextProps = React.ComponentPropsWithoutRef<'div'> & VariantProps & { _lines?: number; isLoaded?: boolean; startColor?: string; }; const SkeletonText = React.forwardRef( function SkeletonText( { className, _lines, isLoaded = false, startColor = 'bg-background-200', gap = 2, children, ...props }, ref ) { if (!isLoaded) { if (_lines) { return (
{Array.from({ length: _lines }).map((_, index) => (
))}
); } else { return (
); } } else { return children; } } ); Skeleton.displayName = 'Skeleton'; SkeletonText.displayName = 'SkeletonText'; export { Skeleton, SkeletonText };