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

UI Changes to Voting Page #517

Merged
merged 2 commits into from
Dec 15, 2024
Merged
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
17 changes: 15 additions & 2 deletions checkers-app/src/components/vote/MessageCard.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React, { useState } from "react";
import { Card, CardBody, Typography, Button } from "@material-tailwind/react";
import { Card, CardBody, Typography, Button, Alert } from "@material-tailwind/react";
import { ChatBubbleLeftEllipsisIcon, PaperAirplaneIcon } from "@heroicons/react/20/solid";

interface PropType {
text: string | null;
type: "image" | "text";
caption: string | null;
imageUrl: string | null;
sender: string | null;
}

// Helper function to detect URLs and split the text
Expand Down Expand Up @@ -44,7 +46,7 @@ const splitTextByUrls = (text: string) => {
export default function MessageCard(prop: PropType) {
const [isExpanded, setIsExpanded] = useState(false);
const lengthBeforeTruncation = 300;
const { text, caption, imageUrl, type } = prop;
const { text, caption, imageUrl, type, sender } = prop;

const toggleExpansion = () => {
setIsExpanded(!isExpanded);
Expand All @@ -69,6 +71,10 @@ export default function MessageCard(prop: PropType) {
return (
<Card className="bg-error-color overflow-y-auto overflow-x-hidden max-w-md w-full h-full max-h-full p-3">
<CardBody className="-m-3">
<Typography className="flex items-center mb-2">
<ChatBubbleLeftEllipsisIcon className="h-6 w-6 text-[#ff327d] mr-2 flex-shrink-0"/>
<p className="font-semibold leading-none">Message:</p>
</Typography>
<Typography className="w-full">
{type === "image" && displayText.length > 0 && (
<span className="font-bold">Caption: </span>
Expand Down Expand Up @@ -109,6 +115,7 @@ export default function MessageCard(prop: PropType) {
{isExpanded ? "Show Less" : "Read More"}
</Button>
)}

</CardBody>
{type === "image" && imageUrl && (
<img
Expand All @@ -117,6 +124,12 @@ export default function MessageCard(prop: PropType) {
className="w-full object-contain rounded-xl"
/>
)}
<CardBody className="-m-3">
<Typography className="flex items-center mt-1 mb-2">
<PaperAirplaneIcon className="h-6 w-6 text-[#ff8932] mr-2 flex-srhink-0"/>
<p className="font-medium leading-none">Sender: {sender}</p>
</Typography>
</CardBody>
</Card>
);
}
5 changes: 3 additions & 2 deletions checkers-app/src/components/vote/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import MessageCard from "./MessageCard";
import { Typography, Alert } from "@material-tailwind/react";
import { Typography } from "@material-tailwind/react";
import { useEffect, useState } from "react";
import { useParams } from "react-router-dom";
import { useUser } from "../../providers/UserContext";
Expand Down Expand Up @@ -64,8 +64,9 @@ export default function VotePage() {
text={vote.text}
imageUrl={vote.signedImageUrl}
caption={vote.caption}
sender={vote.sender}
/>
<Alert variant="ghost">Sender: {vote.sender}</Alert>

{vote.communityNote ? (
<CommunityNoteCard
en = {vote.communityNote.en}
Expand Down
Loading