-
Notifications
You must be signed in to change notification settings - Fork 12
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
11 changed files
with
228 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { Metadata } from "next"; | ||
|
||
export const metadata: Metadata = { | ||
title: "Topic", | ||
description: "Topic", | ||
}; | ||
|
||
export default async function TopicsLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
return <>{children}</>; | ||
} |
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,20 @@ | ||
import TopicHeader from "@/components/contentDisplay/topicHeader/TopicHeader"; | ||
import TopicContainer from "@/containers/posts/TopicContainer"; | ||
|
||
interface Props { | ||
params: { | ||
topic: string; | ||
}; | ||
} | ||
|
||
export default function Page(props: Props) { | ||
const { params } = props; | ||
const url = decodeURIComponent(params.topic); | ||
|
||
return ( | ||
<> | ||
<TopicHeader url={url} /> | ||
<TopicContainer url={url} /> | ||
</> | ||
); | ||
} |
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,15 @@ | ||
import Layout from "@/containers/Layout"; | ||
import type { Metadata } from "next"; | ||
|
||
export const metadata: Metadata = { | ||
title: "Topics", | ||
description: "Topics", | ||
}; | ||
|
||
export default async function TopicsLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
return <>{children}</>; | ||
} |
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,62 @@ | ||
"use client"; | ||
|
||
import useGetLinkMeta from "@/lib/hooks/useGetLinkMeta"; | ||
import Image from "next/image"; | ||
import { SiGooglemessages } from "react-icons/si"; | ||
import TopicHeaderSkeleton from "./TopicHeaderSkeleton"; | ||
import FeedAlert from "@/components/feedback/feedAlert/FeedAlert"; | ||
import { useState } from "react"; | ||
|
||
interface Props { | ||
url: string; | ||
} | ||
|
||
export default function TopicHeader(props: Props) { | ||
const { url } = props; | ||
const { status, data, error, isLoading, isFetching } = useGetLinkMeta(url); | ||
const [hideImage, setHideImage] = useState(false); | ||
|
||
if (isLoading && !data) return <TopicHeaderSkeleton />; | ||
|
||
return ( | ||
<article className="border-skin-base flex flex-col gap-2 border border-x-0 border-t-0 p-3 md:border md:rounded-t-2xl"> | ||
{error && ( | ||
<FeedAlert | ||
variant="badResponse" | ||
message="Something went wrong" | ||
standalone | ||
/> | ||
)} | ||
|
||
{data?.image && !hideImage && ( | ||
<Image | ||
src={data.image} | ||
alt={`Image from ${url}`} | ||
width={900} | ||
height={500} | ||
className="rounded-lg" | ||
onError={() => setHideImage(true)} | ||
/> | ||
)} | ||
|
||
{data && ( | ||
<> | ||
<div className="flex flex-wrap items-center gap-2 text-skin-secondary mt-2"> | ||
<SiGooglemessages className="text-2xl" /> | ||
<span className="font-medium text-lg">Topic</span> | ||
</div> | ||
<div className="flex flex-col gap-1 mt-1"> | ||
{data?.title && ( | ||
<h3 className="text-skin-base break-words text-xl font-medium"> | ||
{data.title} | ||
</h3> | ||
)} | ||
{data?.description && ( | ||
<p className="text-skin-secondary">{data.description}</p> | ||
)} | ||
</div> | ||
</> | ||
)} | ||
</article> | ||
); | ||
} |
18 changes: 18 additions & 0 deletions
18
src/components/contentDisplay/topicHeader/TopicHeaderSkeleton.tsx
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,18 @@ | ||
export default function TopicHeaderSkeleton() { | ||
return ( | ||
<article className="border-skin-base flex flex-col gap-2 border border-x-0 border-y-0 p-3 md:rounded-t-2xl md:border-x md:border-t"> | ||
<div className="bg-skin-muted h-80 w-full animate-pulse rounded-lg" /> | ||
|
||
<div className="flex flex-wrap items-center gap-2 mt-2"> | ||
<div className="bg-skin-muted h-8 w-8 animate-pulse rounded-full" /> | ||
<div className="bg-skin-muted h-5 w-16 animate-pulse rounded" /> | ||
</div> | ||
|
||
<div className="flex flex-col gap-1 mt-1"> | ||
<div className="bg-skin-muted h-6 w-3/4 animate-pulse rounded" /> | ||
<div className="bg-skin-muted h-3 w-1/2 animate-pulse rounded mt-2" /> | ||
<div className="bg-skin-muted h-3 w-1/3 animate-pulse rounded" /> | ||
</div> | ||
</article> | ||
); | ||
} |
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
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,45 @@ | ||
"use client"; | ||
|
||
import { useState } from "react"; | ||
import TabItem from "@/components/navigational/tabs/TabItem"; | ||
import Tabs from "@/components/navigational/tabs/Tabs"; | ||
import PostSearchContainer from "../search/PostSearchContainer"; | ||
|
||
interface Props { | ||
url: string; | ||
} | ||
|
||
export default function TopicContainer(props: Props) { | ||
const { url } = props; | ||
const [currentTab, setCurrentTab] = useState<"top" | "latest">("top"); | ||
|
||
const handleTabChange = (tab: "top" | "latest") => { | ||
setCurrentTab(tab); | ||
}; | ||
|
||
return ( | ||
<section> | ||
<Tabs className="md:border-x border-skin-base"> | ||
<TabItem | ||
asButton | ||
onClick={() => handleTabChange("top")} | ||
label="Top" | ||
isActive={currentTab === "top"} | ||
/> | ||
<TabItem | ||
asButton | ||
onClick={() => handleTabChange("latest")} | ||
label="Latest" | ||
isActive={currentTab === "latest"} | ||
/> | ||
</Tabs> | ||
|
||
{currentTab === "latest" && ( | ||
<PostSearchContainer query={url} sort={currentTab} /> | ||
)} | ||
{currentTab === "top" && ( | ||
<PostSearchContainer query={url} sort={currentTab} /> | ||
)} | ||
</section> | ||
); | ||
} |
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