mirror of
https://github.com/supabase/supabase.git
synced 2026-10-11 04:15:04 +03:00
This PR moves several components which rely on `next` out of the `ui` package to the `ui-patterns` package. `ui-patterns` package is intented to be imported with specific imports so it's ok if there are components reliant on `next` in there. The `SonnerToaster` component has removed its dependency by requiring a prop for `theme`.
75 lines
2.0 KiB
TypeScript
75 lines
2.0 KiB
TypeScript
import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock'
|
|
|
|
import type { ContentFileProps } from '@/components/interfaces/Connect/Connect.types'
|
|
import {
|
|
ConnectTabContent,
|
|
ConnectTabs,
|
|
ConnectTabTrigger,
|
|
ConnectTabTriggers,
|
|
} from '@/components/interfaces/Connect/ConnectTabs'
|
|
|
|
const ContentFile = ({ projectKeys }: ContentFileProps) => {
|
|
return (
|
|
<ConnectTabs>
|
|
<ConnectTabTriggers>
|
|
<ConnectTabTrigger value=".env" />
|
|
<ConnectTabTrigger value="src/utils/supabase.ts" />
|
|
<ConnectTabTrigger value="src/routes/index.tsx" />
|
|
</ConnectTabTriggers>
|
|
|
|
<ConnectTabContent value=".env">
|
|
<SimpleCodeBlock className="bash" parentClassName="min-h-72">
|
|
{`
|
|
VITE_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}
|
|
VITE_SUPABASE_KEY=${projectKeys.publishableKey ?? projectKeys.anonKey ?? 'your-anon-key'}
|
|
`}
|
|
</SimpleCodeBlock>
|
|
</ConnectTabContent>
|
|
|
|
<ConnectTabContent value="src/utils/supabase.ts">
|
|
<SimpleCodeBlock className="ts" parentClassName="min-h-72">
|
|
{`
|
|
import { createClient } from "@supabase/supabase-js";
|
|
|
|
export const supabase = createClient(
|
|
import.meta.env.VITE_SUPABASE_URL,
|
|
import.meta.env.VITE_SUPABASE_KEY
|
|
);
|
|
`}
|
|
</SimpleCodeBlock>
|
|
</ConnectTabContent>
|
|
|
|
<ConnectTabContent value="src/routes/index.tsx">
|
|
<SimpleCodeBlock className="tsx" parentClassName="min-h-72">
|
|
{`
|
|
import { createFileRoute } from '@tanstack/react-router'
|
|
import { supabase } from '../utils/supabase'
|
|
|
|
export const Route = createFileRoute('/')({
|
|
loader: async () => {
|
|
const { data: todos } = await supabase.from('todos').select()
|
|
return { todos }
|
|
},
|
|
component: Home,
|
|
})
|
|
|
|
function Home() {
|
|
const { todos } = Route.useLoaderData()
|
|
|
|
return (
|
|
<ul>
|
|
{todos?.map((todo) => (
|
|
<li key={todo.id}>{todo.name}</li>
|
|
))}
|
|
</ul>
|
|
)
|
|
}
|
|
`}
|
|
</SimpleCodeBlock>
|
|
</ConnectTabContent>
|
|
</ConnectTabs>
|
|
)
|
|
}
|
|
|
|
export default ContentFile
|