mirror of
https://github.com/supabase/supabase.git
synced 2026-09-07 02:20:52 +08:00
This PR removes all `paths` in `tsconfig.json` for all apps and packages. They were added previosly because some of the components had a `_Shadcn` suffix because of an ongoing migration. How that the migration is done, the paths can be removed. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Standardized shared UI component, utility, and icon imports across design-system examples and application screens. * Simplified shared component access and project configuration. * Added shared access to anchor-link helpers and animation styles. * **Compatibility** * Updated component exports and imports without changing existing behavior. * No changes to user-facing workflows, screens, or functionality. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
71 lines
1.5 KiB
TypeScript
71 lines
1.5 KiB
TypeScript
import { useMemo, useState } from 'react'
|
|
import { Button } from 'ui'
|
|
import {
|
|
CommandMenu,
|
|
CommandMenuInput,
|
|
CommandMenuList,
|
|
CommandMenuTrigger as CommandMenuTriggerPrimitive,
|
|
CommandProvider,
|
|
useRegisterCommands,
|
|
} from 'ui-patterns/CommandMenu'
|
|
|
|
function Commands() {
|
|
const [activeCommand, setActiveCommand] = useState(1)
|
|
|
|
const toggleCommands = () => setActiveCommand((state) => (state === 1 ? 2 : 1))
|
|
|
|
const commandOne = useMemo(
|
|
() => [
|
|
{
|
|
id: 'one',
|
|
name: 'One',
|
|
action: () => alert('One'),
|
|
},
|
|
],
|
|
[]
|
|
)
|
|
|
|
const commandTwo = useMemo(
|
|
() => [
|
|
{
|
|
id: 'two',
|
|
name: 'Two',
|
|
action: () => alert('Two'),
|
|
},
|
|
],
|
|
[]
|
|
)
|
|
|
|
const command = activeCommand === 1 ? commandOne : commandTwo
|
|
|
|
useRegisterCommands('Commands', command, { deps: [command] })
|
|
|
|
return (
|
|
<Button onClick={toggleCommands}>
|
|
{activeCommand === 1 ? 'Change command to command two' : 'Change command to command one'}
|
|
</Button>
|
|
)
|
|
}
|
|
|
|
function CommandMenuTrigger() {
|
|
return (
|
|
<CommandMenuTriggerPrimitive>
|
|
<Button>Open command menu</Button>
|
|
</CommandMenuTriggerPrimitive>
|
|
)
|
|
}
|
|
|
|
export default function CommandMenuDemo() {
|
|
return (
|
|
<CommandProvider openKey="">
|
|
<div className="flex flex-col gap-2">
|
|
<CommandMenu trigger={<CommandMenuTrigger />}>
|
|
<CommandMenuInput />
|
|
<CommandMenuList />
|
|
</CommandMenu>
|
|
<Commands />
|
|
</div>
|
|
</CommandProvider>
|
|
)
|
|
}
|