|
| 1 | +import React, { useEffect } from "react"; |
| 2 | +import { Project } from "t9/types/fullstack"; |
| 3 | +import Markdown from "react-markdown"; |
| 4 | +import "./style"; |
| 5 | + |
| 6 | +import programer from "t9/apps/main/assets/png/programmer.png"; |
| 7 | +import contact from "t9/apps/main/assets/png/contact.png"; |
| 8 | +import github from "t9/apps/main/assets/png/github.png"; |
| 9 | +import support from "t9/apps/main/assets/png/support.png"; |
| 10 | + |
| 11 | +const socialMedia = [ |
| 12 | + { |
| 13 | + id: 1, |
| 14 | + name: "dzcode", |
| 15 | + href: "https://github.com/dzcode-io/dzcode.io", |
| 16 | + icon: github, |
| 17 | + }, |
| 18 | + { id: 2, name: "Learn", href: "/learn", icon: programer }, |
| 19 | + { id: 3, name: "Contact", href: "/contact", icon: contact }, |
| 20 | + { id: 4, name: "Support", href: "/support", icon: support }, |
| 21 | +]; |
| 22 | + |
| 23 | +export const Details = (props: DetailsInterface) => { |
| 24 | + useEffect(() => { |
| 25 | + props.fetchCurrentProject(); |
| 26 | + setTimeout(() => { |
| 27 | + window.FB && window.FB.XFBML.parse(); |
| 28 | + }, 3000); |
| 29 | + }, []); |
| 30 | + const { currentProject } = props; |
| 31 | + return ( |
| 32 | + <div className="details"> |
| 33 | + {currentProject ? ( |
| 34 | + <div> |
| 35 | + {/* Image */} |
| 36 | + {currentProject.image && ( |
| 37 | + <img |
| 38 | + className="hero-image" |
| 39 | + src={currentProject.image} |
| 40 | + alt={currentProject.title} |
| 41 | + /> |
| 42 | + )} |
| 43 | + {/* Title */} |
| 44 | + <h2 className="title">{currentProject.title}</h2> |
| 45 | + {/* Description */} |
| 46 | + <small className="description">{currentProject.description}</small> |
| 47 | + <hr className="break" /> |
| 48 | + {/* Details */} |
| 49 | + <Markdown className="details" source={currentProject.content} /> |
| 50 | + <hr className="break" /> |
| 51 | + {/* Contact + Edit*/} |
| 52 | + <div className="actions"> |
| 53 | + {socialMedia.map((item) => { |
| 54 | + return ( |
| 55 | + <div key={item.id} className="item"> |
| 56 | + <img src={item.icon} alt={item.name} className="icon" /> |
| 57 | + <a href={item.href}>{item.name}</a> |
| 58 | + </div> |
| 59 | + ); |
| 60 | + })} |
| 61 | + </div> |
| 62 | + {/* Comments */} |
| 63 | + <div |
| 64 | + className="fb-comments" |
| 65 | + data-href={location.origin + location.pathname} |
| 66 | + data-width="100%" |
| 67 | + data-numposts="5" |
| 68 | + /> |
| 69 | + </div> |
| 70 | + ) : ( |
| 71 | + "Loading Project..." |
| 72 | + )} |
| 73 | + </div> |
| 74 | + ); |
| 75 | +}; |
| 76 | + |
| 77 | +export interface DetailsInterface { |
| 78 | + fetchCurrentProject: () => void; |
| 79 | + currentProject: Project | null; |
| 80 | +} |
0 commit comments