TheCodedProf | c86e44b | 2023-02-28 17:30:57 -0500 | [diff] [blame] | 1 | import Image from "next/image"; |
| 2 | import Styles from "../../styles/Components/transcripts.module.css" |
TheCodedProf | da197f2 | 2023-03-01 18:15:51 -0500 | [diff] [blame] | 3 | import * as hdate from 'human-date' |
TheCodedProf | c86e44b | 2023-02-28 17:30:57 -0500 | [diff] [blame] | 4 | |
| 5 | function Author(props) { |
TheCodedProf | da197f2 | 2023-03-01 18:15:51 -0500 | [diff] [blame] | 6 | const today = props.message.createdTimestamp - (1000 * 60 * 60 * 24) > 0; |
| 7 | const last2days = props.message.createdTimestamp - (1000 * 60 * 60 * 24 * 2) > 0; |
| 8 | const date = new Date(props.message.createdTimestamp) |
| 9 | let timeDelta; |
| 10 | if (today) { |
| 11 | timeDelta = "Today"; |
| 12 | } else if (last2days) { |
| 13 | timeDelta = "Yesterday"; |
| 14 | } else { |
| 15 | timeDelta = hdate.prettyPrint(date).split(", ")[0]; |
| 16 | } |
| 17 | timeDelta += ` at ${date.getHours()}:${date.getMinutes()}` |
TheCodedProf | c86e44b | 2023-02-28 17:30:57 -0500 | [diff] [blame] | 18 | return ( |
TheCodedProf | da197f2 | 2023-03-01 18:15:51 -0500 | [diff] [blame] | 19 | <div className={Styles.verticalFlex} style={{width: "calc(100vw - 60px - 40px)"}}> |
| 20 | <div className={Styles.horizontalFlex}> |
| 21 | <p style={{color: props.message.author.topRole.color ? props.message.author.topRole.color + " !important" : "var(--theme-ui-colors-text)"}} className={Styles.authorText}> |
| 22 | {props.message.author.username}#{props.message.author.discriminator} |
| 23 | </p> |
| 24 | {props.message.author.topRole.badge ? <Image src={props.message.author.topRole.badge} width={20} height={20} alt=""/> : null} |
| 25 | {props.message.author.bot ? <div className={Styles.botBadge}>BOT</div> : ""} |
| 26 | <p style={{color: "#888888", margin: "0", fontSize: "20px"}}>{timeDelta.toString()}</p> |
TheCodedProf | c86e44b | 2023-02-28 17:30:57 -0500 | [diff] [blame] | 27 | </div> |
| 28 | </div> |
| 29 | ) |
| 30 | |
| 31 | } |
| 32 | |
| 33 | export default Author; |