From 229306a46ed3008db884bf938d89b7b80f4db541 Mon Sep 17 00:00:00 2001 From: Varshan Maji Date: Tue, 11 Mar 2025 16:07:17 +0530 Subject: [PATCH] added export functionality to github --- .DS_Store | Bin 0 -> 6148 bytes mobile-magic/apps/frontend/app/layout.tsx | 4 +- .../apps/frontend/components/Appbar.tsx | 5 +- .../frontend/components/ExportOptions.tsx | 78 + .../apps/frontend/components/Header.tsx | 10 +- .../frontend/components/ui/dropdown-menu.tsx | 53 + mobile-magic/apps/frontend/package.json | 10 +- mobile-magic/package-lock.json | 13579 ++++++++++++++++ 8 files changed, 13728 insertions(+), 11 deletions(-) create mode 100644 .DS_Store create mode 100644 mobile-magic/apps/frontend/components/ExportOptions.tsx create mode 100644 mobile-magic/apps/frontend/components/ui/dropdown-menu.tsx create mode 100644 mobile-magic/package-lock.json diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 - + {children} @@ -61,4 +62,3 @@ export default function RootLayout({ } // grid px-4 grid-cols-[1fr_min(640px,100%)_1fr] xl:grid-cols-[1fr_minmax(auto,10rem)_min(640px,100%)_minmax(auto,10rem)_1fr] xl:gap-x-9 xl:px-0 [&>*]:col-start-2 xl:[&>*]:col-start-3 - diff --git a/mobile-magic/apps/frontend/components/Appbar.tsx b/mobile-magic/apps/frontend/components/Appbar.tsx index 5053343..f6133e3 100644 --- a/mobile-magic/apps/frontend/components/Appbar.tsx +++ b/mobile-magic/apps/frontend/components/Appbar.tsx @@ -13,6 +13,8 @@ import { containerVariants, itemVariants } from '@/lib/animation-variants' import { ThemeButton } from '@/components/theme-button' export function Appbar() { + const repoUrl = `https://github.com/VarshanMaj1/mobile-magic`; + return ( -
+
@@ -50,4 +52,3 @@ export function Appbar() { ); } - diff --git a/mobile-magic/apps/frontend/components/ExportOptions.tsx b/mobile-magic/apps/frontend/components/ExportOptions.tsx new file mode 100644 index 0000000..a8c804f --- /dev/null +++ b/mobile-magic/apps/frontend/components/ExportOptions.tsx @@ -0,0 +1,78 @@ +import { Button } from '@/components/ui/button' +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, +} from '@/components/ui/dropdown-menu' +import { GitHubLogoIcon, FileIcon, DownloadIcon } from '@radix-ui/react-icons' +import { toast } from 'sonner' + +interface ExportOptionsProps { + repoUrl?: string + onExport?: (type: 'github' | 'https' | 'ssh' | 'cli') => void +} + +export const ExportOptions = ({ repoUrl, onExport }: ExportOptionsProps) => { + const handleCopy = (text: string, type: string) => { + navigator.clipboard.writeText(text) + toast.success(`Copied ${type} URL to clipboard`) + } + + return ( + + + + + +
+
+ + Clone +
+
+ Select a cloning method to get the project URL +
+
+ { + handleCopy(`${repoUrl || ''}`, 'HTTPS'); + onExport?.('https'); + }} + > + HTTPS + + + { + handleCopy(`git@github.com:${repoUrl?.split('github.com/')[1]}`, 'SSH'); + onExport?.('ssh'); + }} + > + SSH + + + { + handleCopy(`gh repo clone ${repoUrl?.split('github.com/')[1]}`, 'GitHub CLI'); + onExport?.('cli'); + }} + > + GitHub CLI + + +
+
+
+
+ ) +} diff --git a/mobile-magic/apps/frontend/components/Header.tsx b/mobile-magic/apps/frontend/components/Header.tsx index 1ce3890..ca37ecd 100644 --- a/mobile-magic/apps/frontend/components/Header.tsx +++ b/mobile-magic/apps/frontend/components/Header.tsx @@ -4,12 +4,14 @@ import { cn } from '@/lib/utils' import Image from 'next/image' import Link from 'next/link' import { motion } from 'motion/react' -import { itemVariants } from '@/lib/animation-variants' +import { itemVariants } from '@/lib/animation-variants' +import { ExportOptions } from './ExportOptions' -export const Header = ({ children, className, onClick }: { +export const Header = ({ children, className, onClick, repoUrl }: { children?: React.ReactNode, className?: string, - onClick?: () => void + onClick?: () => void, + repoUrl?: string }) => { return ( @@ -20,6 +22,8 @@ export const Header = ({ children, className, onClick }: { logo +
+ {children &&