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

feat(GIST-99): card code preview #41

Merged
merged 1 commit into from
Nov 14, 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
2 changes: 1 addition & 1 deletion src/app/(gistLayout)/mygist/page-ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function MyGistsPage({}: MyGistPageProps) {
<PaginationProvider fromUrl>
<MyGistListFeature />
<div className="h-[1px] bg-border"></div>
<div className="p-4">
<div className="py-4 px-6 flex flex-row justify-between items-center rounded-b-lg border-border border-l border-b border-r">
<PaginationComponent />
</div>
</PaginationProvider>
Expand Down
25 changes: 23 additions & 2 deletions src/components/ui/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
import { Trash2 } from "lucide-react"
import Shortcut from "./shortcut"
import { Gist } from "@/types"
import { Codearea } from "../shadcn/codearea"
import { getLanguage } from "@/lib/language"

interface CardProps {
gist: Gist
Expand All @@ -20,13 +22,32 @@ interface CardProps {
}

export default function Card({ gist, href, onDeleteGist }: CardProps) {
const language = getLanguage(gist.name)

return (
<ContextMenu>
<ContextMenuTrigger className="flex items-center justify-start rounded-md text-sm font-semibold text-slate-400 w-full">
<Link href={href} passHref className="relative hover:border-primary border-border border group w-full h-full">
<ContextMenuTrigger>
<Link
href={href}
passHref
className="relative flex items-center justify-start hover:border-primary transition-all group/card border-border border group w-full h-full overflow-hidden"
>
<Badge className="absolute bottom-8 left-8" variant={"title"}>
{gist.name}
</Badge>
<div className={`${gist.code === "" ? "flex w-full items-center justify-center" : "absolute inset-0 -z-10"}`}>
{gist.code !== "" ? (
<Codearea
className="w-full h-full rounded-none opacity-50 group-hover/card:opacity-100 transition-all duration-200 border-none p-4"
value={gist.code}
language={language}
/>
) : (
<div className="text-[10px] opacity-50 group-hover/card:opacity-100 transition-all duration-200 p-4 text-gray-500">
Gist empty
</div>
)}
</div>
</Link>
</ContextMenuTrigger>
<ContextMenuContent className="w-64">
Expand Down
Loading