Skip to content

Commit

Permalink
chore: update Loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Wxh16144 committed Mar 3, 2023
1 parent 021ae1a commit 173ae53
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/client/theme-default/slots/Loading/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { usePrefersColor } from 'dumi';
import React from 'react';
import type { SkeletonProps } from 'react-loading-skeleton';
import type { SkeletonProps, SkeletonThemeProps } from 'react-loading-skeleton';
import Skeleton, { SkeletonTheme } from 'react-loading-skeleton';
import 'react-loading-skeleton/dist/skeleton.css';
import './index.less';
Expand Down Expand Up @@ -42,9 +43,29 @@ const DemoBlockSkeleton = ({ children }: React.PropsWithChildren) => (
);

const Loading: React.FC = () => {
const [currentPrefersColor] = usePrefersColor();

const skeletonThemeProps = React.useMemo<SkeletonThemeProps>(() => {
// light use default color
let baseColor = undefined;
let highlightColor = undefined;

if (currentPrefersColor === 'dark') {
baseColor = '#1f1f1f';
highlightColor = 'rgba(255, 255, 255, 0.12)';
}

return {
baseColor,
highlightColor,
// TODO: direction support
direction: 'ltr',
};
}, [currentPrefersColor]);

return (
<div className="dumi-default-loading-skeleton">
<SkeletonTheme>
<SkeletonTheme {...skeletonThemeProps}>
<TitleSkeleton />
<DescriptionSkeleton />
<DemoBlockSkeleton>
Expand Down

0 comments on commit 173ae53

Please sign in to comment.