diff --git a/src/components/ui/Skeleton.tsx b/src/components/ui/Skeleton.tsx index 25efe089..dc57dc81 100644 --- a/src/components/ui/Skeleton.tsx +++ b/src/components/ui/Skeleton.tsx @@ -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'; @@ -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; } @@ -24,6 +26,7 @@ export const Skeleton: React.FC = ({ height, borderRadius = 8, circle = false, + isDark = false, style, }) => { const pulseAnim = useRef(new Animated.Value(0.3)).current; @@ -53,7 +56,7 @@ export const Skeleton: React.FC = ({ width: width, height: height, borderRadius: circle ? (typeof height === 'number' ? height / 2 : 999) : borderRadius, - backgroundColor: '#E5E7EB', + backgroundColor: isDark ? '#334155' : '#E5E7EB', opacity: pulseAnim as any, }; diff --git a/tests/components/Skeleton.test.tsx b/tests/components/Skeleton.test.tsx index dbab7a4f..b51cf794 100644 --- a/tests/components/Skeleton.test.tsx +++ b/tests/components/Skeleton.test.tsx @@ -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', () => { @@ -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 ────────────────────────────────────────────────────────