mirror of
https://github.com/supabase/supabase.git
synced 2026-05-07 01:10:15 -04:00
56de26fe22
This PR migrates the whole monorepo to use Tailwind v4: - Removed `@tailwindcss/container-queries` plugin since it's included by default in v4, - Bump all instances of Tailwind to v4. Made minimal changes to the shared config to remove non-supported features (`alpha` mentions), - Migrate all apps to be compatible with v4 configs, - Fix the `typography.css` import in 3 apps, - Add missing rules which were included by default in v3, - Run `pnpm dlx @tailwindcss/upgrade` on all apps, which renames a lot of classes - Rename all misnamed classes according to https://tailwindcss.com/docs/upgrade-guide#renamed-utilities in all apps. --------- Co-authored-by: Jordi Enric <jordi.err@gmail.com>
104 lines
3.8 KiB
TypeScript
104 lines
3.8 KiB
TypeScript
'use client'
|
|
|
|
import { motion } from 'framer-motion'
|
|
import { Tabs_Shadcn_, TabsContent_Shadcn_, TabsList_Shadcn_, TabsTrigger_Shadcn_ } from 'ui'
|
|
|
|
import { CommandCopyButton } from './command-copy-button'
|
|
import { useLocalStorage } from './use-local-storage'
|
|
|
|
interface CommandCopyProps {
|
|
name: string
|
|
highlight?: boolean
|
|
// For Vue, we need to use the `shadcn-vue` package instead of `shadcn`
|
|
framework?: 'react' | 'vue'
|
|
}
|
|
|
|
type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun'
|
|
|
|
const LOCAL_STORAGE_KEY = 'package-manager-copy-command'
|
|
|
|
const getBaseUrl = () => {
|
|
if (process.env.NEXT_PUBLIC_VERCEL_TARGET_ENV === 'production') {
|
|
// we have a special alias for the production environment, added in https://github.com/shadcn-ui/ui/pull/8161
|
|
return `@supabase`
|
|
} else if (process.env.NEXT_PUBLIC_VERCEL_TARGET_ENV === 'preview') {
|
|
return `https://${process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL}`
|
|
} else {
|
|
return 'http://localhost:3004'
|
|
}
|
|
}
|
|
|
|
const getComponentPath = (name: string) => {
|
|
if (process.env.NEXT_PUBLIC_VERCEL_TARGET_ENV === 'production') {
|
|
return `/${name}`
|
|
} else {
|
|
return `${process.env.NEXT_PUBLIC_BASE_PATH ?? ''}/r/${name}.json`
|
|
}
|
|
}
|
|
|
|
export function Command({ name, highlight, framework = 'react' }: CommandCopyProps) {
|
|
const [value, setValue] = useLocalStorage(LOCAL_STORAGE_KEY, 'npm')
|
|
|
|
const baseUrl = getBaseUrl()
|
|
const componentPath = getComponentPath(name)
|
|
|
|
const commands: Record<PackageManager, string> =
|
|
framework === 'vue'
|
|
? {
|
|
npm: `npx shadcn-vue@latest add ${baseUrl}${componentPath}`,
|
|
pnpm: `pnpm dlx shadcn-vue@latest add ${baseUrl}${componentPath}`,
|
|
yarn: `yarn dlx shadcn-vue@latest add ${baseUrl}${componentPath}`,
|
|
bun: `bunx --bun shadcn-vue@latest add ${baseUrl}${componentPath}`,
|
|
}
|
|
: {
|
|
npm: `npx shadcn@latest add ${baseUrl}${componentPath}`,
|
|
pnpm: `pnpm dlx shadcn@latest add ${baseUrl}${componentPath}`,
|
|
yarn: `yarn dlx shadcn@latest add ${baseUrl}${componentPath}`,
|
|
bun: `bunx --bun shadcn@latest add ${baseUrl}${componentPath}`,
|
|
}
|
|
|
|
return (
|
|
<Tabs_Shadcn_ value={value} onValueChange={setValue} className="w-full">
|
|
<div className="w-full group relative rounded-lg bg-surface-200 dark:bg-surface-100 px-4 py-2 overflow-hidden">
|
|
{highlight && (
|
|
<motion.div
|
|
className="absolute inset-0 bg-linear-to-l from-transparent via-[#bbb] dark:via-white to-transparent opacity-10 z-0"
|
|
initial={{ x: '100%' }}
|
|
animate={{ x: '-100%' }}
|
|
transition={{
|
|
repeat: Infinity,
|
|
duration: 2.5,
|
|
ease: 'linear',
|
|
repeatType: 'loop',
|
|
}}
|
|
/>
|
|
)}
|
|
|
|
<div className="flex flex-col">
|
|
<TabsList_Shadcn_ className="gap-2 relative mb-2 z-10">
|
|
{(Object.keys(commands) as PackageManager[]).map((manager) => (
|
|
<TabsTrigger_Shadcn_ key={manager} value={manager} className="text-xs">
|
|
{manager}
|
|
</TabsTrigger_Shadcn_>
|
|
))}
|
|
</TabsList_Shadcn_>
|
|
|
|
{(Object.keys(commands) as PackageManager[]).map((manager) => (
|
|
<TabsContent_Shadcn_ key={manager} value={manager} className="m-0">
|
|
<div className="flex items-center">
|
|
<div className="flex-1 font-mono text-sm text-foreground relative z-10">
|
|
<span className="mr-2 text-[#888] select-none">$</span>
|
|
{commands[manager]}
|
|
</div>
|
|
<div className="relative z-10">
|
|
<CommandCopyButton command={commands[manager]} />
|
|
</div>
|
|
</div>
|
|
</TabsContent_Shadcn_>
|
|
))}
|
|
</div>
|
|
</div>
|
|
</Tabs_Shadcn_>
|
|
)
|
|
}
|