-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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-#445: Absence of a Proper Loading skeleton for the AddBlog Section #pr446 #451
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b3dc620
fix-#445: added custom loading skeleton for AddBlog section
AMS003010 300152f
Merge branch 'krishnaacharyaa:main' into loader-add-blog
AMS003010 f161687
Add require-auth-blog and update App.tsx to use it for add-blog route
MetiUmashri 5394bc8
necessary changes done
MetiUmashri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,23 @@ | ||
import { Navigate, Outlet } from 'react-router-dom'; | ||
import { AddBlogPostSkeleton } from './skeletons/add-blog-post-skeleton'; | ||
import useAuthData from '@/hooks/useAuthData'; | ||
|
||
function RequireAuthBlog({ allowedRole }: { allowedRole: string[] }) { | ||
const { role, token, loading } = useAuthData(); | ||
|
||
if (loading) { | ||
return ( | ||
<> | ||
<AddBlogPostSkeleton /> | ||
</> | ||
); // Render a loading indicator | ||
} | ||
|
||
return token && allowedRole.find((myRole) => myRole === role) ? ( | ||
<Outlet /> | ||
) : ( | ||
<Navigate to={'/signin'} /> | ||
); | ||
} | ||
|
||
export default RequireAuthBlog; |
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
65 changes: 65 additions & 0 deletions
65
frontend/src/components/skeletons/add-blog-post-skeleton.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,65 @@ | ||
import { useState, useEffect } from 'react'; | ||
import navigateBackBlackIcon from '@/assets/svg/navigate-back-black.svg'; | ||
import navigateBackWhiteIcon from '@/assets/svg/navigate-back-white.svg'; | ||
|
||
export const AddBlogPostSkeleton = () => { | ||
const [isDarkMode, setIsDarkMode] = useState<boolean | null>(null); | ||
useEffect(() => { | ||
const storedTheme = localStorage.getItem('theme'); | ||
setIsDarkMode(storedTheme === 'dark'); | ||
}, []); | ||
|
||
return ( | ||
<div className="flex-grow cursor-default bg-slate-50 px-6 py-8 dark:bg-dark-card"> | ||
<div className="mb-4 flex justify-center"> | ||
<div className="flex w-[32rem] items-center justify-start space-x-4 sm:w-5/6 lg:w-4/6 "> | ||
<div className="w-fit"> | ||
<img | ||
alt="theme" | ||
src={isDarkMode ? navigateBackWhiteIcon : navigateBackBlackIcon} | ||
className="active:scale-click h-5 w-10" | ||
/> | ||
</div> | ||
<h2 className="cursor-text text-lg font-semibold text-light-primary dark:text-dark-primary sm:text-xl lg:text-2xl"> | ||
Create Blog | ||
</h2> | ||
</div> | ||
</div> | ||
<div className="flex justify-center"> | ||
<form className="sm:w-5/6 lg:w-2/3"> | ||
<div className="mb-2 flex items-center"> | ||
<label className="flex items-center"> | ||
<span className="h-[1.4rem] w-[10rem] animate-pulse rounded-sm bg-slate-300 px-2 dark:bg-slate-700"></span> | ||
</label> | ||
</div> | ||
|
||
<div className="mb-2"> | ||
<div className="mb-4 h-[1rem] w-[16rem] animate-pulse rounded-sm bg-slate-300 dark:bg-slate-700"></div> | ||
<div className="mb-1 h-[3rem] w-[100%] animate-pulse rounded-lg bg-slate-200 p-3 dark:bg-dark-field"></div> | ||
</div> | ||
|
||
<div className="mb-1"> | ||
<div className="mb-2 h-[1rem] w-[6rem] animate-pulse rounded-sm bg-slate-300 dark:bg-slate-700"></div> | ||
<div className="mb-1 h-[10rem] w-[100%] animate-pulse rounded-lg bg-slate-200 p-3 dark:bg-dark-field"></div> | ||
</div> | ||
<div className="mb-2"> | ||
<div className="mb-2 h-[1rem] w-[6rem] bg-slate-300 dark:bg-slate-700"></div> | ||
<div className="mb-1 h-[3rem] w-[100%] animate-pulse rounded-lg bg-slate-200 p-3 dark:bg-dark-field"></div> | ||
</div> | ||
|
||
<div className="mb-4 h-[1rem] w-[12rem] animate-pulse rounded-sm bg-slate-300 dark:bg-slate-700"></div> | ||
<div> | ||
<div className="mb-1 flex items-center justify-between gap-2 sm:gap-4"> | ||
<div className="mb-1 h-[3rem] w-[100%] animate-pulse rounded-lg bg-slate-200 p-3 dark:bg-dark-field"></div> | ||
<div className="active:scale-click flex h-[2.8rem] w-[3.5rem] animate-pulse items-center justify-center rounded-lg bg-slate-300 px-12 py-3 dark:bg-slate-700 sm:mx-1 sm:w-fit"></div> | ||
</div> | ||
</div> | ||
|
||
<div className="mb-8 h-[1rem] w-[17rem] animate-pulse rounded-sm bg-slate-300 dark:bg-slate-700"></div> | ||
|
||
<div className="active:scale-click flex h-[2.5rem] w-[1.5rem] animate-pulse items-center justify-center rounded-lg bg-slate-300 px-12 py-3 dark:bg-slate-700 sm:mx-1 sm:w-fit"></div> | ||
</form> | ||
</div> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which is this loader? Can you paste the screenshot of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you enhance this even? For other cases let's say full page circular loader with white and black theme?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you prefer a new PR for that, i'm fine with that, just let me know