Skip to content

Commit e9fbd30

Browse files
Merge pull request #24 from kunaldhongade/main
update: home page
2 parents ff873e4 + 0e364ae commit e9fbd30

File tree

3 files changed

+51
-35
lines changed

3 files changed

+51
-35
lines changed

src/components/HomeMainbar/Questions.tsx

+34-32
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import moment from "moment";
2-
// import { MdOutlineFavorite } from "react-icons/md";
3-
// import { RiQuestionAnswerFill } from "react-icons/ri";
2+
import { BiSolidUpvote } from "react-icons/bi";
43
import { Link } from "react-router-dom";
54

65
interface Question {
@@ -17,14 +16,11 @@ interface Question {
1716
const Questions = ({ question }: { question: Question }) => {
1817
return (
1918
<Link to={`/Questions/${question._id}`}>
20-
<div className="flex flex-col gap-4 p-4 bg-gray-50 border border-gray-300 rounded-md shadow-md hover:shadow-lg transition-shadow duration-300 mb-2">
21-
{/* Votes and Answers Row */}
22-
23-
{/* Question Details Section */}
19+
<div className="flex flex-col gap-4 p-6 bg-white border border-gray-200 rounded-2xl shadow-sm hover:shadow-md transition-shadow duration-300 mb-4 transform hover:-translate-y-1">
2420
<div className="flex-grow">
2521
<Link
2622
to={`/Questions/${question._id}`}
27-
className="text-lg font-medium text-blue-700 hover:underline"
23+
className="text-xl font-semibold text-gray-800 hover:text-blue-600 transition-colors duration-300"
2824
>
2925
{question.questionTitle?.length >
3026
(window.innerWidth <= 400 ? 70 : 90)
@@ -35,33 +31,39 @@ const Questions = ({ question }: { question: Question }) => {
3531
: question.questionTitle}
3632
</Link>
3733
</div>
38-
<div className="flex flex-wrap items-center gap-4 text-gray-600 text-xs sm:text-sm">
39-
{/* <span className="px-2 py-1 bg-gray-100 border border-gray-300 rounded-full inline-flex items-center">
40-
<span className="font-semibold">
41-
{question.upVote.length - question.downVote.length}
42-
</span>{" "}
43-
<MdOutlineFavorite />
44-
</span> */}
45-
{/* <span className="px-2 py-1 bg-gray-100 border border-gray-300 rounded-full inline-flex items-center">
46-
<span className="font-semibold px-1">{question.noOfAnswers}</span>
47-
<RiQuestionAnswerFill />
48-
</span> */}
49-
<div className="text-xs text-gray-500 mt-2">
50-
asked {moment(question.askedOn).fromNow()} by
51-
<span className="ml-1 font-medium text-gray-800">
52-
{question.userPosted.length > 10
53-
? question.userPosted.substring(0, 10) + "..."
54-
: question.userPosted}
55-
</span>
34+
35+
<div className="flex items-center gap-2 text-sm text-gray-600">
36+
<div className="flex flex-wrap gap-2">
37+
{question.questionTags.map((tag) => (
38+
<span
39+
key={tag}
40+
className="px-3 py-1 text-xs font-medium text-gray-600 border border-gray-300 rounded-full hover:bg-blue-50 transition-colors duration-300"
41+
>
42+
{tag}
43+
</span>
44+
))}
5645
</div>
57-
{question.questionTags.map((tag) => (
58-
<span
59-
key={tag}
60-
className="px-2 py-1 text-xs text-gray-800 bg-gray-200 border border-gray-300 rounded-full"
61-
>
62-
{tag}
46+
47+
<span className="px-2 py-1 text-xs font-medium text-gray-600 border border-gray-300 rounded-full items-center flex content-between">
48+
{question.noOfAnswers} <BiSolidUpvote />
49+
</span>
50+
51+
<span className="px-2 py-1 text-xs font-medium text-gray-600 border border-gray-300 rounded-full">
52+
{question.noOfAnswers} 💬
53+
</span>
54+
</div>
55+
56+
<div className="flex justify-between items-center text-gray-600 text-sm">
57+
<div className="flex items-center gap-2 text-sm text-gray-500">
58+
<span className="text-gray-500">
59+
asked {moment(question.askedOn).fromNow()}
6360
</span>
64-
))}
61+
</div>
62+
<span className="font-medium text-slate-400 hover:text-blue-200 transition-colors duration-300">
63+
{question.userPosted.length > 10
64+
? question.userPosted.substring(0, 10) + "..."
65+
: question.userPosted}
66+
</span>
6567
</div>
6668
</div>
6769
</Link>

src/pages/Questions/DisplayAnswer.tsx

+16-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const DisplayAnswer: React.FC<DisplayAnswerProps> = ({
3131
}) => {
3232
const { address } = useAccount();
3333
const [voteStatus, setVoteStatus] = useState<{ [key: string]: boolean }>({});
34+
const [isSeeMoreQuestion, setIsSeeMoreQuestion] = useState<boolean>(false);
3435
const [loadingStates, setLoadingStates] = useState<{
3536
[key: string]: boolean;
3637
}>({});
@@ -140,17 +141,30 @@ const DisplayAnswer: React.FC<DisplayAnswerProps> = ({
140141
</div>
141142

142143
<MarkdownPreview
143-
source={answer.content}
144+
source={
145+
isSeeMoreQuestion
146+
? answer.content
147+
: answer.content.substring(0, 500) +
148+
(answer.content.length > 500 ? "..." : "")
149+
}
144150
wrapperElement={{
145151
"data-color-mode": "light",
146152
}}
147153
style={{
148154
padding: "1rem",
149155
color: "#333",
150-
backgroundColor: "whitesmoke",
156+
backgroundColor: "#FAF9F6",
151157
borderRadius: "1rem",
152158
}}
153159
/>
160+
{answer.content.length > 200 && (
161+
<button
162+
onClick={() => setIsSeeMoreQuestion(!isSeeMoreQuestion)}
163+
className="mt-2 text-gray-400 hover:text-blue-300 float-end text-sm"
164+
>
165+
{isSeeMoreQuestion ? "... Show Less" : "... Show More"}
166+
</button>
167+
)}
154168

155169
<div className="flex items-center gap-4 mt-4">
156170
<button

src/pages/Questions/QuestionsDetails.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ const QuestionsDetails = () => {
252252
style={{
253253
padding: "1rem",
254254
color: "#333",
255-
backgroundColor: "whitesmoke",
255+
backgroundColor: "#f8f8f8",
256256
borderRadius: "1rem",
257257
}}
258258
/>

0 commit comments

Comments
 (0)