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: play cards ui #1461

Merged
merged 7 commits into from
Feb 24, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
58 changes: 58 additions & 0 deletions src/common/playlists/PlayCard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { BsPlayCircleFill } from 'react-icons/bs';
import { BiLogoTypescript } from 'react-icons/bi';
import { BiLogoJavascript } from 'react-icons/bi';
priyankarpal marked this conversation as resolved.
Show resolved Hide resolved

import Shimmer from 'react-shimmer-effect';
import Like from 'common/components/Like/Like';
import userImage from 'images/user.png';

function PlayCard({ play, cover, likeObject }) {
return (
<Link to={`/plays/${encodeURI(play.github.toLowerCase())}/${play.slug}`}>
<div className="play-card-container">
<div className="play-thumb-container">
<Shimmer>
<img alt="Dummy Image" className="play-thumb-img" src={cover} />
</Shimmer>
<BsPlayCircleFill className="play-icon" color="white" size={80} />
</div>

{/* <div className="border" /> */}
<div className="card-header">{play.name}</div>
priyankarpal marked this conversation as resolved.
Show resolved Hide resolved
{play.user && (
<div className="author">
<img
alt="avatar"
className="rounded-full border border-zink"
height="25px"
loading="lazy"
src={
play?.user.avatarUrl
? play?.user.avatarUrl.length
? play?.user.avatarUrl
: userImage
: userImage
}
width="25px"
/>
<div className="author-name">{play?.user.displayName}</div>
</div>
)}
<div className="play-actions mt-4">
<div className="like-container">
<Like likeObj={likeObject()} onLikeClick={null} />
{play.language === 'ts' ? (
<BiLogoTypescript size={25} />
) : (
<BiLogoJavascript size={25} />
priyankarpal marked this conversation as resolved.
Show resolved Hide resolved
)}
</div>
</div>
</div>
</Link>
);
}

export default PlayCard;
49 changes: 2 additions & 47 deletions src/common/playlists/PlayThumbnail.jsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,8 @@
import { useState, useEffect } from 'react';
import { Link } from 'react-router-dom';
import { BsPlayCircleFill } from 'react-icons/bs';
import Shimmer from 'react-shimmer-effect';
import userImage from 'images/user.png';
import Like from 'common/components/Like/Like';
import { useUserId, useAuthenticated } from '@nhost/react';
import countByProp from 'common/utils/commonUtils';
import { loadCoverImage } from 'common/utils/coverImageUtil';

const Author = ({ user }) => {
return (
<div className="play-author flex items-center gap-2">
<img
alt="avatar"
className="rounded-full border border-zink-400"
height="25px"
loading="lazy"
src={user?.avatarUrl ? (user?.avatarUrl.length ? user?.avatarUrl : userImage) : userImage}
width="25px"
/>
<div className="author-anchor">{user?.displayName}</div>
</div>
);
};
import PlayCard from './PlayCard';

const PlayThumbnail = ({ play }) => {
const [cover, setCover] = useState(null);
Expand Down Expand Up @@ -57,32 +37,7 @@ const PlayThumbnail = ({ play }) => {
loadCover();
}, [play]);

return (
<li>
<Link to={`/plays/${encodeURI(play.github.toLowerCase())}/${play.slug}`}>
<div className="play-thumb">
<Shimmer>
<img alt="" className="play-thumb-img" loading="lazy" src={cover} />
</Shimmer>
</div>
<div className="play-header">
<div className="play-title">{play.name}</div>
{play.user && <Author user={play.user} />}
<div className="play-actions mt-4">
<div className="flex flex-row justify-between items-end">
<Like likeObj={likeObject()} onLikeClick={null} />
<div className={`language language-${play.language || 'js'}`} />
</div>
</div>
</div>
<div className="play-status">
<BsPlayCircleFill size="48px" />
<div className="default">Play now</div>
<div className="current">Playing..</div>
</div>
</Link>
</li>
);
return <PlayCard cover={cover} likeObject={likeObject} play={play} />;
};

export default PlayThumbnail;
110 changes: 109 additions & 1 deletion src/common/playlists/playlist.css
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@
color: #25a0a7;
}

.search-summary{
.search-summary {
padding: 1.6rem 2rem 0rem 2rem;
display: flex;
flex-wrap: wrap;
Expand All @@ -825,3 +825,111 @@
border-radius: 4px;
border: 1px solid grey;
}

.play-card-container {
display: flex;
flex-direction: column;
border: 1px solid #ddd; /* Add a border for visual separation, adjust as needed */
border-radius: 8px; /* Add rounded corners, adjust as needed */
overflow: hidden; /* Prevent content from overflowing */
transition: transform 0.2s ease-in-out; /* Add a smooth transition effect */
width: 300px; /* Adjust the max-width as needed */
height: 100%; /* Ensure the card container fills its parent */
padding: 12px;
}

.border {
border: 1px solid rgb(189 183 183);
margin: 8px;
/* padding: 20px; */
}
.author {
display: flex;
align-items: center;
margin-top: 10px;
justify-content: center;
}
.card-cover {
width: 100%; /* Set the width to fill its container */
height: auto; /* Maintain aspect ratio */
border-radius: 8px; /* Rounded corners, adjust as needed */
object-fit: cover; /* Scale the image to cover the entire box */
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1); /* Add a subtle shadow */
}

.author-name {
margin-left: 10px;
font-size: 12px;
font-weight: 200;
}
.card-header {
font-size: 18px; /* Example font size, adjust as needed */
padding: 10px; /* Example padding, adjust as needed */
}

.img {
border-radius: 50%;
width: 40px;
height: 40px;
}
.card-footer {
display: flex;
justify-content: space-between;
margin-top: 30px;
align-items: center;
}
.like-btn,
.lng-btn {
padding: 10px 20px;
border-radius: 20px;
background-color: #007bff;
color: #fff;
cursor: pointer;
transition: background-color 0.3s;
}
.like-btn:hover,
.lng-btn:hover {
background-color: #0056b3;
}

.like-container {
display: flex;
align-items: center; /* Align children vertically */
justify-content: space-between;
}

.language {
height: 1.25rem;
width: 1.25rem;
background-repeat: no-repeat;
opacity: 0.2;
}

.play-thumb-container {
position: relative;
overflow: hidden;
}

.play-thumb-img {
width: 100%;
height: auto;
object-fit: cover;
transition: filter 0.3s ease-in-out;
}

.play-card-container:hover .play-thumb-img {
filter: blur(3px) brightness(0.7) saturate(50%);
}

.play-icon {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
opacity: 0;
transition: opacity 0.3s ease-in-out;
}

.play-card-container:hover .play-icon {
opacity: 1;
}
6 changes: 3 additions & 3 deletions src/plays/quiz-app/QuizApp.tsx
priyankarpal marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ function QuizApp(props: any) {
isWin === false && index + 1 === questions[question].answer && isFlipped
? ' border-red-600'
: index + 1 === questions[question].answer &&
questions[question].qStatus === 1
? 'border-[#021C1E]'
: 'border-b-0'
questions[question].qStatus === 1
? 'border-[#021C1E]'
: 'border-b-0'
} ${selectedAns === index ? 'text-blue-700' : ''}`}
disabled={questions[question].qStatus === 1 ? true : false}
key={index}
Expand Down