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

fix: add missing skeleton loader for insights panel #2524

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 18 additions & 1 deletion components/shared/AppSidebar/InsightsPanel.tsx
Expand Up @@ -3,6 +3,7 @@ import { FiChevronDown, FiChevronUp } from "react-icons/fi";
import { Root, Thumb } from "@radix-ui/react-switch";
import { useState } from "react";
import ClientOnly from "components/atoms/ClientOnly/client-only";
import SkeletonWrapper from "components/atoms/SkeletonLoader/skeleton-wrapper";
import SidebarMenuItem from "./sidebar-menu-item";

interface InsightsPanelProps {
Expand All @@ -13,6 +14,20 @@ interface InsightsPanelProps {
isLoading: boolean;
}

const Loading = () => {
return (
<ul className="list-none w-full px-2 mt-1 [&_li]:border-l-2">
{new Array(5).fill(0).map((_, i) => {
return (
<li key={i} className="p-2">
<SkeletonWrapper height={20} />
</li>
);
})}
</ul>
);
};

export const InsightsPanel = ({ title, username, insights, type, isLoading }: InsightsPanelProps) => {
const [open, setOpen] = useState(true);
return (
Expand Down Expand Up @@ -41,7 +56,9 @@ export const InsightsPanel = ({ title, username, insights, type, isLoading }: In
</Root>
</Collapsible.Trigger>
<Collapsible.Content>
{isLoading ? null : (
{isLoading ? (
<Loading />
) : (
<ul className="list-none w-full px-2 mt-1 [&_li]:border-l-2">
{insights.map((insight) => {
const url = type === "list" ? `/lists/${insight.id}` : `/pages/${username}/${insight.id}/dashboard`;
Expand Down