Skip to content

Commit

Permalink
added paging for components
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauravtb2253 committed Oct 16, 2024
1 parent fa54b81 commit 200f9a6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/GlassyUIComponentsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ const GlassyUIComponentsPage: React.FC = () => {
onClick: () => navigate('/generator'),
},
];

const [filteredData, setFilteredData] = useState(componentsData);
useEffect(() => {
const data = componentsData.filter(component => {
Expand All @@ -210,9 +211,9 @@ const GlassyUIComponentsPage: React.FC = () => {
setFilteredData(data);
}, [searchFilter]);

const totalPages = Math.ceil(componentsData.length / componentsPerPage);
const totalPages = Math.ceil(filteredData.length / componentsPerPage);

const currentComponents = componentsData.slice(
const currentComponents = filteredData.slice(
(currentPage - 1) * componentsPerPage,
currentPage * componentsPerPage,
);
Expand Down Expand Up @@ -256,7 +257,7 @@ const GlassyUIComponentsPage: React.FC = () => {
</p>

<div className='grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8'>
{filteredData.map((component, index) => (
{currentComponents.map((component, index) => (
<ComponentCard
key={index}
title={component.title}
Expand Down

0 comments on commit 200f9a6

Please sign in to comment.