modified: src/components/ui/dropdown-menu.tsx
This commit is contained in:
parent
751f6ae7cd
commit
02265d3a29
6 changed files with 97 additions and 11 deletions
|
|
@ -37,7 +37,9 @@ const buttonVariants = cva(
|
||||||
export interface ButtonProps
|
export interface ButtonProps
|
||||||
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
||||||
VariantProps<typeof buttonVariants> {
|
VariantProps<typeof buttonVariants> {
|
||||||
asChild?: boolean
|
asChild?: boolean;
|
||||||
|
variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link";
|
||||||
|
size?: "default" | "sm" | "lg" | "icon";
|
||||||
}
|
}
|
||||||
|
|
||||||
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
||||||
|
|
|
||||||
|
|
@ -53,4 +53,64 @@ const DialogContent = React.forwardRef<
|
||||||
))
|
))
|
||||||
DialogContent.displayName = DialogPrimitive.Content.displayName
|
DialogContent.displayName = DialogPrimitive.Content.displayName
|
||||||
|
|
||||||
export { Dialog, DialogPortal, DialogOverlay, DialogClose, DialogTrigger, DialogContent }
|
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-slot="dialog-header"
|
||||||
|
className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-slot="dialog-footer"
|
||||||
|
className={cn(
|
||||||
|
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function DialogTitle({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof DialogPrimitive.Title>) {
|
||||||
|
return (
|
||||||
|
<DialogPrimitive.Title
|
||||||
|
data-slot="dialog-title"
|
||||||
|
className={cn("text-lg leading-none font-semibold", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function DialogDescription({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof DialogPrimitive.Description>) {
|
||||||
|
return (
|
||||||
|
<DialogPrimitive.Description
|
||||||
|
data-slot="dialog-description"
|
||||||
|
className={cn("text-muted-foreground text-sm", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
Dialog,
|
||||||
|
DialogPortal,
|
||||||
|
DialogOverlay,
|
||||||
|
DialogClose,
|
||||||
|
DialogTrigger,
|
||||||
|
DialogContent,
|
||||||
|
DialogHeader,
|
||||||
|
DialogFooter,
|
||||||
|
DialogTitle,
|
||||||
|
DialogDescription,
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,18 @@ const DropdownMenuSeparator = React.forwardRef<
|
||||||
))
|
))
|
||||||
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName
|
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName
|
||||||
|
|
||||||
|
const DropdownMenuLabel = React.forwardRef<
|
||||||
|
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<DropdownMenuPrimitive.Label
|
||||||
|
ref={ref}
|
||||||
|
className={cn("px-2 py-1.5 text-sm font-semibold", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
|
||||||
|
|
||||||
export {
|
export {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
|
|
@ -70,4 +82,5 @@ export {
|
||||||
DropdownMenuPortal,
|
DropdownMenuPortal,
|
||||||
DropdownMenuSub,
|
DropdownMenuSub,
|
||||||
DropdownMenuRadioGroup,
|
DropdownMenuRadioGroup,
|
||||||
|
DropdownMenuLabel,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -241,6 +241,7 @@ function DropdownMenuSubContent({
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
DropdownMenu,
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuPortal,
|
DropdownMenuPortal,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
|
|
@ -254,6 +255,14 @@ export {
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuShortcut,
|
DropdownMenuShortcut,
|
||||||
DropdownMenuSub,
|
DropdownMenuSub,
|
||||||
DropdownMenuSubTrigger,
|
|
||||||
DropdownMenuSubContent,
|
DropdownMenuSubContent,
|
||||||
}
|
DropdownMenuSubTrigger,
|
||||||
|
DropdownMenuItem,
|
||||||
|
DropdownMenuCheckboxItem,
|
||||||
|
DropdownMenuRadioGroup,
|
||||||
|
DropdownMenuRadioItem,
|
||||||
|
DropdownMenuSeparator,
|
||||||
|
DropdownMenuShortcut,
|
||||||
|
DropdownMenuSub,
|
||||||
|
DropdownMenuSubContent,
|
||||||
|
DropdownMenuSubTrigger,
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,11 @@ export interface ScriptTemplate {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getTemplatesForPlatform(platform: PlatformId): ScriptTemplate[] {
|
export function getTemplatesForPlatform(platform: PlatformId): ScriptTemplate[] {
|
||||||
return templates.filter(t => t.platform === platform);
|
return templates.filter(t => t.platform === platform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export { getTemplatesForPlatform };
|
||||||
|
|
||||||
const robloxTemplates: ScriptTemplate[] = [
|
const robloxTemplates: ScriptTemplate[] = [
|
||||||
{
|
{
|
||||||
id: 'hello-world',
|
id: 'hello-world',
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
import { PlatformId, getPlatform } from './platforms';
|
import { PlatformId, getPlatform } from './platforms';
|
||||||
import { toast } from 'sonner';
|
import { toast } from 'sonner';
|
||||||
import { captureEvent, captureError } from './analytics';
|
import { trackEvent, trackError } from './analytics';
|
||||||
|
|
||||||
export interface TranslationRequest {
|
export interface TranslationRequest {
|
||||||
sourceCode: string;
|
sourceCode: string;
|
||||||
|
|
@ -199,7 +199,7 @@ async function translateWithClaudeAPI(
|
||||||
const result = parseClaudeResponse(content, request.targetPlatform);
|
const result = parseClaudeResponse(content, request.targetPlatform);
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
captureError(error as Error, {
|
trackError(error as Error, {
|
||||||
context: 'translation_api',
|
context: 'translation_api',
|
||||||
sourcePlatform: request.sourcePlatform,
|
sourcePlatform: request.sourcePlatform,
|
||||||
targetPlatform: request.targetPlatform,
|
targetPlatform: request.targetPlatform,
|
||||||
|
|
@ -292,7 +292,7 @@ export async function translateCode(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log translation attempt
|
// Log translation attempt
|
||||||
captureEvent('translation_started', {
|
trackEvent('translation_started', {
|
||||||
sourcePlatform: request.sourcePlatform,
|
sourcePlatform: request.sourcePlatform,
|
||||||
targetPlatform: request.targetPlatform,
|
targetPlatform: request.targetPlatform,
|
||||||
codeLength: request.sourceCode.length,
|
codeLength: request.sourceCode.length,
|
||||||
|
|
@ -303,7 +303,7 @@ export async function translateCode(
|
||||||
|
|
||||||
// Log result
|
// Log result
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
captureEvent('translation_success', {
|
trackEvent('translation_success', {
|
||||||
sourcePlatform: request.sourcePlatform,
|
sourcePlatform: request.sourcePlatform,
|
||||||
targetPlatform: request.targetPlatform,
|
targetPlatform: request.targetPlatform,
|
||||||
});
|
});
|
||||||
|
|
@ -311,7 +311,7 @@ export async function translateCode(
|
||||||
`Translated ${request.sourcePlatform} → ${request.targetPlatform}`
|
`Translated ${request.sourcePlatform} → ${request.targetPlatform}`
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
captureEvent('translation_failed', {
|
trackEvent('translation_failed', {
|
||||||
sourcePlatform: request.sourcePlatform,
|
sourcePlatform: request.sourcePlatform,
|
||||||
targetPlatform: request.targetPlatform,
|
targetPlatform: request.targetPlatform,
|
||||||
error: result.error,
|
error: result.error,
|
||||||
|
|
@ -321,7 +321,7 @@ export async function translateCode(
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
captureError(error as Error, { context: 'translate_code' });
|
trackError(error as Error, { context: 'translate_code' });
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
error: `Unexpected error: ${(error as Error).message}`,
|
error: `Unexpected error: ${(error as Error).message}`,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue