Skip to content

[Feat]-Added hover effect and Read More to blog cards #1349

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

Closed
Show file tree
Hide file tree
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
128 changes: 55 additions & 73 deletions pages/blog/index.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,87 +240,61 @@
})
.map((blogPost: any) => {
const { frontmatter, content } = blogPost;
const date = new Date(frontmatter.date);

Check failure on line 243 in pages/blog/index.page.tsx

View workflow job for this annotation

GitHub Actions / Code Quality Checks

'date' is assigned a value but never used
const timeToRead = Math.ceil(readingTime(content).minutes);

return (
<section key={blogPost.slug}>
<div className='h-[498px] flex border rounded-lg shadow-sm hover:shadow-lg transition-all overflow-hidden dark:border-slate-500'>
<div className='h-[498px] flex border rounded-lg shadow-sm hover:shadow-xl transition-all duration-300 overflow-hidden dark:border-slate-500 group relative'>
<Link
href={`/blog/posts/${blogPost.slug}`}
className='inline-flex flex-col flex-1 w-full'
>
<div
className='bg-slate-50 h-[160px] w-full self-stretch mr-3 bg-cover bg-center'
style={{ backgroundImage: `url(${frontmatter.cover})` }}
/>
<div className=' p-4 flex flex-col flex-1 justify-between'>
<div className='relative w-full h-[200px] overflow-hidden'>
<Image
src={frontmatter.cover}
fill
className='object-cover transition-transform duration-300 group-hover:scale-105'
alt={frontmatter.title}
/>
</div>
<div className='p-4 flex flex-col flex-1 justify-between'>
<div>
<div>
<div
className='bg-blue-100 hover:bg-blue-200 dark:bg-slate-700 dark:text-blue-100 cursor-pointer font-semibold text-blue-800 inline-block px-3 py-1 rounded-full mb-4 text-sm'
onClick={(e) => {
e.preventDefault();
e.stopPropagation();

if (frontmatter.type) {
setCurrentFilterTag(frontmatter.type);
history.replaceState(
null,
'',
`/blog?type=${frontmatter.type}`,
);
}
}}
>
{frontmatter.type || 'Unknown Type'}
</div>
<div className='bg-blue-100 hover:bg-blue-200 dark:bg-slate-700 dark:text-blue-100 cursor-pointer font-semibold text-blue-800 inline-block px-3 py-1 rounded-full mb-4 text-sm'>
{frontmatter.type || 'Unknown Type'}
</div>
<div className='text-lg font-semibold'>
<div className='text-lg font-semibold group-hover:text-blue-600 dark:group-hover:text-blue-400 transition-colors duration-300'>
{frontmatter.title}
</div>

<div className='mt-3 mb-6 text-slate-500 dark:text-slate-300'>
<TextTruncate
element='span'
line={4}
line={3}
text={frontmatter.excerpt}
/>
</div>
</div>
<div
className={`
flex
flex-row
items-center
`}
>
<div className='flex flex-row pl-2 mr-2'>
{(frontmatter.authors || []).map(
(author: Author, index: number) => (
<div
key={index}
className={`bg-slate-50 rounded-full -ml-3 bg-cover bg-center border-2 border-white ${
frontmatter.authors.length > 2
? 'h-8 w-8'
: 'h-11 w-11'
}`}
style={{
backgroundImage: `url(${author.photo})`,
zIndex: 10 - index,
}}
/>
),
)}
</div>

<div
className={`
flex
flex-col
items-start
`}
>
<div className='flex flex-col space-y-4'>
<div className='flex items-center'>
<div className='flex flex-row pl-2 mr-2'>
{(frontmatter.authors || []).map(
(author: Author, index: number) => (
<div
key={index}
className={`bg-slate-50 rounded-full -ml-3 bg-cover bg-center border-2 border-white ${
frontmatter.authors.length > 2
? 'h-8 w-8'
: 'h-11 w-11'
}`}
style={{
backgroundImage: `url(${author.photo})`,
zIndex: 10 - index,
}}
/>
),
)}
</div>
<div className='text-sm font-semibold'>
{frontmatter.authors.length > 2 ? (
<>
Expand All @@ -346,19 +320,27 @@
)
)}
</div>

<div className='text-slate-500 text-sm dark:text-slate-300'>
{frontmatter.date && (
<span>
{date.toLocaleDateString('en-us', {
year: 'numeric',
month: 'long',
day: 'numeric',
})}
</span>
)}{' '}
&middot; {timeToRead} min read
</div>
</div>
<div className='flex items-center justify-between pt-2 border-t dark:border-slate-600'>
<span className='text-sm text-slate-500 dark:text-slate-300'>
{timeToRead} min read
</span>
<span className='text-blue-600 dark:text-blue-400 font-medium flex items-center group-hover:translate-x-1 transition-transform duration-300'>
Read More
<svg

Check failure on line 330 in pages/blog/index.page.tsx

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Delete `·`
className='ml-1 w-4 h-4 group-hover:translate-x-1 transition-transform duration-300'

Check failure on line 331 in pages/blog/index.page.tsx

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Delete `·`
fill='none'

Check failure on line 332 in pages/blog/index.page.tsx

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Delete `·`
stroke='currentColor'

Check failure on line 333 in pages/blog/index.page.tsx

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Delete `·`
viewBox='0 0 24 24'
>
<path

Check failure on line 336 in pages/blog/index.page.tsx

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Delete `·`
strokeLinecap='round'

Check failure on line 337 in pages/blog/index.page.tsx

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Delete `·`
strokeLinejoin='round'

Check failure on line 338 in pages/blog/index.page.tsx

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Delete `·`
strokeWidth={2}

Check failure on line 339 in pages/blog/index.page.tsx

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Delete `·`
d='M9 5l7 7-7 7'
/>
</svg>
</span>
</div>
</div>
</div>
Expand Down
27 changes: 27 additions & 0 deletions styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -299,4 +299,31 @@ border-radius: 4px; */
}
.scrollbar-hidden::-webkit-scrollbar {
display: none;
}

@keyframes shine {
from {
transform: translateX(-100%);
}
to {
transform: translateX(200%);
}
}

.shine-animation {
animation: shine 2s infinite;
}

/* Add smooth transitions for dark mode */
.dark .group:hover {
background: rgba(255, 255, 255, 0.05);
}

/* Enhance card interactions */
.group {
transition: all 0.3s ease;
}

.group:hover {
transform: translateY(-2px);
}
Loading