Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/components/ui/Skeleton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useRef } from 'react';
import { Animated, DimensionValue, StyleSheet, View, ViewStyle } from 'react-native';
import { Animated, DimensionValue, View, ViewStyle } from 'react-native';

import { useAdaptiveFrameRate } from '../../hooks/useAdaptiveFrameRate';

Expand All @@ -15,6 +15,8 @@ interface SkeletonProps {
borderRadius?: number;
/** Whether to render as a circle */
circle?: boolean;
/** Whether dark mode styling is enabled */
isDark?: boolean;
/** Custom style for the skeleton */
style?: ViewStyle;
}
Expand All @@ -24,6 +26,7 @@ export const Skeleton: React.FC<SkeletonProps> = ({
height,
borderRadius = 8,
circle = false,
isDark = false,
style,
}) => {
const pulseAnim = useRef(new Animated.Value(0.3)).current;
Expand Down Expand Up @@ -53,7 +56,7 @@ export const Skeleton: React.FC<SkeletonProps> = ({
width: width,
height: height,
borderRadius: circle ? (typeof height === 'number' ? height / 2 : 999) : borderRadius,
backgroundColor: '#E5E7EB',
backgroundColor: isDark ? '#334155' : '#E5E7EB',
opacity: pulseAnim as any,
};

Expand Down
17 changes: 16 additions & 1 deletion tests/components/Skeleton.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { render, RenderAPI } from '@testing-library/react-native';
import React from 'react';

import { Skeleton, SkeletonGroup } from '../../src/components/ui/Skeleton';

describe('Skeleton', () => {
Expand Down Expand Up @@ -39,6 +40,20 @@ describe('Skeleton', () => {
const json = JSON.stringify(toJSON());
expect(json).toContain('10');
});

it('accepts isDark prop and applies dark placeholder color', () => {
const { toJSON } = renderSkeleton({ isDark: true });
const json = JSON.stringify(toJSON());
expect(json).toContain('#334155');
});

it('defaults to light placeholder color when isDark is false or omitted', () => {
const { toJSON: toJSONDefault } = renderSkeleton();
expect(JSON.stringify(toJSONDefault())).toContain('#E5E7EB');

const { toJSON: toJSONLight } = renderSkeleton({ isDark: false });
expect(JSON.stringify(toJSONLight())).toContain('#E5E7EB');
});
});

// ── Circle variant ────────────────────────────────────────────────────────
Expand Down