-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
697 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import Image from "next/image"; | ||
import Link from "next/link"; | ||
import React from "react"; | ||
|
||
interface Props { | ||
imgUrl: string; | ||
alt: string; | ||
value: string | number; | ||
title: string; | ||
href?: string; | ||
textStyles: string; | ||
imgStyles?: string; | ||
isAuthor?: Boolean; | ||
} | ||
|
||
const Metric = ({ | ||
imgUrl, | ||
alt, | ||
value, | ||
title, | ||
href, | ||
textStyles, | ||
imgStyles, | ||
isAuthor, | ||
}: Props) => { | ||
const metricContent = ( | ||
<> | ||
<Image | ||
src={imgUrl} | ||
width={16} | ||
height={16} | ||
alt={alt} | ||
className={`rounded-full object-contain ${imgStyles}`} | ||
/> | ||
<p className={`${textStyles} flex items-center gap-1`}> | ||
{value} | ||
<span | ||
className={`small-regular line-clamp-1 ${ | ||
isAuthor ? "max-sm:hidden" : "" | ||
}`} | ||
> | ||
{title} | ||
</span> | ||
</p> | ||
</> | ||
); | ||
return href ? ( | ||
<Link href={href} className="flex-center gap-1"> | ||
{metricContent} | ||
</Link> | ||
) : ( | ||
<div className="flex-center gap-1">{metricContent}</div> | ||
); | ||
}; | ||
|
||
export default Metric; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import ROUTES from "@/constants/routes"; | ||
import { getTimeStamp } from "@/lib/utils"; | ||
import Link from "next/link"; | ||
import TagCard from "./TagCard"; | ||
import Metric from "../Metric"; | ||
import { auth } from "@/auth"; | ||
|
||
interface Props { | ||
question: Question; | ||
} | ||
|
||
const QuestionCard = ({ | ||
question: { _id, title, tags, author, createdAt, upvotes, answers, views }, | ||
}: Props) => { | ||
return ( | ||
<div className="card-wrapper rounded-[10px] p-9 sm:px-11"> | ||
<div className="flex flex-col-reverse justify-between items-start gap-5 sm:flex-row"> | ||
<div> | ||
<span className="subtle-regular text-dark400_light700 line-clamp-1 flex sm:hidden"> | ||
{getTimeStamp(createdAt)} | ||
</span> | ||
<Link href={ROUTES.QUESTION(_id)}> | ||
<h3 className="sm:h3-semibold bas-semibold text-dark200_light900"> | ||
{title} | ||
</h3> | ||
</Link> | ||
</div> | ||
</div> | ||
<div className="mt-3.5 flex w-full flex-wrap gap-2"> | ||
{tags.map((tag: Tag) => ( | ||
<TagCard key={tag._id} _id={tag._id} name={tag.name} compact /> | ||
))} | ||
</div> | ||
<div className="flex-between mt-6 w-full flex-wrap gap-3"> | ||
<Metric | ||
imgUrl={author.image} | ||
alt={author.name} | ||
value={author.name} | ||
title={`. asked ${getTimeStamp(createdAt)}`} | ||
href={ROUTES.PROFILE(author._id)} | ||
textStyles="body-medium text-dark400_light700" | ||
isAuthor | ||
/> | ||
<div className="flex items-center gap-3 max-sm:flex-wrap max-sm:flex-start"> | ||
<Metric | ||
imgUrl="/icons/like.svg" | ||
alt=" like" | ||
value={upvotes} | ||
title=" Votes" | ||
textStyles="small-medium text-dark400_light800" | ||
/> | ||
<Metric | ||
imgUrl="/icons/message.svg" | ||
alt="answers" | ||
value={answers} | ||
title=" Answers" | ||
textStyles="small-medium text-dark400_light800" | ||
/> | ||
<Metric | ||
imgUrl="/icons/eye.svg" | ||
alt="views" | ||
value={views} | ||
title=" Views" | ||
textStyles="small-medium text-dark400_light800" | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default QuestionCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
"use client"; | ||
import { cn } from "@/lib/utils"; | ||
import { Button } from "../ui/button"; | ||
import { useState } from "react"; | ||
import { useRouter, useSearchParams } from "next/navigation"; | ||
import { formUrlQuery, removeKeysFormUrlQuery } from "@/lib/url"; | ||
|
||
const filters = [ | ||
{ name: "React", value: "react" }, | ||
{ name: "JavaScript", value: "javascript" }, | ||
]; | ||
|
||
const HomeFilter = () => { | ||
const router = useRouter(); | ||
const searchParams = useSearchParams(); | ||
const filterParams = searchParams.get("filter"); | ||
|
||
const [active, setActive] = useState(""); | ||
|
||
const handleTypeClick = (filter: string) => { | ||
let newUrl = ""; | ||
if (filter === active) { | ||
setActive(""); | ||
newUrl = removeKeysFormUrlQuery({ | ||
keysToRemove: ["filter"], | ||
params: searchParams.toString(), | ||
}); | ||
} else { | ||
setActive(filter); | ||
newUrl = formUrlQuery({ | ||
params: searchParams.toString(), | ||
key: "filter", | ||
value: filter.toLowerCase(), | ||
}); | ||
} | ||
router.push(newUrl, { scroll: false }); | ||
}; | ||
|
||
return ( | ||
<div className="mt-10 hidden flex-wrap gap-3 sm:flex"> | ||
{filters.map((filter) => ( | ||
<Button | ||
key={filter.value} | ||
className={cn( | ||
`body-medium rounded-lg px-6 py-3 capitalize shadow-none`, | ||
active === filter.value | ||
? "bg-primary-100 text-primary-500 hover:bg-primary-100 dark:bg-dark-400 dark:text-primary-500 dark:hover:bg-dark-400" | ||
: "bg-light-800 text-light-500 hover:bg-light-800 dark:bg-dark-300 dark:text-light-500 dark:hover:bg-dark-300" | ||
)} | ||
onClick={() => { | ||
handleTypeClick(filter.value); | ||
}} | ||
> | ||
{filter.name} | ||
</Button> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default HomeFilter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import type { NextConfig } from "next"; | ||
|
||
const nextConfig: NextConfig = { | ||
/* config options here */ | ||
images: { | ||
remotePatterns: [{ protocol: "https", hostname: "avatar.iran.liara.run" }], | ||
}, | ||
}; | ||
|
||
export default nextConfig; |
Oops, something went wrong.