-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(apps/kampus): Add pano home page (#570)
# Description Epic: #566 This PR is in progress but still open to review :) --------- Co-authored-by: Umut Sirin <[email protected]>
- Loading branch information
Showing
16 changed files
with
255 additions
and
103 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
2 changes: 1 addition & 1 deletion
2
...p/pano/features/filter/PanoFilterLink.tsx → ...o/features/post-filter/PanoFilterLink.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
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
File renamed without changes.
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 @@ | ||
import { MoreHorizontal } from "lucide-react"; | ||
|
||
import { | ||
Button, | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuTrigger, | ||
} from "@kampus/ui-next"; | ||
|
||
interface Props { | ||
post: Post; | ||
shareUrl: string; | ||
} | ||
|
||
type Post = { | ||
__typename?: "PanoPost"; | ||
content: string; | ||
createdAt: string; | ||
id: string; | ||
owner: string; | ||
title: string; | ||
url: string; | ||
}; | ||
|
||
export const MoreOptionsDropdown = ({ post, shareUrl }: Props) => { | ||
// const user = useUserContext(); | ||
console.log(post, shareUrl); | ||
|
||
const ownerItems: JSX.Element[] = []; | ||
// if (canUserEdit(user, post)) { | ||
// ownerItems.push( | ||
// <Item onSelect={() => navigate(`/posts/${post.id}/edit`)} key="edit"> | ||
// Düzenle | ||
// </Item> | ||
// ); | ||
// ownerItems.push( | ||
// <Item onSelect={handleOpen} key="delete"> | ||
// Sil | ||
// </Item> | ||
// ); | ||
// ownerItems.push(<DropdownMenuSeparator key="separator" />); | ||
// } | ||
|
||
// // FIXME: below appears to be redundant, is it? | ||
// const menuItems = [...ownerItems]; | ||
|
||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button className="h-5 p-1" variant="ghost"> | ||
<MoreHorizontal size="16" aria-label="Daha fazla seçenek" /> | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent> | ||
{ownerItems} | ||
<DropdownMenuItem>Adresi kopyala</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
}; |
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 NextLink from "next/link"; | ||
|
||
import { cn } from "@kampus/ui-next/utils"; | ||
|
||
import { MoreOptionsDropdown } from "./MoreOptions"; | ||
import { UpvoteButton } from "./PostUpvoteButton"; | ||
|
||
type Post = { | ||
__typename?: "PanoPost"; | ||
content: string; | ||
createdAt: string; | ||
id: string; | ||
owner: string; | ||
title: string; | ||
url: string; | ||
}; | ||
|
||
type PostItemProps = { | ||
post: Post; | ||
showContent?: boolean; | ||
}; | ||
|
||
interface LinkProps { | ||
href: string; | ||
title: string; | ||
className?: string; | ||
} | ||
|
||
const Link = ({ href, title, className }: LinkProps) => { | ||
return ( | ||
<NextLink className={cn("text-muted-foreground hover:underline", className)} href={href}> | ||
{title} | ||
</NextLink> | ||
); | ||
}; | ||
export const PostItem = (props: PostItemProps) => { | ||
return ( | ||
<div className="mr-1 flex h-full gap-1 border-l-2"> | ||
<div className="ml-1 flex h-full"> | ||
<UpvoteButton upvoteCount={5} isUpvoted={false} disabled={false} isVoting={false} /> | ||
</div> | ||
<div className="flex w-full flex-col justify-center"> | ||
<div className="flex items-center gap-1 align-baseline"> | ||
<Link title={props.post.title} href={props.post.url} /> | ||
<Link className="text-sm" title="wow.sh" href={props.post.url} /> | ||
</div> | ||
<div className="flex items-center gap-1 text-sm"> | ||
<div>@{props.post.owner} |</div> | ||
<div>{<Link title="0 yorum" href={`/pano/post/${props.post.id}/`} />} |</div> | ||
<div>{props.post.createdAt} |</div> | ||
<MoreOptionsDropdown post={props.post} shareUrl={props.post.url} /> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
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,27 @@ | ||
import { PostItem } from "./PostItem"; | ||
|
||
type Post = { | ||
__typename?: "PanoPost"; | ||
content: string; | ||
createdAt: string; | ||
id: string; | ||
owner: string; | ||
title: string; | ||
url: string; | ||
}; | ||
|
||
interface PostListProps { | ||
posts: Post[]; | ||
} | ||
|
||
export const PostList = (props: PostListProps) => { | ||
const { posts } = props; | ||
|
||
return ( | ||
<div className="flex flex-col gap-3"> | ||
{posts.map((post) => { | ||
return <PostItem key={post.id} post={post} />; | ||
})} | ||
</div> | ||
); | ||
}; |
26 changes: 26 additions & 0 deletions
26
apps/kampus/app/pano/features/post-list/PostUpvoteButton.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,26 @@ | ||
import { Triangle } from "lucide-react"; | ||
|
||
import { Button } from "@kampus/ui-next"; | ||
import { cn } from "@kampus/ui-next/utils"; | ||
|
||
interface UpvoteProps { | ||
isUpvoted: boolean; | ||
upvoteCount: number; | ||
isVoting: boolean; | ||
disabled?: boolean; | ||
} | ||
|
||
export const UpvoteButton = (props: UpvoteProps) => { | ||
const upvoteStyle = props.isUpvoted ? "fill-primary" : "fill-none"; | ||
const opacity = props.isVoting ? "opacity-50" : "opacity-100"; | ||
const combinedStyle = cn(upvoteStyle, opacity); | ||
|
||
return ( | ||
<Button className="flex h-full items-center pt-3" variant="ghost"> | ||
<div className="flex flex-col items-center justify-center"> | ||
<Triangle className={combinedStyle} size={12} /> | ||
{`${props.upvoteCount}`} | ||
</div> | ||
</Button> | ||
); | ||
}; |
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,11 @@ | ||
export default function PanoLayout({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<section | ||
aria-label="PanoLayout" | ||
role="contentinfo" | ||
className="bg-background container mx-auto max-w-5xl py-10" | ||
> | ||
{children} | ||
</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
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,22 +1,42 @@ | ||
import { PostSortFilters } from "~/app/pano/features/filter/PostSortFilters"; | ||
import { PostSortFilters } from "~/app/pano/features/post-filter/PostSortFilters"; | ||
import { PostList } from "../features/post-list/PostList"; | ||
|
||
export default function PostsPage() { | ||
const posts = [ | ||
{ id: 1, title: "Post1" }, | ||
{ id: 2, title: "Post2" }, | ||
{ id: 3, title: "Post3" }, | ||
]; | ||
type Post = { | ||
__typename?: "PanoPost"; | ||
content: string; | ||
createdAt: string; | ||
id: string; | ||
owner: string; | ||
title: string; | ||
url: string; | ||
}; | ||
|
||
const posts: Post[] = [ | ||
{ | ||
__typename: "PanoPost", | ||
content: "Muthis", | ||
createdAt: "1 ay once", | ||
id: "1", | ||
owner: "Can", | ||
title: "Can'in muthis postu", | ||
url: "wow.sh", | ||
}, | ||
{ | ||
__typename: "PanoPost", | ||
content: "Yuppi", | ||
createdAt: "1 hafta once", | ||
id: "2", | ||
owner: "Vladik", | ||
title: "Vladik'in muthis postu", | ||
url: "https://wow.sh", | ||
}, | ||
]; | ||
|
||
export default function PostsPage() { | ||
return ( | ||
<div> | ||
<div className="flex flex-col gap-4"> | ||
<PostSortFilters /> | ||
{posts.map((post) => { | ||
return ( | ||
<div key={post.id}> | ||
<a href={`/pano/post/${post.id}`}>{post.title}</a> | ||
</div> | ||
); | ||
})} | ||
<PostList posts={posts} /> | ||
</div> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
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,11 +1,19 @@ | ||
export * from "./alert-dialog"; | ||
export * from "./avatar"; | ||
export * from "./button"; | ||
export * from "./dialog"; | ||
export * from "./dropdown-menu"; | ||
export * from "./input-with-button"; | ||
export * from "./input"; | ||
export * from "./button"; | ||
export * from "./top-nav"; | ||
export * from "./label"; | ||
export * from "./loading"; | ||
export * from "./select"; | ||
export * from "./separator"; | ||
export * from "./textarea"; | ||
export * from "./theme-provider"; | ||
export * from "./theme-toggle"; | ||
export * from "./user-avatar"; | ||
export * from "./time-ago"; | ||
export * from "./social-media-buttons"; | ||
export * from "./loading"; | ||
export * from "./toast"; | ||
export * from "./top-nav"; | ||
export * from "./use-toast"; | ||
export * from "./user-avatar"; |
Oops, something went wrong.