Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add skeleton to events main #745

Merged
merged 2 commits into from
Aug 6, 2024
Merged
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
8 changes: 8 additions & 0 deletions packages/berlin/src/components/skeleton/Skeleton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { useAppStore } from '@/store';

export default function Skeleton({ className }: React.HTMLAttributes<HTMLDivElement>) {
const theme = useAppStore((state) => state.theme);
return (
<div className={`${className} animate-pulse ${theme === 'dark' ? 'bg-[#333]' : 'bg-[#eee]'}`} />
);
}
1 change: 1 addition & 0 deletions packages/berlin/src/components/skeleton/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './Skeleton';
16 changes: 15 additions & 1 deletion packages/berlin/src/pages/Event.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ import Cycles from '../components/cycles';
import Link from '../components/link';
import Markdown from 'react-markdown';
import Onboarding from '@/components/onboarding';
import Skeleton from '@/components/skeleton';

function Event() {
const { eventId } = useParams();
const { data: event } = useQuery({
const { data: event, isLoading } = useQuery({
queryKey: ['event', eventId],
queryFn: () =>
fetchEvent({ eventId: eventId || '', serverUrl: import.meta.env.VITE_SERVER_URL }),
Expand Down Expand Up @@ -49,6 +50,19 @@ function Event() {
[openCycles],
);

if (isLoading) {
return (
<div className="grid w-full grid-cols-3 gap-4">
<div className="col-span-3 flex flex-col gap-4 md:col-span-2">
<Skeleton className="h-[100px] md:h-[212px]" />
<Skeleton className="h-[50px] md:h-[122px]" />
</div>
<Skeleton className="col-span-3 h-[250px] md:col-span-1 md:h-[350px]" />
<Skeleton className="col-span-3 h-[200px]" />
</div>
);
}

return (
<>
<Onboarding steps={eventSteps} type="event" />
Expand Down
Loading