-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding skeleton loadin for cards and navbar
- Loading branch information
1 parent
cd6c455
commit 8a4b1e0
Showing
9 changed files
with
355 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {useCategoriesStore} from '@/store/store'; | ||
|
||
|
||
export const fetchCategories = async () => { | ||
try { | ||
const response = await fetch('http://localhost:4000/components/get-cateogries'); | ||
if (!response.ok) { | ||
throw new Error('Failed to fetch categories'); | ||
} | ||
const data = await response.json(); | ||
const { directories } = data; | ||
useCategoriesStore.setState({ categories: directories }); // Use setState to update store | ||
return directories; | ||
} catch (error) { | ||
console.error('Error fetching categories:', error); | ||
} | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { useComponentsStore } from '@/store/store'; | ||
|
||
type PostDetails = { | ||
html: string; | ||
css: string; | ||
js: string; | ||
folder_path: string; | ||
folder_name: string; | ||
catogries: string; | ||
isActive: boolean; | ||
title: string; | ||
description: string; | ||
admin: { | ||
_id: string; | ||
id: number; | ||
login: string; | ||
avatar_url: string; | ||
url: string; | ||
html_url: string; | ||
company: string; | ||
location: string; | ||
email: string | null; | ||
name: string; | ||
blog: string; | ||
bio: string; | ||
twitter_username: string | null; | ||
__v: number; | ||
}; | ||
}; | ||
|
||
type ResponseItem = { | ||
post_details: PostDetails; | ||
}; | ||
|
||
export const fetchComponentsStore = async (categories: string) => { | ||
try { | ||
const response = await fetch(`http://localhost:4000/components/searchcomponents?search=${categories}`); | ||
if (!response.ok) { | ||
throw new Error('Failed to fetch categories'); | ||
} | ||
const data = await response.json(); | ||
const { response: responseData } = data; | ||
|
||
// Extract post_details from response | ||
const details: PostDetails[] = responseData.map((item: ResponseItem) => item.post_details); | ||
|
||
// Update the store | ||
useComponentsStore.setState({ buttons: details }); | ||
|
||
return details; | ||
} catch (error) { | ||
console.error('Error fetching categories:', error);`` | ||
} | ||
}; |
25 changes: 25 additions & 0 deletions
25
ui_tailwind_shadecn/src/components/custom_ui/skeleton/CardSkeleton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Skeleton } from "@/components/ui/skeleton" | ||
|
||
|
||
const CardSkeleton = () => { | ||
return ( | ||
<> | ||
|
||
<div className="relative"> | ||
<div className="flex flex-col space-y-3"> | ||
<Skeleton className="h-[250px] w-[100%] rounded-xl" /> | ||
<div className="space-y-2"> | ||
<div className="flex justify-between"> | ||
<Skeleton className="h-4 w-[100%]" /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
|
||
</> | ||
) | ||
} | ||
|
||
|
||
export { CardSkeleton } |
23 changes: 23 additions & 0 deletions
23
ui_tailwind_shadecn/src/components/custom_ui/skeleton/NavSkeleton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Skeleton } from "@/components/ui/skeleton" | ||
|
||
|
||
const NavSkeleton = () => { | ||
return( | ||
<> | ||
<Skeleton className="w-[100%] h-[40px] rounded transition duration-900 px-3 py-3 ease-in-out my-1" /> | ||
<Skeleton className="w-[100%] h-[40px] rounded transition duration-900 px-3 py-3 ease-in-out my-1" /> | ||
<Skeleton className="w-[100%] h-[40px] rounded transition duration-900 px-3 py-3 ease-in-out my-1" /> | ||
<Skeleton className="w-[100%] h-[40px] rounded transition duration-900 px-3 py-3 ease-in-out my-1" /> | ||
<Skeleton className="w-[100%] h-[40px] rounded transition duration-900 px-3 py-3 ease-in-out my-1" /> | ||
<Skeleton className="w-[100%] h-[40px] rounded transition duration-900 px-3 py-3 ease-in-out my-1" /> | ||
<Skeleton className="w-[100%] h-[40px] rounded transition duration-900 px-3 py-3 ease-in-out my-1" /> | ||
<Skeleton className="w-[100%] h-[40px] rounded transition duration-900 px-3 py-3 ease-in-out my-1" /> | ||
<Skeleton className="w-[100%] h-[40px] rounded transition duration-900 px-3 py-3 ease-in-out my-1" /> | ||
<Skeleton className="w-[100%] h-[40px] rounded transition duration-900 px-3 py-3 ease-in-out my-1" /> | ||
<Skeleton className="w-[100%] h-[40px] rounded transition duration-900 px-3 py-3 ease-in-out my-1" /> | ||
<Skeleton className="w-[100%] h-[40px] rounded transition duration-900 px-3 py-3 ease-in-out my-1" /> | ||
</> | ||
) | ||
} | ||
|
||
export {NavSkeleton} |
Oops, something went wrong.