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-#392: added related blogs section in detailed blog page #398

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions frontend/src/assets/svg/arrow-right-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions frontend/src/components/PostMobileViewCardSkeleton.tsx
Copy link
Owner

Choose a reason for hiding this comment

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

I guess this should go under skeletons folder, not sure, whereever all the skeletons are placed, kindly place it there,
And naming sir, please follow guidelines related-post-card-skeleton as other skeletons namings.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Skeleton } from './ui/skeleton';

export function PostMobileViewCardSkeleton() {
return (
<div
className="flex h-fit rounded-lg border bg-slate-50 dark:border-none dark:bg-dark-card"
data-testid={'postMobileViewCardSkeleton'}
>
<div className="flex h-fit w-full gap-2 p-3">
<Skeleton className="w-1/3 overflow-hidden rounded-lg bg-slate-200 dark:bg-slate-700" />
<div className="flex h-full w-2/3 flex-col gap-2 ">
<Skeleton className="mb-2 h-3 w-full bg-slate-200 pr-2 dark:bg-slate-700" />
<div className="mt-1 flex flex-wrap gap-1 sm:mt-2 sm:gap-1.5">
<Skeleton className={`h-6 w-16 rounded-full bg-slate-200 dark:bg-slate-700`} />
<Skeleton className={`h-6 w-16 rounded-full bg-slate-200 dark:bg-slate-700`} />
</div>
<Skeleton className="mb-2 h-6 w-full bg-slate-200 pr-2 dark:bg-slate-700 sm:mb-4" />
<Skeleton className="mb-2 h-3 w-full bg-slate-200 pr-2 dark:bg-slate-700" />
</div>
</div>
</div>
);
}
26 changes: 17 additions & 9 deletions frontend/src/pages/details-page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Link, useLocation, useNavigate, useParams } from 'react-router-dom';
import navigateBackWhiteIcon from '@/assets/svg/navigate-back-white.svg';
import arrowRightIcon from '@/assets/svg/arrow-right.svg';
import arrowRightWhiteIcon from '@/assets/svg/arrow-right-white.svg';
import arrowRightBlackIcon from '@/assets/svg/arrow-right-black.svg';
import formatPostTime from '@/utils/format-post-time';
import CategoryPill from '@/components/category-pill';
import { useEffect, useState } from 'react';
Expand All @@ -10,6 +11,7 @@ import axiosInstance from '@/helpers/axios-instance';
import { PostCardSkeleton } from '@/components/skeletons/post-card-skeleton';
krishnaacharyaa marked this conversation as resolved.
Show resolved Hide resolved
import PostCard from '@/components/post-card';
import PostMobileViewComponent from '@/components/PostMobileViewComponent';
import { PostMobileViewCardSkeleton } from '@/components/PostMobileViewCardSkeleton';

export default function DetailsPage() {
const { state } = useLocation();
Expand All @@ -20,6 +22,12 @@ export default function DetailsPage() {
const navigate = useNavigate();
const [relatedCategoryPosts, setRelatedCategoryPosts] = useState<Post[]>([]);
const [relatedPostsLoading, setRelatedPostsLoading] = useState<boolean>(false);
const [isDarkMode, setIsDarkMode] = useState<boolean | null>(null);

useEffect(() => {
const theme = localStorage.getItem('theme');
setIsDarkMode(theme === 'dark');
}, []);

krishnaacharyaa marked this conversation as resolved.
Show resolved Hide resolved
useEffect(() => {
const getPostById = async () => {
Expand Down Expand Up @@ -92,25 +100,25 @@ export default function DetailsPage() {
</p>
</div>
</div>
<div className="container mx-auto flex flex-col px-4 py-6 text-white">
<div className="ml-4 flex justify-between text-2xl font-semibold ">
<div className="container mx-auto flex flex-col space-y-2 px-4 py-6 dark:text-white">
<div className="flex flex-col text-2xl font-semibold sm:flex-col md:ml-4 md:flex-row md:justify-between ">
<div>Related Blogs</div>
<div className="mr-10 flex cursor-pointer items-center gap-1 text-gray-400 hover:underline">
<div className="mr-10 flex cursor-pointer items-center text-sm text-gray-400 hover:underline">
<Link to="/">
<div className="text-sm">see more blogs</div>
<div>see more blogs</div>
</Link>
<img
alt="arrow-right"
src={arrowRightIcon}
className="active:scale-click h-10 w-10 "
src={isDarkMode ? arrowRightWhiteIcon : arrowRightBlackIcon}
className="active:scale-click h-8 w-8"
/>
</div>
</div>
<div className="block space-y-4 sm:hidden">
{relatedPostsLoading
? Array(4)
? Array(3)
.fill(0)
.map((_, index) => <PostCardSkeleton key={index} />)
.map((_, index) => <PostMobileViewCardSkeleton key={index} />)
: relatedCategoryPosts
.slice(0, 3)
.map((post) => <PostMobileViewComponent key={post._id} post={post} />)}
Expand Down