Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Chore/custom content example projects (#38086)

Joshen Lim0beba891d331
diff --git a/apps/studio/components/interfaces/Home/ExampleProject.tsx b/apps/studio/components/interfaces/Home/ExampleProject.tsx
index 13a10c1a00b..8f6ba8c5736 100644
--- a/apps/studio/components/interfaces/Home/ExampleProject.tsx
+++ b/apps/studio/components/interfaces/Home/ExampleProject.tsx
@@ -6,20 +6,39 @@ import { useParams } from 'common'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
import { BASE_PATH } from 'lib/constants'
+import { cn } from 'ui'
interface ExampleProjectProps {
- framework: string
title: string
description: string
url: string
+ framework?: string
+ iconUrl?: string
}
-const ExampleProject = ({ framework, title, description, url }: ExampleProjectProps) => {
+export const ExampleProject = ({
+ framework,
+ title,
+ description,
+ url,
+ iconUrl,
+}: ExampleProjectProps) => {
const { resolvedTheme } = useTheme()
const { ref: projectRef } = useParams()
const { data: org } = useSelectedOrganizationQuery()
const { mutate: sendEvent } = useSendEventMutation()
+ const iconImgSrc = iconUrl
+ ? iconUrl
+ : !!framework
+ ? `${BASE_PATH}/img/libraries/${framework.toLowerCase()}${
+ ['expo', 'nextjs'].includes(framework.toLowerCase())
+ ? resolvedTheme?.includes('dark')
+ ? '-dark'
+ : ''
+ : ''
+ }-icon.svg`
+ : ''
return (
<Link
@@ -35,23 +54,17 @@ const ExampleProject = ({ framework, title, description, url }: ExampleProjectPr
}
>
<div
- className={[
+ className={cn(
'group relative',
'border bg-surface-100 border-overlay',
'flex h-32 flex-row rounded-md p-4 hover:bg-overlay-hover',
- 'transition duration-150 ease-in-out',
- ].join(' ')}
+ 'transition duration-150 ease-in-out'
+ )}
>
<div className="mr-4 flex flex-col">
<img
className="transition-all group-hover:scale-110"
- src={`${BASE_PATH}/img/libraries/${framework.toLowerCase()}${
- ['expo', 'nextjs'].includes(framework.toLowerCase())
- ? resolvedTheme?.includes('dark')
- ? '-dark'
- : ''
- : ''
- }-icon.svg`}
+ src={iconImgSrc}
alt={`${framework} logo`}
width={26}
height={26}
@@ -62,16 +75,11 @@ const ExampleProject = ({ framework, title, description, url }: ExampleProjectPr
<p className="text-sm text-foreground-light">{description}</p>
</div>
<div
- className="
- absolute
- right-4
- top-3
- text-foreground-lighter
- transition-all
- duration-200
- group-hover:right-3
- group-hover:text-foreground
- "
+ className={cn(
+ 'absolute right-4 top-3',
+ 'text-foreground-lighter transition-all duration-200',
+ 'group-hover:right-3 group-hover:text-foreground'
+ )}
>
<ChevronRight />
</div>
@@ -79,5 +87,3 @@ const ExampleProject = ({ framework, title, description, url }: ExampleProjectPr
</Link>
)
}
-
-export default ExampleProject
diff --git a/apps/studio/components/interfaces/Home/index.ts b/apps/studio/components/interfaces/Home/index.ts
index 5780ca6d194..708725f92ed 100644
--- a/apps/studio/components/interfaces/Home/index.ts
+++ b/apps/studio/components/interfaces/Home/index.ts
@@ -1,2 +1 @@
export { default as ClientLibrary } from './ClientLibrary'
-export { default as ExampleProject } from './ExampleProject'
diff --git a/apps/studio/components/layouts/ProjectLayout/BuildingState.tsx b/apps/studio/components/layouts/ProjectLayout/BuildingState.tsx
index e52bae2142d..90f91b16710 100644
--- a/apps/studio/components/layouts/ProjectLayout/BuildingState.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/BuildingState.tsx
@@ -5,7 +5,7 @@ import { useMemo } from 'react'
import { useParams } from 'common'
import ClientLibrary from 'components/interfaces/Home/ClientLibrary'
-import ExampleProject from 'components/interfaces/Home/ExampleProject'
+import { ExampleProject } from 'components/interfaces/Home/ExampleProject'
import { CLIENT_LIBRARIES, EXAMPLE_PROJECTS } from 'components/interfaces/Home/Home.constants'
import { DisplayApiSettings, DisplayConfigSettings } from 'components/ui/ProjectSettings'
import { invalidateProjectDetailsQuery } from 'data/projects/project-detail-query'
diff --git a/apps/studio/hooks/custom-content/CustomContent.types.ts b/apps/studio/hooks/custom-content/CustomContent.types.ts
index 0c0e6be07e3..57bfadada57 100644
--- a/apps/studio/hooks/custom-content/CustomContent.types.ts
+++ b/apps/studio/hooks/custom-content/CustomContent.types.ts
@@ -5,4 +5,10 @@ export type CustomContentTypes = {
description: string
action: { text: string; url: string }
}[]
+ projectHomepageExampleProjects: {
+ title: string
+ description: string
+ iconUrl: string
+ url: string
+ }[]
}
diff --git a/apps/studio/hooks/custom-content/custom-content.json b/apps/studio/hooks/custom-content/custom-content.json
index 5b7291b0d30..eb9035fde27 100644
--- a/apps/studio/hooks/custom-content/custom-content.json
+++ b/apps/studio/hooks/custom-content/custom-content.json
@@ -1,5 +1,7 @@
{
"$schema": "./custom-content.schema.json",
- "organization:legal_documents": null
+ "organization:legal_documents": null,
+
+ "project_homepage:example_projects": null
}
diff --git a/apps/studio/hooks/custom-content/custom-content.sample.json b/apps/studio/hooks/custom-content/custom-content.sample.json
index 1a6af8b9418..b9454c592b4 100644
--- a/apps/studio/hooks/custom-content/custom-content.sample.json
+++ b/apps/studio/hooks/custom-content/custom-content.sample.json
@@ -20,5 +20,20 @@
"url": "https://supabase.com"
}
}
+ ],
+
+ "project_homepage:example_projects": [
+ {
+ "title": "Framework 1",
+ "description": "This is a description of Framework 1",
+ "iconUrl": "https://supabase.com/dashboard/img/supabase-logo.svg",
+ "url": "https://supabase.com"
+ },
+ {
+ "title": "Framework 2",
+ "description": "This is a description of Framework 2",
+ "iconUrl": "https://supabase.com/dashboard/img/supabase-logo.svg",
+ "url": "https://supabase.com"
+ }
]
}
diff --git a/apps/studio/hooks/custom-content/custom-content.schema.json b/apps/studio/hooks/custom-content/custom-content.schema.json
index 8c645146a82..9d67dae109e 100644
--- a/apps/studio/hooks/custom-content/custom-content.schema.json
+++ b/apps/studio/hooks/custom-content/custom-content.schema.json
@@ -24,8 +24,21 @@
}
}
}
+ },
+ "project_homepage:example_projects": {
+ "type": ["array", "null"],
+ "description": "Renders a provided set of example projects under the project's home page",
+ "items": {
+ "type": "object",
+ "properties": {
+ "title": { "type": "string" },
+ "description": { "type": "string" },
+ "iconUrl": { "type": "string" },
+ "url": { "type": "string" }
+ }
+ }
}
},
- "required": ["organization:legal_documents"],
+ "required": ["organization:legal_documents", "project_homepage:example_projects"],
"additionalProperties": false
}
diff --git a/apps/studio/pages/project/[ref]/index.tsx b/apps/studio/pages/project/[ref]/index.tsx
index f075fd2b228..567ecaa1800 100644
--- a/apps/studio/pages/project/[ref]/index.tsx
+++ b/apps/studio/pages/project/[ref]/index.tsx
@@ -3,8 +3,9 @@ import Link from 'next/link'
import { useEffect, useMemo, useRef } from 'react'
import { useParams } from 'common'
-import { ClientLibrary, ExampleProject } from 'components/interfaces/Home'
+import { ClientLibrary } from 'components/interfaces/Home'
import { AdvisorWidget } from 'components/interfaces/Home/AdvisorWidget'
+import { ExampleProject } from 'components/interfaces/Home/ExampleProject'
import { CLIENT_LIBRARIES, EXAMPLE_PROJECTS } from 'components/interfaces/Home/Home.constants'
import { NewProjectPanel } from 'components/interfaces/Home/NewProjectPanel/NewProjectPanel'
import { ProjectUsageSection } from 'components/interfaces/Home/ProjectUsageSection'
@@ -19,6 +20,7 @@ import { useBranchesQuery } from 'data/branches/branches-query'
import { useEdgeFunctionsQuery } from 'data/edge-functions/edge-functions-query'
import { useReadReplicasQuery } from 'data/read-replicas/replicas-query'
import { useTablesQuery } from 'data/tables/tables-query'
+import { useCustomContent } from 'hooks/custom-content/useCustomContent'
import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
import {
@@ -50,6 +52,8 @@ const Home: NextPageWithLayout = () => {
const snap = useAppStateSnapshot()
const { ref, enableBranching } = useParams()
+ const { projectHomepageExampleProjects } = useCustomContent(['project_homepage:example_projects'])
+
const {
projectHomepageShowAllClientLibraries: showAllClientLibraries,
projectHomepageShowInstanceSize: showInstanceSize,
@@ -243,36 +247,46 @@ const Home: NextPageWithLayout = () => {
</div>
</div>
{showExamples && (
- <div className="space-y-8">
+ <div className="flex flex-col gap-y-8">
<h4 className="text-lg">Example projects</h4>
- <div className="flex justify-center">
- <Tabs_Shadcn_ defaultValue="app" className="w-full">
- <TabsList_Shadcn_ className="flex gap-4 mb-8">
- <TabsTrigger_Shadcn_ value="app">App Frameworks</TabsTrigger_Shadcn_>
- <TabsTrigger_Shadcn_ value="mobile">
- Mobile Frameworks
- </TabsTrigger_Shadcn_>
- </TabsList_Shadcn_>
- <TabsContent_Shadcn_ value="app">
- <div className="grid gap-2 md:gap-8 md:grid-cols-2 lg:grid-cols-3">
- {EXAMPLE_PROJECTS.filter((project) => project.type === 'app')
- .sort((a, b) => a.title.localeCompare(b.title))
- .map((project) => (
- <ExampleProject key={project.url} {...project} />
- ))}
- </div>
- </TabsContent_Shadcn_>
- <TabsContent_Shadcn_ value="mobile">
- <div className="grid gap-2 md:gap-8 md:grid-cols-2 lg:grid-cols-3">
- {EXAMPLE_PROJECTS.filter((project) => project.type === 'mobile')
- .sort((a, b) => a.title.localeCompare(b.title))
- .map((project) => (
- <ExampleProject key={project.url} {...project} />
- ))}
- </div>
- </TabsContent_Shadcn_>
- </Tabs_Shadcn_>
- </div>
+ {!!projectHomepageExampleProjects ? (
+ <div className="grid gap-2 md:gap-8 md:grid-cols-2 lg:grid-cols-3">
+ {projectHomepageExampleProjects
+ .sort((a, b) => a.title.localeCompare(b.title))
+ .map((project) => (
+ <ExampleProject key={project.url} {...project} />
+ ))}
+ </div>
+ ) : (
+ <div className="flex justify-center">
+ <Tabs_Shadcn_ defaultValue="app" className="w-full">
+ <TabsList_Shadcn_ className="flex gap-4 mb-8">
+ <TabsTrigger_Shadcn_ value="app">App Frameworks</TabsTrigger_Shadcn_>
+ <TabsTrigger_Shadcn_ value="mobile">
+ Mobile Frameworks
+ </TabsTrigger_Shadcn_>
+ </TabsList_Shadcn_>
+ <TabsContent_Shadcn_ value="app">
+ <div className="grid gap-2 md:gap-8 md:grid-cols-2 lg:grid-cols-3">
+ {EXAMPLE_PROJECTS.filter((project) => project.type === 'app')
+ .sort((a, b) => a.title.localeCompare(b.title))
+ .map((project) => (
+ <ExampleProject key={project.url} {...project} />
+ ))}
+ </div>
+ </TabsContent_Shadcn_>
+ <TabsContent_Shadcn_ value="mobile">
+ <div className="grid gap-2 md:gap-8 md:grid-cols-2 lg:grid-cols-3">
+ {EXAMPLE_PROJECTS.filter((project) => project.type === 'mobile')
+ .sort((a, b) => a.title.localeCompare(b.title))
+ .map((project) => (
+ <ExampleProject key={project.url} {...project} />
+ ))}
+ </div>
+ </TabsContent_Shadcn_>
+ </Tabs_Shadcn_>
+ </div>
+ )}
</div>
)}
</>