Skip to content

Commit 8918209

Browse files
committed
use Translate component and pass delay to story
1 parent 64eedd5 commit 8918209

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/components/admin/loading.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useTimeout, useTranslate } from "ra-core";
1+
import { Translate, useTimeout } from "ra-core";
22
import { Spinner } from "./spinner";
33

44
export const Loading = (props: LoadingProps) => {
@@ -9,7 +9,6 @@ export const Loading = (props: LoadingProps) => {
99
...rest
1010
} = props;
1111
const oneSecondHasPassed = useTimeout(delay);
12-
const translate = useTranslate();
1312
return oneSecondHasPassed ? (
1413
<div
1514
className={"flex flex-col justify-center items-center h-full"}
@@ -18,10 +17,10 @@ export const Loading = (props: LoadingProps) => {
1817
<div className={"text-center font-sans color-muted pt-1 pb-1"}>
1918
<Spinner size="large" className="width-9 height-9" />
2019
<h5 className="mt-3 text-2xl text-secondary-foreground">
21-
{translate(loadingPrimary, { _: loadingPrimary })}
20+
<Translate i18nKey={loadingPrimary}>{loadingPrimary}</Translate>
2221
</h5>
2322
<p className="text-primary">
24-
{translate(loadingSecondary, { _: loadingSecondary })}
23+
<Translate i18nKey={loadingSecondary}>{loadingSecondary}</Translate>
2524
</p>
2625
</div>
2726
</div>

src/stories/loading.stories.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,15 @@ const StoryWrapper = ({
2525

2626
const i18nProvider = polyglotI18nProvider(() => englishMessages, "en");
2727

28-
export const Basic = ({ theme }: { theme: "system" | "light" | "dark" }) => (
28+
export const Basic = ({
29+
theme,
30+
delay,
31+
}: {
32+
theme: "system" | "light" | "dark";
33+
delay?: number;
34+
}) => (
2935
<StoryWrapper theme={theme}>
30-
<Loading />
36+
<Loading delay={delay} />
3137
</StoryWrapper>
3238
);
3339

@@ -46,11 +52,17 @@ Basic.argTypes = {
4652
},
4753
};
4854

49-
export const I18N = ({ theme }: { theme: "system" | "light" | "dark" }) => {
55+
export const I18N = ({
56+
theme,
57+
delay,
58+
}: {
59+
theme: "system" | "light" | "dark";
60+
delay?: number;
61+
}) => {
5062
return (
5163
<StoryWrapper theme={theme}>
5264
<I18nContextProvider value={i18nProvider}>
53-
<Loading />
65+
<Loading delay={delay} />
5466
</I18nContextProvider>
5567
</StoryWrapper>
5668
);

0 commit comments

Comments
 (0)