MCPcopy Create free account
hub / github.com/Bitbox-Connect/Bitbox / CommunityCard

Function CommunityCard

client/src/component/CommunityCard.jsx:10–82  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

8import DetailCardImg from '../assets/images/Modal Image/Details.png'
9
10const CommunityCard = (props) => {
11 const { project, showDetailProject } = props;
12 // const [like,setLike]=useState(false)
13
14 const HandleColor = () => {
15
16 }
17
18 // Function to generate a unique image URL for each project
19 const generateImageUrl = (projectId) => {
20 return `https://source.unsplash.com/910x900/?computer/?coding/&${projectId}`;
21 };
22
23 // Function to format date
24 const formatDate = (dateString) => {
25 const date = new Date(dateString);
26 const year = date.getFullYear().toString().slice(-2); // Get last 2 digits of the year
27 const month = ('0' + (date.getMonth() + 1)).slice(-2); // Add leading zero for single-digit months
28 const day = ('0' + date.getDate()).slice(-2); // Add leading zero for single-digit days
29 const hours = ('0' + date.getHours()).slice(-2); // Add leading zero for single-digit hours
30 const minutes = ('0' + date.getMinutes()).slice(-2); // Add leading zero for single-digit minutes
31
32 // Format the date and time
33 return `${day}/${month}/${year} | ${hours}:${minutes}`;
34 };
35
36 // Max Length for title and description
37 const maxTitleLength = 30;
38 const maxDescriptionLength = 75;
39
40 return (
41 <div className='col-md-4 my-3'>
42 <div className="projectContainer" style={{ borderradius: props.mode === '10px' }} >
43 <div className="projectBox" style={{ background: props.mode === 'dark' ? ' white' : '', color: props.mode === 'dark' ? 'white' : 'black' }}>
44 <div className="projectInfo">
45 <div className="projectAvatar">
46 <img src={avatarImg} alt="avatar" />
47 </div>
48 <div className="projectText">
49 <div className="projectTitle" style={{ color: props.mode === 'dark' ? '#100000' : '' }}>{project.title.length > maxTitleLength ? project.title.slice(0, maxTitleLength) + '...' : project.title}</div>
50 <div className="projectDetails">
51 {/* <div className="projectUserName">Anuj Verma</div> */}
52 <div className="projectTime" style={{ color: props.mode === 'dark' ? '#100000' : '', margin: "0" }}>{formatDate(project.date)}</div>
53 </div>
54 </div>
55 </div>
56 <div className="projectDescription" style={{ color: props.mode === 'dark' ? '#100000' : '' }}>
57 {project.description.length > maxDescriptionLength ? project.description.slice(0, maxDescriptionLength) + '...' : project.description}
58 </div>
59 <div className="project-bottom-container">
60 <div className="projectVisualContainer">
61 <img src={generateImageUrl(project._id)} className="card-img-top" alt="..." />
62 </div>
63 <div className="projectEngagementContainer" >
64 <div className="project-love" onClick={HandleColor}>
65 <img src={FavourModalImg} alt="Love" />
66 </div>
67 <div className="project-comment">

Callers

nothing calls this directly

Calls 3

formatDateFunction · 0.70
generateImageUrlFunction · 0.70
showDetailProjectFunction · 0.70

Tested by

no test coverage detected