feat: update project icon for each template type

This commit is contained in:
Hamzat Victor 2024-09-24 14:10:56 +01:00
parent b7230f1bc4
commit 0f619ccb7d
3 changed files with 43 additions and 49 deletions

View File

@ -36,43 +36,7 @@ import { createSandbox } from "@/lib/actions"
import { useRouter } from "next/navigation"
import { Loader2 } from "lucide-react"
import { Button } from "../ui/button"
const data: {
id: string
name: string
icon: string
description: string
disabled: boolean
}[] = [
{
id: "reactjs",
name: "React",
icon: "/project-icons/react.svg",
description: "A JavaScript library for building user interfaces",
disabled: false,
},
{
id: "vanillajs",
name: "HTML/JS",
icon: "/project-icons/more.svg",
description: "More coming soon, feel free to contribute on GitHub",
disabled: false,
},
{
id: "nextjs",
name: "NextJS",
icon: "/project-icons/node.svg",
description: "A JavaScript runtime built on the V8 JavaScript engine",
disabled: false,
},
{
id: "streamlit",
name: "Streamlit",
icon: "/project-icons/python.svg",
description: "A JavaScript runtime built on the V8 JavaScript engine",
disabled: false,
},
]
import { projectTemplates } from "@/lib/data"
const formSchema = z.object({
name: z
@ -129,7 +93,7 @@ export default function NewProjectModal({
<DialogTitle>Create A Sandbox</DialogTitle>
</DialogHeader>
<div className="grid grid-cols-2 w-full gap-2 mt-2">
{data.map((item) => (
{projectTemplates.map((item) => (
<button
disabled={item.disabled || loading}
key={item.id}

View File

@ -8,6 +8,7 @@ import { Clock, Globe, Lock } from "lucide-react"
import { Sandbox } from "@/lib/types"
import { Card } from "@/components/ui/card"
import { useRouter } from "next/navigation"
import { projectTemplates } from "@/lib/data"
export default function ProjectCard({
children,
@ -43,7 +44,9 @@ export default function ProjectCard({
setDate(`${Math.floor(diffInMinutes / 1440)}d ago`)
}
}, [sandbox])
const projectIcon =
projectTemplates.find((p) => p.id === sandbox.type)?.icon ??
"/project-icons/node.svg"
return (
<Card
tabIndex={0}
@ -65,16 +68,7 @@ export default function ProjectCard({
</AnimatePresence>
<div className="space-x-2 flex items-center justify-start w-full z-10">
<Image
alt=""
src={
sandbox.type === "react"
? "/project-icons/react.svg"
: "/project-icons/node.svg"
}
width={20}
height={20}
/>
<Image alt="" src={projectIcon} width={20} height={20} />
<div className="font-medium static whitespace-nowrap w-full text-ellipsis overflow-hidden">
{sandbox.name}
</div>

View File

@ -0,0 +1,36 @@
export const projectTemplates: {
id: string
name: string
icon: string
description: string
disabled: boolean
}[] = [
{
id: "reactjs",
name: "React",
icon: "/project-icons/react.svg",
description: "A JavaScript library for building user interfaces",
disabled: false,
},
{
id: "vanillajs",
name: "HTML/JS",
icon: "/project-icons/more.svg",
description: "More coming soon, feel free to contribute on GitHub",
disabled: false,
},
{
id: "nextjs",
name: "NextJS",
icon: "/project-icons/node.svg",
description: "A JavaScript runtime built on the V8 JavaScript engine",
disabled: false,
},
{
id: "streamlit",
name: "Streamlit",
icon: "/project-icons/python.svg",
description: "A JavaScript runtime built on the V8 JavaScript engine",
disabled: false,
},
]