Skip to content

Commit 3960f71

Browse files
committed
fix(docs): add loading skeleton for installation page
Improve user experience by adding a loading skeleton while the installation page resources are being loaded. This prevents layout shift and provides visual feedback during loading. Also includes minor content updates to installation commands and test component example.
1 parent d13cb57 commit 3960f71

File tree

1 file changed

+94
-54
lines changed

1 file changed

+94
-54
lines changed

app/(site)/docs/installation/page.tsx

Lines changed: 94 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,93 @@ import { InstallationTabs } from "@/components/docs/installation-tabs";
66
import Image from "next/image";
77
import { useTheme } from "next-themes";
88

9-
export default function InstallationPage() {
10-
const [selectedPlatform, setSelectedPlatform] = React.useState("expo");
11-
const { resolvedTheme } = useTheme();
12-
const [mounted, setMounted] = React.useState(false);
13-
14-
React.useEffect(() => {
15-
setMounted(true);
16-
}, []);
9+
const InstallationPageSkeleton = () => {
10+
return (
11+
<div className="container max-w-3xl py-10 animate-pulse">
12+
{/* Header skeleton */}
13+
<div className="space-y-6">
14+
<div className="space-y-4">
15+
<div className="h-10 bg-muted rounded-md w-1/2"></div>
16+
<div className="h-6 bg-muted rounded-md w-full"></div>
17+
<div className="h-6 bg-muted rounded-md w-4/5"></div>
18+
</div>
1719

18-
if (!mounted) {
19-
return (
20-
<div className="space-y-8">
21-
<div>
22-
<h1 className="text-3xl font-bold tracking-tight">Installation</h1>
23-
<p className="text-muted-foreground text-lg mt-2">
24-
How to install dependencies and structure your app.
25-
</p>
20+
{/* Info banner skeleton */}
21+
<div className="rounded-lg border-2 p-4">
22+
<div className="flex items-center gap-3">
23+
<div className="rounded-full bg-muted p-2 w-9 h-9"></div>
24+
<div className="h-5 bg-muted rounded-md flex-1"></div>
25+
</div>
2626
</div>
27+
</div>
28+
29+
{/* Platform selection skeleton */}
30+
<div className="mt-12 space-y-8">
2731
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
28-
<div className="relative overflow-hidden rounded-lg border p-6">
32+
<div className="rounded-lg border p-6">
2933
<div className="flex flex-col items-center space-y-4">
30-
<div className="h-16 w-16 relative">
31-
<Image
32-
src={resolvedTheme === 'dark' ? "/images/expo-logo-dark.svg" : "/images/expo-logo.svg"}
33-
alt="Expo"
34-
fill
35-
className="object-contain"
36-
/>
34+
<div className="h-16 w-16 bg-muted rounded"></div>
35+
<div className="text-center space-y-2">
36+
<div className="h-6 bg-muted rounded-md w-32"></div>
37+
<div className="h-4 bg-muted rounded-md w-40"></div>
3738
</div>
38-
<div className="text-center">
39-
<h3 className="font-bold text-xl">Expo (Recommended)</h3>
40-
<p className="text-sm text-muted-foreground mt-1">
41-
Quick setup with better developer experience
42-
</p>
39+
</div>
40+
</div>
41+
<div className="rounded-lg border p-6 opacity-50">
42+
<div className="flex flex-col items-center space-y-4">
43+
<div className="h-16 w-16 bg-muted rounded"></div>
44+
<div className="text-center space-y-2">
45+
<div className="h-6 bg-muted rounded-md w-32"></div>
46+
<div className="h-4 bg-muted rounded-md w-40"></div>
4347
</div>
4448
</div>
4549
</div>
4650
</div>
51+
52+
{/* Installation steps skeleton */}
53+
<div className="space-y-8">
54+
<div className="space-y-4">
55+
<div className="h-8 bg-muted rounded-md w-1/3"></div>
56+
<div className="h-5 bg-muted rounded-md w-full"></div>
57+
<div className="h-5 bg-muted rounded-md w-3/4"></div>
58+
</div>
59+
60+
{/* Multiple step skeletons */}
61+
{Array.from({ length: 6 }).map((_, i) => (
62+
<div key={i} className="space-y-4">
63+
<div className="h-6 bg-muted rounded-md w-1/4"></div>
64+
<div className="h-4 bg-muted rounded-md w-full"></div>
65+
<div className="h-32 bg-muted rounded-md"></div>
66+
</div>
67+
))}
68+
</div>
4769
</div>
48-
);
70+
</div>
71+
);
72+
};
73+
74+
export default function InstallationPage() {
75+
const [selectedPlatform, setSelectedPlatform] = React.useState("expo");
76+
const { resolvedTheme } = useTheme();
77+
const [mounted, setMounted] = React.useState(false);
78+
const [isLoading, setIsLoading] = React.useState(true);
79+
80+
React.useEffect(() => {
81+
const loadResources = async () => {
82+
setIsLoading(true);
83+
84+
// Simulate loading time for theme and resources
85+
await new Promise(resolve => setTimeout(resolve, 800));
86+
87+
setMounted(true);
88+
setIsLoading(false);
89+
};
90+
91+
loadResources();
92+
}, []);
93+
94+
if (isLoading || !mounted) {
95+
return <InstallationPageSkeleton />;
4996
}
5097

5198
return (
@@ -136,7 +183,7 @@ export default function InstallationPage() {
136183
<div className="mt-8 space-y-12">
137184
<div className="space-y-4">
138185
<h3 className="text-xl font-semibold">1. Create Expo Project</h3>
139-
<InstallationTabs command="create-expo-app my-app --template default" />
186+
<InstallationTabs command="create-expo-app my-app" />
140187
</div>
141188

142189
<div className="space-y-4">
@@ -558,41 +605,34 @@ function AppContent() {
558605
Add this code in any of your components to test that everything is working:
559606
</p>
560607
<CodeBlock
561-
language="typescript"
608+
language="tsx"
562609
collapsible
563-
title="app/components/TestComponent.tsx"
564-
code={`import { Button } from '@/components/ui/button';
565-
import { Text } from 'react-native';
610+
title="Test Component"
611+
code={`import { View, Text } from 'react-native';
566612
567-
// ... rest of your imports ...
568-
569-
return (
570-
<Button>
571-
<Text className="text-primary-foreground">Click me</Text>
572-
</Button>
573-
);`}
613+
export default function TestComponent() {
614+
return (
615+
<View className="flex-1 justify-center items-center bg-background">
616+
<Text className="text-2xl font-bold text-foreground">
617+
NativeUI is working! 🎉
618+
</Text>
619+
</View>
620+
);
621+
}`}
574622
/>
575623
</div>
576624
</div>
577625
</div>
578626
</div>
579627
) : (
580-
<div className="rounded-lg border-2 border-muted p-8 text-center">
581-
<h2 className="text-2xl font-bold tracking-tight mb-4">React Native CLI Support</h2>
582-
<p className="text-muted-foreground text-lg leading-7">
583-
Support for React Native CLI is coming soon. We recommend using Expo for now.
628+
<div className="text-center py-12">
629+
<h3 className="text-xl font-semibold mb-2">React Native CLI</h3>
630+
<p className="text-muted-foreground">
631+
Support for React Native CLI is coming soon. Stay tuned!
584632
</p>
585633
</div>
586634
)}
587635
</div>
588-
589-
<div className="mt-12 space-y-4">
590-
<h2 className="text-2xl font-bold tracking-tight">Next Steps</h2>
591-
<p className="text-muted-foreground leading-7">
592-
Now that you have set up your project, you can start adding components from our collection.
593-
Visit the components section to explore available components and learn how to use them.
594-
</p>
595-
</div>
596636
</div>
597637
);
598638
}

0 commit comments

Comments
 (0)