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

fixed ui loader on doc page #266

Merged
merged 1 commit into from
Sep 3, 2024
Merged
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
13 changes: 8 additions & 5 deletions src/pages/Doc/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,29 @@ const DocList = () => {
};

fetchDocs();
}, []);
}, []);



if (loading) return <div className="flex justify-center items-center h-screen"><Spin size="large" /></div>;
if (error) return <Alert message="Error" description={error} type="error" />;

return (
<Layout>
<div className="container mx-auto p-4 min-h-screen">
<MainTitle highlight={'Documentation'} />
<ul className='grid gap-5 mx-auto md:max-w-2xl'>
{loading ? (
<div className='grid place-content-center mx-auto md:max-w-2xl aspect-video'>
<Spin size="large" />
</div>
) : (<ul className='grid gap-5 mx-auto md:max-w-2xl'>
Comment on lines +41 to +45
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor suggestion: Centralize loading spinner logic.

The changes made to centralize the loading spinner in a grid layout are visually appealing and align with the PR's objectives to enhance the UI on the documentation page. However, consider extracting this loading spinner logic into a separate component for better reusability and maintainability across different parts of the application.

Consider creating a LoadingSpinner component that encapsulates the grid and spinner logic:

const LoadingSpinner = () => (
  <div className='grid place-content-center mx-auto md:max-w-2xl aspect-video'>
    <Spin size="large" />
  </div>
);

// Usage in DocList
{loading ? <LoadingSpinner /> : ...}

{
docs.map(item =>
<Link to={item.title} className='capitalize group flex items-center justify-between bg-white/10 p-5 rounded-md'>{item.title.replace(/_/g, ' ')}
<Link key={item.title} to={item.title} className='capitalize group flex items-center justify-between bg-white/10 p-5 rounded-md'>{item.title.replace(/_/g, ' ')}
<FaArrowRight className="dark:text-white opacity-0 group-hover:opacity-100 -translate-x-10 group-hover:translate-x-0 transition duration-300" />
</Link>
)
}
</ul>
</ul>)}
</div>
</Layout>
);
Expand Down