feat: update project icon for each template type
This commit is contained in:
parent
b7230f1bc4
commit
0f619ccb7d
@ -36,43 +36,7 @@ import { createSandbox } from "@/lib/actions"
|
|||||||
import { useRouter } from "next/navigation"
|
import { useRouter } from "next/navigation"
|
||||||
import { Loader2 } from "lucide-react"
|
import { Loader2 } from "lucide-react"
|
||||||
import { Button } from "../ui/button"
|
import { Button } from "../ui/button"
|
||||||
|
import { projectTemplates } from "@/lib/data"
|
||||||
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,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
name: z
|
name: z
|
||||||
@ -129,7 +93,7 @@ export default function NewProjectModal({
|
|||||||
<DialogTitle>Create A Sandbox</DialogTitle>
|
<DialogTitle>Create A Sandbox</DialogTitle>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<div className="grid grid-cols-2 w-full gap-2 mt-2">
|
<div className="grid grid-cols-2 w-full gap-2 mt-2">
|
||||||
{data.map((item) => (
|
{projectTemplates.map((item) => (
|
||||||
<button
|
<button
|
||||||
disabled={item.disabled || loading}
|
disabled={item.disabled || loading}
|
||||||
key={item.id}
|
key={item.id}
|
||||||
|
@ -8,6 +8,7 @@ import { Clock, Globe, Lock } from "lucide-react"
|
|||||||
import { Sandbox } from "@/lib/types"
|
import { Sandbox } from "@/lib/types"
|
||||||
import { Card } from "@/components/ui/card"
|
import { Card } from "@/components/ui/card"
|
||||||
import { useRouter } from "next/navigation"
|
import { useRouter } from "next/navigation"
|
||||||
|
import { projectTemplates } from "@/lib/data"
|
||||||
|
|
||||||
export default function ProjectCard({
|
export default function ProjectCard({
|
||||||
children,
|
children,
|
||||||
@ -43,7 +44,9 @@ export default function ProjectCard({
|
|||||||
setDate(`${Math.floor(diffInMinutes / 1440)}d ago`)
|
setDate(`${Math.floor(diffInMinutes / 1440)}d ago`)
|
||||||
}
|
}
|
||||||
}, [sandbox])
|
}, [sandbox])
|
||||||
|
const projectIcon =
|
||||||
|
projectTemplates.find((p) => p.id === sandbox.type)?.icon ??
|
||||||
|
"/project-icons/node.svg"
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
@ -65,16 +68,7 @@ export default function ProjectCard({
|
|||||||
</AnimatePresence>
|
</AnimatePresence>
|
||||||
|
|
||||||
<div className="space-x-2 flex items-center justify-start w-full z-10">
|
<div className="space-x-2 flex items-center justify-start w-full z-10">
|
||||||
<Image
|
<Image alt="" src={projectIcon} width={20} height={20} />
|
||||||
alt=""
|
|
||||||
src={
|
|
||||||
sandbox.type === "react"
|
|
||||||
? "/project-icons/react.svg"
|
|
||||||
: "/project-icons/node.svg"
|
|
||||||
}
|
|
||||||
width={20}
|
|
||||||
height={20}
|
|
||||||
/>
|
|
||||||
<div className="font-medium static whitespace-nowrap w-full text-ellipsis overflow-hidden">
|
<div className="font-medium static whitespace-nowrap w-full text-ellipsis overflow-hidden">
|
||||||
{sandbox.name}
|
{sandbox.name}
|
||||||
</div>
|
</div>
|
||||||
|
36
frontend/lib/data/index.ts
Normal file
36
frontend/lib/data/index.ts
Normal 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,
|
||||||
|
},
|
||||||
|
]
|
Loading…
x
Reference in New Issue
Block a user