Skip to content

UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.

feat: added script copy button (#342)

Arghya Dasb7ef970d897d
diff --git a/__registry__/index.tsx b/__registry__/index.tsx
index 5b9ac703..6e2aa1dc 100644
--- a/__registry__/index.tsx
+++ b/__registry__/index.tsx
@@ -148,6 +148,19 @@ export const Index: Record<string, any> = {
subcategory: "undefined",
chunks: [],
},
+ "script-copy-btn": {
+ name: "script-copy-btn",
+ type: "registry:ui",
+ registryDependencies: undefined,
+ files: ["registry/default/magicui/script-copy-btn.tsx"],
+ component: React.lazy(
+ () => import("@/registry/default/magicui/script-copy-btn.tsx"),
+ ),
+ source: "",
+ category: "undefined",
+ subcategory: "undefined",
+ chunks: [],
+ },
marquee: {
name: "marquee",
type: "registry:ui",
@@ -1031,6 +1044,19 @@ export const Index: Record<string, any> = {
subcategory: "undefined",
chunks: [],
},
+ "script-copy-btn-demo": {
+ name: "script-copy-btn-demo",
+ type: "registry:example",
+ registryDependencies: undefined,
+ files: ["registry/default/example/script-copy-btn-demo.tsx"],
+ component: React.lazy(
+ () => import("@/registry/default/example/script-copy-btn-demo.tsx"),
+ ),
+ source: "",
+ category: "undefined",
+ subcategory: "undefined",
+ chunks: [],
+ },
"marquee-demo": {
name: "marquee-demo",
type: "registry:example",
diff --git a/config/docs.ts b/config/docs.ts
index 3aef71bf..cccd7374 100644
--- a/config/docs.ts
+++ b/config/docs.ts
@@ -201,6 +201,12 @@ export const docsConfig: DocsConfig = {
items: [],
label: "",
},
+ {
+ title: "Script Copy Button",
+ href: `/docs/components/script-copy-btn`,
+ items: [],
+ label: "New",
+ },
{
title: "Scratch To Reveal",
href: `/docs/components/scratch-to-reveal`,
diff --git a/content/docs/components/script-copy-btn.mdx b/content/docs/components/script-copy-btn.mdx
new file mode 100644
index 00000000..ab544493
--- /dev/null
+++ b/content/docs/components/script-copy-btn.mdx
@@ -0,0 +1,50 @@
+---
+title: Script Copy Button
+date: 2023-11-18
+description: Copy code to clipboard
+author: dillionverma
+published: true
+---
+
+<ComponentPreview name="script-copy-btn-demo" />
+
+## Installation
+
+<Tabs defaultValue="cli">
+
+<TabsList>
+ <TabsTrigger value="cli">CLI</TabsTrigger>
+ <TabsTrigger value="manual">Manual</TabsTrigger>
+</TabsList>
+<TabsContent value="cli">
+
+```bash
+npx shadcn@latest add "https://magicui.design/r/script-copy-btn"
+```
+
+</TabsContent>
+
+<TabsContent value="manual">
+
+<Steps>
+
+<Step>Copy and paste the following code into your project.</Step>
+
+<ComponentSource name="script-copy-btn" />
+
+</Steps>
+
+</TabsContent>
+
+</Tabs>
+
+## Props
+
+| Prop | Type | Description | Default |
+| -------------------------- | ------------------------ | ----------------------------------------------------------- | ------- |
+| className | string | The class name to be applied to the component | |
+| showMultiplePackageOptions | boolean | Whether to show options for multiple package managers | true |
+| codeLanguage | string | The language of the code snippet (e.g., "shell") | |
+| lightTheme | string | The theme to use for light mode | |
+| darkTheme | string | The theme to use for dark mode | |
+| commandMap | Record \<string, string> | A map of package manager names to their respective commands | |
diff --git a/package.json b/package.json
index 8e16a1cb..ba65c23c 100644
--- a/package.json
+++ b/package.json
@@ -27,10 +27,10 @@
"@heroicons/react": "^2.1.3",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-alert-dialog": "^1.0.5",
- "@radix-ui/react-avatar": "^1.0.3",
+ "@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-collapsible": "^1.0.3",
"@radix-ui/react-dialog": "^1.0.5",
- "@radix-ui/react-dropdown-menu": "^2.0.5",
+ "@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-hover-card": "^1.0.7",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.0.2",
@@ -46,7 +46,7 @@
"@types/lodash.template": "^4.5.3",
"autoprefixer": "10.4.14",
"canvas-confetti": "^1.9.3",
- "class-variance-authority": "^0.6.0",
+ "class-variance-authority": "^0.6.1",
"clsx": "^2.1.1",
"cmdk": "^1.0.0",
"cobe": "^0.6.3",
@@ -69,7 +69,7 @@
"react": "18.3.1",
"react-day-picker": "^8.9.1",
"react-dom": "18.3.1",
- "react-hook-form": "^7.45.0",
+ "react-hook-form": "^7.50.1",
"react-icon-cloud": "^4.1.4",
"react-tweet": "^3.2.1",
"schema-dts": "^1.1.2",
@@ -88,7 +88,7 @@
"@ianvs/prettier-plugin-sort-imports": "^4.3.1",
"@tailwindcss/typography": "^0.5.9",
"@types/canvas-confetti": "^1.6.4",
- "@types/node": "^20.8.9",
+ "@types/node": "^20.11.22",
"@types/react": "18.2.12",
"@types/react-dom": "18.2.5",
"@types/unist": "^3.0.2",
@@ -99,7 +99,7 @@
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-tailwindcss": "3.13.1",
"husky": "^9.0.11",
- "lint-staged": "^15.2.5",
+ "lint-staged": "^15.2.7",
"mdast-util-toc": "^6.1.1",
"npm-run-all": "^4.1.5",
"prettier": "^3.3.3",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 2e7bffff..750e1043 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -18,7 +18,7 @@ importers:
specifier: ^1.0.5
'@radix-ui/react-avatar':
- specifier: ^1.0.3
+ specifier: ^1.0.4
'@radix-ui/react-collapsible':
specifier: ^1.0.3
@@ -27,7 +27,7 @@ importers:
specifier: ^1.0.5
'@radix-ui/react-dropdown-menu':
- specifier: ^2.0.5
+ specifier: ^2.0.6
'@radix-ui/react-hover-card':
specifier: ^1.0.7
@@ -75,7 +75,7 @@ importers:
specifier: ^1.9.3
version: 1.9.3
class-variance-authority:
- specifier: ^0.6.0
+ specifier: ^0.6.1
version: 0.6.1
clsx:
specifier: ^2.1.1
@@ -144,7 +144,7 @@ importers:
specifier: 18.3.1
version: 18.3.1([email protected])
react-hook-form:
- specifier: ^7.45.0
+ specifier: ^7.50.1
version: 7.50.1([email protected])
react-icon-cloud:
specifier: ^4.1.4
@@ -196,7 +196,7 @@ importers:
specifier: ^1.6.4
version: 1.6.4
'@types/node':
- specifier: ^20.8.9
+ specifier: ^20.11.22
version: 20.11.22
'@types/react':
specifier: 18.2.12
@@ -229,7 +229,7 @@ importers:
specifier: ^9.0.11
version: 9.0.11
lint-staged:
- specifier: ^15.2.5
+ specifier: ^15.2.7
version: 15.2.7
mdast-util-toc:
specifier: ^6.1.1
@@ -267,6 +267,8 @@ importers:
shiki:
specifier: ^1.20.0
version: 1.20.0
+ specifier: ^1.20.0
+ version: 1.20.0
tailwindcss:
specifier: 3.4.1
@@ -296,8 +298,8 @@ packages:
resolution: {integrity: sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==}
engines: {node: '>=10'}
- '@ampproject/[email protected]':
- resolution: {integrity: sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==}
+ '@ampproject/[email protected]':
+ resolution: {integrity: sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==}
engines: {node: '>=6.0.0'}
@@ -893,6 +895,10 @@ packages:
resolution: {integrity: sha512-Oud2QPM5dHviZNn4y/WhhYKSXksv+1xLEIsNrAbGcFzUN3ubqWRFT5gwPchNc5NuzILOU4tPBDTZ4VwhL8Y7cw==}
engines: {node: '>=6.0.0'}
+ '@jridgewell/[email protected]':
+ resolution: {integrity: sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==}
+ engines: {node: '>=6.0.0'}
+
'@jridgewell/[email protected]':
resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==}
engines: {node: '>=6.0.0'}
@@ -904,9 +910,15 @@ packages:
'@jridgewell/[email protected]':
resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==}
+ '@jridgewell/[email protected]':
+ resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==}
+
'@jridgewell/[email protected]':
resolution: {integrity: sha512-9/4foRoUKp8s96tSkh8DlAAc5A0Ty8vLXld+l9gjKKY6ckwI8G15f0hskGmuLZu78ZlGa1vtsfOa+lnB4vG6Jg==}
+ '@jridgewell/[email protected]':
+ resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==}
+
'@jridgewell/[email protected]':
resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==}
@@ -1992,6 +2004,9 @@ packages:
resolution: {integrity: sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==}
+
resolution: {integrity: sha512-HM5bwOaIQJIQbAYfax35HCKxx7a3KrK3nBtIqJgSOitivTD1y3oW9P3rxY9RkXYPUk7y/AjAohfHKmFpGE79zw==}
@@ -2068,8 +2083,8 @@ packages:
peerDependencies:
acorn: ^6.0.0 || ^7.0.0 || ^8.0.0
- resolution: {integrity: sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==}
+ resolution: {integrity: sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==}
engines: {node: '>=0.4.0'}
@@ -2241,6 +2256,11 @@ packages:
engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7}
hasBin: true
+ resolution: {integrity: sha512-Rmb62sR1Zpjql25eSanFGEhAxcFwfA1K0GuQcLoaJBAcENegrQut3hYdhXFF1obQfiDyqIW/cLM5HSJ/9k884A==}
+ engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7}
+ hasBin: true
+
resolution: {integrity: sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==}
engines: {node: '>=10.16.0'}
@@ -2264,8 +2284,8 @@ packages:
resolution: {integrity: sha512-bsTwuIg/BZZK/vreVTYYbSWoe2F+71P7K5QGEX+pT250DZbfU1MQ5prOKpPR+LL6uWKK3KMwMCAS74QB3Um1uw==}
- resolution: {integrity: sha512-PCzRMei/vXjJyL5mJtzNiUCKP59dm8Apqc3PH8gJkMnMXZGox93RbE76jHsmLwmIo6/3nsYIpJtx0O7u5PqFuQ==}
+ resolution: {integrity: sha512-AmE7k4dXiNKQipgn7a2xg558IRqPN3jMQY/rOsbxDhrd0tyChwbITBfiwtnqz8bi2M5mIWbxAYBvk7W7QBUS2g==}
resolution: {integrity: sha512-rFfTURMvmVEX1gyXFgn5QMn81bYk70qa0HLzcIOSVEyl57n6o9ItHeBtUSWdvKAPY0xlvBHno4/v3QPrT83q9g==}
@@ -2514,8 +2534,8 @@ packages:
supports-color:
optional: true
- resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==}
+ resolution: {integrity: sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==}
engines: {node: '>=6.0'}
peerDependencies:
supports-color: '*'
@@ -2608,6 +2628,9 @@ packages:
resolution: {integrity: sha512-3avY1B+vUzNxEgkBDpKOP8WarvUAEwpRaiCL0He5OKWEFxzaOFiq4WoZEZe7qh0ReS7DiWoHMnYoQCKxNZNzSg==}
+ resolution: {integrity: sha512-PF8n2AlIhCKXQ+gTpiJi0VhcHDb69kYX4MtCiivctc2QD3XuNZ/XIOlbGzt7WAjjEev0TtaH6Cu3arZExm5DOw==}
+
resolution: {integrity: sha512-QpLs9D9v9kArv4lfDEgg1X/gN5XLnf/A6l9cs8SPZLRZR3ZkY9+kwIQTxm+fsSej5UMYGE8fdoaZVIBlqG0XTw==}
@@ -2676,6 +2699,10 @@ packages:
resolution: {integrity: sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==}
engines: {node: '>=6'}
+ resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==}
+ engines: {node: '>=6'}
+
resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==}
engines: {node: '>=0.8.0'}
@@ -3747,6 +3774,9 @@ packages:
resolution: {integrity: sha512-KvOVV+X1yLBfs9dCBSopq/+G1PcgT3lAK07mC4BzXi5E7ahzMAF8oIupDDJ6mievI6F+lAATkbQQlQixJfT3aQ==}
+ resolution: {integrity: sha512-KvOVV+X1yLBfs9dCBSopq/+G1PcgT3lAK07mC4BzXi5E7ahzMAF8oIupDDJ6mievI6F+lAATkbQQlQixJfT3aQ==}
+
resolution: {integrity: sha512-Ye01HXpkZPNcV6FiyoW2fGZDUw4Yc7vT0E9Sad83+bEDiCJ1uXu0S3mr8WLpsz3HaG3x2q0HM6CTuPdcZcluFQ==}
@@ -3810,6 +3840,9 @@ packages:
resolution: {integrity: sha512-WhYv5UEcZrbAtlsnPuChHUAsu/iBPOVaEVsntLBIdpibO0ddy8OzavZz3iL2xVvBZOpolujSliP65Kq0/7KIYw==}
+ resolution: {integrity: sha512-WhYv5UEcZrbAtlsnPuChHUAsu/iBPOVaEVsntLBIdpibO0ddy8OzavZz3iL2xVvBZOpolujSliP65Kq0/7KIYw==}
+
resolution: {integrity: sha512-kUQHyzRoxvZO2PuLzMt2P/dwVsTiivCK8icYTeR+3WgbuPqfHgPPy7nFKbeqRivBvn/3N3GBiNC+JRTMSxEC7A==}
@@ -3822,12 +3855,18 @@ packages:
resolution: {integrity: sha512-8JZt9ElZ5kyTnO94muPxIGS8oyElRJaiJO8EzV6ZSyGQ1Is8xwl4Q45qU5UOg+bGH4AikWziz0iN4sFLWs8PGw==}
+ resolution: {integrity: sha512-8JZt9ElZ5kyTnO94muPxIGS8oyElRJaiJO8EzV6ZSyGQ1Is8xwl4Q45qU5UOg+bGH4AikWziz0iN4sFLWs8PGw==}
+
resolution: {integrity: sha512-ukRBgie8TIAcacscVHSiddHjO4k/q3pnedmzMQ4iwDcK0FtFCohKOlFbaOL/mPgfnPsL3C1ZyxJa4sbWrBl3jg==}
resolution: {integrity: sha512-oNh6S2WMHWRZrmutsRmDDfkzKtxF+bc2VxLC9dvtrDIRFln627VsFP6fLMgTryGDljgLPjkrzQSDcPrjPyDJ5w==}
+ resolution: {integrity: sha512-oNh6S2WMHWRZrmutsRmDDfkzKtxF+bc2VxLC9dvtrDIRFln627VsFP6fLMgTryGDljgLPjkrzQSDcPrjPyDJ5w==}
+
resolution: {integrity: sha512-uD66tJj54JLYq0De10AhWycZWGQNUvDI55xPgk2sQM5kn1JYlhbCMTtEeT27+vAhW2FBQxLlOmS3pmA7/2z4aA==}
@@ -3951,6 +3990,9 @@ packages:
resolution: {integrity: sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==}
+ resolution: {integrity: sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==}
+
resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==}
@@ -4128,6 +4170,9 @@ packages:
resolution: {integrity: sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==}
+ resolution: {integrity: sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==}
+
resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==}
engines: {node: '>=8.6'}
@@ -4691,6 +4736,8 @@ packages:
resolution: {integrity: sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==}
+ resolution: {integrity: sha512-MZJJ1PCFsQB1Piq+25wiz0a75yUv8Q3/fzy7SzRx5ONdjdtGdyiKwYn8vb/FnK5kjS0voWGnPpjG16POauUR+g==}
resolution: {integrity: sha512-MZJJ1PCFsQB1Piq+25wiz0a75yUv8Q3/fzy7SzRx5ONdjdtGdyiKwYn8vb/FnK5kjS0voWGnPpjG16POauUR+g==}
@@ -4979,6 +5026,9 @@ packages:
resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==}
+ resolution: {integrity: sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==}
+
resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==}
engines: {node: '>= 6'}
@@ -5066,18 +5116,27 @@ packages:
resolution: {integrity: sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==}
+ resolution: {integrity: sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==}
+
resolution: {integrity: sha512-x6+y8g7wWMyQhL1iZfhIPhDAs7Xwbn9nRosDXl7qoPTSCy0yNxnKc+hWokFifWQIDGi154rdUqKvbCa4+1kLhg==}
resolution: {integrity: sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==}
+ resolution: {integrity: sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==}
+
resolution: {integrity: sha512-MSd8OUGISqHdVvfY9TPhyK2VdUrPgxkUtWSuMHF6XAAFuL4LokseigBnZtPnJMu+FbynTkFNnFlyjxpVKujMRg==}
resolution: {integrity: sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==}
+ resolution: {integrity: sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==}
+
resolution: {integrity: sha512-G5o6f95b5BggDGuUfKDApKaCgNYy2x7OdHY0zSMF081O0EJobw+1130VONhrA7ezGSV2FNOGyM+KQpQZAr9bIQ==}
@@ -5090,6 +5149,12 @@ packages:
peerDependencies:
browserslist: '>= 4.21.0'
+ resolution: {integrity: sha512-EdRAaAyk2cUE1wOf2DkEhzxqOQvFOoRJFNS6NeyJ01Gp2beMRpBAINjM2iDXE3KCuKhwnvHIQCJm6ThL2Z+HzQ==}
+ hasBin: true
+ peerDependencies:
+ browserslist: '>= 4.21.0'
+
resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==}
@@ -5221,6 +5286,11 @@ packages:
engines: {node: '>= 14'}
hasBin: true
+ resolution: {integrity: sha512-bLQOjaX/ADgQ20isPJRvF0iRUHIxVhYvr53Of7wGcWlO2jvtUlH5m87DsmulFVxRpNLOnI4tB6p/oh8D7kpn9Q==}
+ engines: {node: '>= 14'}
+ hasBin: true
+
resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==}
engines: {node: '>=12'}
@@ -5257,10 +5327,10 @@ snapshots:
'@alloc/[email protected]': {}
- '@ampproject/[email protected]':
+ '@ampproject/[email protected]':
dependencies:
- '@jridgewell/gen-mapping': 0.3.4
- '@jridgewell/trace-mapping': 0.3.23
+ '@jridgewell/gen-mapping': 0.3.5
+ '@jridgewell/trace-mapping': 0.3.25
dependencies:
@@ -5269,20 +5339,22 @@ snapshots:
'@babel/[email protected]': {}
- '@babel/[email protected]':
+ '@babel/[email protected]': {}
+
+ '@babel/[email protected]':
dependencies:
- '@ampproject/remapping': 2.2.1
- '@babel/code-frame': 7.23.5
- '@babel/generator': 7.23.6
- '@babel/helper-compilation-targets': 7.23.6
- '@babel/helper-module-transforms': 7.23.3(@babel/[email protected])
- '@babel/helpers': 7.24.0
- '@babel/parser': 7.24.0
- '@babel/template': 7.24.0
- '@babel/traverse': 7.24.0
- '@babel/types': 7.24.6
+ '@ampproject/remapping': 2.3.0
+ '@babel/code-frame': 7.24.7
+ '@babel/generator': 7.25.6
+ '@babel/helper-compilation-targets': 7.25.2
+ '@babel/helper-module-transforms': 7.25.2(@babel/[email protected])
+ '@babel/helpers': 7.25.6
+ '@babel/parser': 7.25.6
+ '@babel/template': 7.25.0
+ '@babel/traverse': 7.25.6
+ '@babel/types': 7.25.6
convert-source-map: 2.0.0
- debug: 4.3.4
+ debug: 4.3.7
gensync: 1.0.0-beta.2
json5: 2.2.3
semver: 6.3.1
@@ -5291,9 +5363,9 @@ snapshots:
dependencies:
- '@babel/types': 7.24.6
- '@jridgewell/gen-mapping': 0.3.4
- '@jridgewell/trace-mapping': 0.3.23
+ '@babel/types': 7.25.6
+ '@jridgewell/gen-mapping': 0.3.5
+ '@jridgewell/trace-mapping': 0.3.25
jsesc: 2.5.2
@@ -5344,11 +5416,8 @@ snapshots:
dependencies:
- '@babel/template': 7.24.0
- '@babel/traverse': 7.24.0
- '@babel/types': 7.24.6
- transitivePeerDependencies:
- - supports-color
+ '@babel/template': 7.25.0
+ '@babel/types': 7.25.6
dependencies:
@@ -5358,7 +5427,10 @@ snapshots:
dependencies:
- '@babel/types': 7.24.6
+ '@babel/helper-validator-identifier': 7.24.7
+ chalk: 2.4.2
+ js-tokens: 4.0.0
+ picocolors: 1.1.0
dependencies:
@@ -5765,7 +5837,7 @@ snapshots:
'@eslint/[email protected]':
dependencies:
ajv: 6.12.6
- debug: 4.3.4
+ debug: 4.3.7
espree: 9.6.1
globals: 13.24.0
ignore: 5.3.1
@@ -5804,7 +5876,7 @@ snapshots:
'@humanwhocodes/[email protected]':
dependencies:
'@humanwhocodes/object-schema': 2.0.3
- debug: 4.3.4
+ debug: 4.3.7
minimatch: 3.1.2
transitivePeerDependencies:
- supports-color
@@ -5840,21 +5912,34 @@ snapshots:
'@jridgewell/sourcemap-codec': 1.4.15
'@jridgewell/trace-mapping': 0.3.23
+ '@jridgewell/[email protected]':
+ dependencies:
+ '@jridgewell/set-array': 1.2.1
+ '@jridgewell/sourcemap-codec': 1.5.0
+ '@jridgewell/trace-mapping': 0.3.25
+
'@jridgewell/[email protected]': {}
'@jridgewell/[email protected]': {}
'@jridgewell/[email protected]': {}
+ '@jridgewell/[email protected]': {}
+
'@jridgewell/[email protected]':
dependencies:
'@jridgewell/resolve-uri': 3.1.2
'@jridgewell/sourcemap-codec': 1.4.15
+ '@jridgewell/[email protected]':
+ dependencies:
+ '@jridgewell/resolve-uri': 3.1.2
+ '@jridgewell/sourcemap-codec': 1.5.0
+
'@jridgewell/[email protected]':
dependencies:
'@jridgewell/resolve-uri': 3.1.2
- '@jridgewell/sourcemap-codec': 1.4.15
+ '@jridgewell/sourcemap-codec': 1.5.0
optional: true
@@ -6893,11 +6978,11 @@ snapshots:
dependencies:
'@swc/counter': 0.1.3
- tslib: 2.6.2
+ tslib: 2.7.0
dependencies:
- tslib: 2.6.2
+ tslib: 2.7.0
dependencies:
@@ -6985,6 +7070,10 @@ snapshots:
dependencies:
'@types/unist': 3.0.3
+ '@types/[email protected]':
+ dependencies:
+ '@types/unist': 3.0.3
+
'@types/[email protected]': {}
'@types/[email protected]': {}
@@ -7064,7 +7153,9 @@ snapshots:
dependencies:
acorn: 8.12.1
+ dependencies:
+ acorn: 8.12.1
optional: true
@@ -7207,7 +7298,7 @@ snapshots:
dependencies:
browserslist: 4.23.0
- caniuse-lite: 1.0.30001591
+ caniuse-lite: 1.0.30001664
fraction.js: 4.3.7
normalize-range: 0.1.2
picocolors: 1.0.0
@@ -7255,11 +7346,18 @@ snapshots:
dependencies:
- caniuse-lite: 1.0.30001591
+ caniuse-lite: 1.0.30001664
electron-to-chromium: 1.4.686
node-releases: 2.0.14
update-browserslist-db: 1.0.13([email protected])
+ dependencies:
+ caniuse-lite: 1.0.30001664
+ electron-to-chromium: 1.5.29
+ node-releases: 2.0.18
+ update-browserslist-db: 1.1.0([email protected])
+
dependencies:
streamsearch: 1.1.0
@@ -7285,7 +7383,7 @@ snapshots:
lodash.memoize: 4.1.2
lodash.uniq: 4.5.0
@@ -7499,12 +7597,12 @@ snapshots:
dependencies:
mdn-data: 2.0.28
- source-map-js: 1.0.2
+ source-map-js: 1.2.0
dependencies:
mdn-data: 2.0.30
- source-map-js: 1.0.2
+ source-map-js: 1.2.0
@@ -7575,6 +7673,10 @@ snapshots:
dependencies:
ms: 2.1.2
+ dependencies:
+ ms: 2.1.3
+
dependencies:
character-entities: 2.0.2
@@ -7658,6 +7760,8 @@ snapshots:
+
@@ -7817,6 +7921,8 @@ snapshots:
+
@@ -7855,7 +7961,7 @@ snapshots:
dependencies:
- debug: 4.3.4
+ debug: 4.3.7
enhanced-resolve: 5.15.1
eslint: 8.57.1
@@ -7910,7 +8016,7 @@ snapshots:
dependencies:
- '@babel/runtime': 7.24.0
+ '@babel/runtime': 7.25.6
aria-query: 5.3.0
array-includes: 3.1.7
array.prototype.flatmap: 1.3.2
@@ -7978,7 +8084,7 @@ snapshots:
ajv: 6.12.6
chalk: 4.1.2
cross-spawn: 7.0.3
- debug: 4.3.4
+ debug: 4.3.7
doctrine: 3.0.0
escape-string-regexp: 4.0.0
eslint-scope: 7.2.2
@@ -9312,6 +9418,11 @@ snapshots:
micromark-util-symbol: 2.0.0
micromark-util-types: 2.0.0
+ dependencies:
+ micromark-util-symbol: 2.0.0
+ micromark-util-types: 2.0.0
+
dependencies:
micromark-util-symbol: 1.1.0
@@ -9411,6 +9522,12 @@ snapshots:
micromark-util-encode: 2.0.0
micromark-util-symbol: 2.0.0
+ dependencies:
+ micromark-util-character: 2.1.0
+ micromark-util-encode: 2.0.0
+ micromark-util-symbol: 2.0.0
+
dependencies:
micromark-util-chunked: 1.1.0
@@ -9429,14 +9546,18 @@ snapshots:
+
+
dependencies:
'@types/debug': 4.1.12
- debug: 4.3.4
+ debug: 4.3.7
decode-named-character-reference: 1.0.2
micromark-core-commonmark: 1.1.0
micromark-factory-space: 1.1.0
@@ -9550,12 +9671,12 @@ snapshots:
'@next/env': 14.2.13
'@swc/helpers': 0.5.5
busboy: 1.6.0
- caniuse-lite: 1.0.30001591
+ caniuse-lite: 1.0.30001664
graceful-fs: 4.2.11
postcss: 8.4.31
react: 18.3.1
react-dom: 18.3.1([email protected])
- styled-jsx: 5.1.1(@babel/[email protected])([email protected])
+ styled-jsx: 5.1.1(@babel/[email protected])([email protected])
optionalDependencies:
'@next/swc-darwin-arm64': 14.2.13
'@next/swc-darwin-x64': 14.2.13
@@ -9577,6 +9698,8 @@ snapshots:
+
dependencies:
hosted-git-info: 2.8.9
@@ -9784,6 +9907,8 @@ snapshots:
+
@@ -9810,7 +9935,7 @@ snapshots:
dependencies:
- browserslist: 4.23.0
+ browserslist: 4.24.0
caniuse-api: 3.0.0
colord: 2.9.3
postcss: 8.4.39
@@ -9818,7 +9943,7 @@ snapshots:
dependencies:
- browserslist: 4.23.0
+ browserslist: 4.24.0
postcss: 8.4.39
postcss-value-parser: 4.2.0
@@ -9868,7 +9993,7 @@ snapshots:
dependencies:
- browserslist: 4.23.0
+ browserslist: 4.24.0
caniuse-api: 3.0.0
cssnano-utils: 4.0.1([email protected])
postcss: 8.4.39
@@ -9888,7 +10013,7 @@ snapshots:
dependencies:
- browserslist: 4.23.0
+ browserslist: 4.24.0
cssnano-utils: 4.0.1([email protected])
postcss: 8.4.39
postcss-value-parser: 4.2.0
@@ -9934,7 +10059,7 @@ snapshots:
dependencies:
- browserslist: 4.23.0
+ browserslist: 4.24.0
postcss: 8.4.39
postcss-value-parser: 4.2.0
@@ -9956,7 +10081,7 @@ snapshots:
dependencies:
- browserslist: 4.23.0
+ browserslist: 4.24.0
caniuse-api: 3.0.0
postcss: 8.4.39
@@ -10391,6 +10516,7 @@ snapshots:
dependencies:
'@shikijs/core': 1.20.0
@@ -10399,6 +10525,12 @@ snapshots:
'@shikijs/types': 1.20.0
'@shikijs/vscode-textmate': 9.2.2
'@types/hast': 3.0.4
+ '@shikijs/core': 1.20.0
+ '@shikijs/engine-javascript': 1.20.0
+ '@shikijs/engine-oniguruma': 1.20.0
+ '@shikijs/types': 1.20.0
+ '@shikijs/vscode-textmate': 9.2.2
+ '@types/hast': 3.0.4
dependencies:
@@ -10556,11 +10688,11 @@ snapshots:
client-only: 0.0.1
react: 18.3.1
optionalDependencies:
- '@babel/core': 7.24.0
+ '@babel/core': 7.25.2
dependencies:
- browserslist: 4.23.0
+ browserslist: 4.24.0
postcss: 8.4.39
postcss-selector-parser: 6.0.15
@@ -10596,7 +10728,7 @@ snapshots:
css-tree: 2.3.1
css-what: 6.1.0
csso: 5.0.5
- picocolors: 1.0.0
+ picocolors: 1.1.0
dependencies:
@@ -10697,7 +10829,7 @@ snapshots:
'@tsconfig/node16': 1.0.4
'@types/node': 20.11.22
acorn: 8.12.1
- acorn-walk: 8.3.2
+ acorn-walk: 8.3.4
arg: 4.1.3
create-require: 1.1.1
diff: 4.0.2
@@ -10837,6 +10969,10 @@ snapshots:
dependencies:
'@types/unist': 3.0.3
+ dependencies:
+ '@types/unist': 3.0.3
+
dependencies:
'@types/unist': 2.0.10
@@ -10847,6 +10983,11 @@ snapshots:
'@types/unist': 3.0.3
unist-util-is: 6.0.0
+ dependencies:
+ '@types/unist': 3.0.3
+ unist-util-is: 6.0.0
+
dependencies:
'@types/unist': 2.0.10
@@ -10859,6 +11000,12 @@ snapshots:
unist-util-is: 6.0.0
unist-util-visit-parents: 6.0.1
+ dependencies:
+ '@types/unist': 3.0.3
+ unist-util-is: 6.0.0
+ unist-util-visit-parents: 6.0.1
+
@@ -10869,6 +11016,12 @@ snapshots:
escalade: 3.1.2
picocolors: 1.0.0
+ dependencies:
+ browserslist: 4.24.0
+ escalade: 3.2.0
+ picocolors: 1.1.0
+
dependencies:
punycode: 2.3.1
diff --git a/public/r/index.json b/public/r/index.json
index 832eb745..bab13d39 100644
--- a/public/r/index.json
+++ b/public/r/index.json
@@ -175,6 +175,21 @@
}
]
},
+ {
+ "name": "script-copy-btn",
+ "type": "registry:ui",
+ "dependencies": [
+ "framer-motion",
+ "shiki",
+ "next-themes"
+ ],
+ "files": [
+ {
+ "path": "magicui/script-copy-btn.tsx",
+ "type": "registry:ui"
+ }
+ ]
+ },
{
"name": "marquee",
"type": "registry:ui",
diff --git a/public/r/styles/default/dock.json b/public/r/styles/default/dock.json
index 08908f20..78d1ff26 100644
--- a/public/r/styles/default/dock.json
+++ b/public/r/styles/default/dock.json
@@ -7,7 +7,7 @@
"files": [
{
"path": "magicui/dock.tsx",
- "content": "\"use client\";\n\nimport React, { PropsWithChildren, useRef } from \"react\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport {\n motion,\n MotionValue,\n useMotionValue,\n useSpring,\n useTransform,\n} from \"framer-motion\";\n\nimport { cn } from \"@/lib/utils\";\n\nexport interface DockProps extends VariantProps<typeof dockVariants> {\n className?: string;\n iconSize?: number;\n iconMagnification?: number;\n iconDistance?: number;\n direction?: \"top\" | \"middle\" | \"bottom\";\n children: React.ReactNode;\n}\n\nconst DEFAULT_SIZE = 40;\nconst DEFAULT_MAGNIFICATION = 60;\nconst DEFAULT_DISTANCE = 140;\n\nconst dockVariants = cva(\n \"supports-backdrop-blur:bg-white/10 supports-backdrop-blur:dark:bg-black/10 mx-auto mt-8 flex h-[58px] w-max items-center justify-center gap-2 rounded-2xl border p-2 backdrop-blur-md\",\n);\n\nconst Dock = React.forwardRef<HTMLDivElement, DockProps>(\n (\n {\n className,\n children,\n iconSize = DEFAULT_SIZE,\n iconMagnification = DEFAULT_MAGNIFICATION,\n iconDistance = DEFAULT_DISTANCE,\n direction = \"middle\",\n ...props\n },\n ref,\n ) => {\n const mouseX = useMotionValue(Infinity);\n\n const renderChildren = () => {\n return React.Children.map(children, (child) => {\n if (React.isValidElement(child) && child.type === DockIcon) {\n return React.cloneElement(child, {\n ...child.props,\n mouseX: mouseX,\n size: iconSize,\n magnification: iconMagnification,\n distance: iconDistance,\n });\n }\n return child;\n });\n };\n\n return (\n <motion.div\n ref={ref}\n onMouseMove={(e) => mouseX.set(e.pageX)}\n onMouseLeave={() => mouseX.set(Infinity)}\n {...props}\n className={cn(dockVariants({ className }), {\n \"items-start\": direction === \"top\",\n \"items-center\": direction === \"middle\",\n \"items-end\": direction === \"bottom\",\n })}\n >\n {renderChildren()}\n </motion.div>\n );\n },\n);\n\nDock.displayName = \"Dock\";\n\nexport interface DockIconProps {\n size?: number;\n magnification?: number;\n distance?: number;\n mouseX?: MotionValue<number>;\n className?: string;\n children?: React.ReactNode;\n props?: PropsWithChildren;\n}\n\nconst DockIcon = ({\n size = DEFAULT_SIZE,\n magnification = DEFAULT_MAGNIFICATION,\n distance = DEFAULT_DISTANCE,\n mouseX,\n className,\n children,\n ...props\n}: DockIconProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const padding = Math.max(6, size * 0.2);\n const defaultMouseX = useMotionValue(Infinity);\n\n const distanceCalc = useTransform(mouseX ?? defaultMouseX, (val: number) => {\n const bounds = ref.current?.getBoundingClientRect() ?? { x: 0, width: 0 };\n return val - bounds.x - bounds.width / 2;\n });\n\n const sizeTransform = useTransform(\n distanceCalc,\n [-distance, 0, distance],\n [size, magnification, size],\n );\n\n const scaleSize = useSpring(sizeTransform, {\n mass: 0.1,\n stiffness: 150,\n damping: 12,\n });\n\n return (\n <motion.div\n ref={ref}\n style={{ width: scaleSize, height: scaleSize, padding }}\n className={cn(\n \"flex aspect-square cursor-pointer items-center justify-center rounded-full\",\n className,\n )}\n {...props}\n >\n {children}\n </motion.div>\n );\n};\n\nDockIcon.displayName = \"DockIcon\";\n\nexport { Dock, DockIcon, dockVariants };\n",
+ "content": "\"use client\";\n\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport {\n motion,\n MotionProps,\n MotionValue,\n useMotionValue,\n useSpring,\n useTransform,\n} from \"framer-motion\";\nimport React, { PropsWithChildren, useRef } from \"react\";\n\nimport { cn } from \"@/lib/utils\";\n\nexport interface DockProps extends VariantProps<typeof dockVariants> {\n className?: string;\n iconSize?: number;\n iconMagnification?: number;\n iconDistance?: number;\n direction?: \"top\" | \"middle\" | \"bottom\";\n children: React.ReactNode;\n}\n\nconst DEFAULT_SIZE = 40;\nconst DEFAULT_MAGNIFICATION = 60;\nconst DEFAULT_DISTANCE = 140;\n\nconst dockVariants = cva(\n \"supports-backdrop-blur:bg-white/10 supports-backdrop-blur:dark:bg-black/10 mx-auto mt-8 flex h-[58px] w-max items-center justify-center gap-2 rounded-2xl border p-2 backdrop-blur-md\",\n);\n\nconst Dock = React.forwardRef<HTMLDivElement, DockProps>(\n (\n {\n className,\n children,\n iconSize = DEFAULT_SIZE,\n iconMagnification = DEFAULT_MAGNIFICATION,\n iconDistance = DEFAULT_DISTANCE,\n direction = \"middle\",\n ...props\n },\n ref,\n ) => {\n const mouseX = useMotionValue(Infinity);\n\n const renderChildren = () => {\n return React.Children.map(children, (child) => {\n if (React.isValidElement(child) && child.type === DockIcon) {\n return React.cloneElement(child, {\n ...child.props,\n mouseX: mouseX,\n size: iconSize,\n magnification: iconMagnification,\n distance: iconDistance,\n });\n }\n return child;\n });\n };\n\n return (\n <motion.div\n ref={ref}\n onMouseMove={(e) => mouseX.set(e.pageX)}\n onMouseLeave={() => mouseX.set(Infinity)}\n {...props}\n className={cn(dockVariants({ className }), {\n \"items-start\": direction === \"top\",\n \"items-center\": direction === \"middle\",\n \"items-end\": direction === \"bottom\",\n })}\n >\n {renderChildren()}\n </motion.div>\n );\n },\n);\n\nDock.displayName = \"Dock\";\n\nexport interface DockIconProps\n extends Omit<MotionProps & React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n size?: number;\n magnification?: number;\n distance?: number;\n mouseX?: MotionValue<number>;\n className?: string;\n children?: React.ReactNode;\n props?: PropsWithChildren;\n}\n\nconst DockIcon = ({\n size = DEFAULT_SIZE,\n magnification = DEFAULT_MAGNIFICATION,\n distance = DEFAULT_DISTANCE,\n mouseX,\n className,\n children,\n ...props\n}: DockIconProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const padding = Math.max(6, size * 0.2);\n const defaultMouseX = useMotionValue(Infinity);\n\n const distanceCalc = useTransform(mouseX ?? defaultMouseX, (val: number) => {\n const bounds = ref.current?.getBoundingClientRect() ?? { x: 0, width: 0 };\n return val - bounds.x - bounds.width / 2;\n });\n\n const sizeTransform = useTransform(\n distanceCalc,\n [-distance, 0, distance],\n [size, magnification, size],\n );\n\n const scaleSize = useSpring(sizeTransform, {\n mass: 0.1,\n stiffness: 150,\n damping: 12,\n });\n\n return (\n <motion.div\n ref={ref}\n style={{ width: scaleSize, height: scaleSize, padding }}\n className={cn(\n \"flex aspect-square cursor-pointer items-center justify-center rounded-full\",\n className,\n )}\n {...props}\n >\n {children}\n </motion.div>\n );\n};\n\nDockIcon.displayName = \"DockIcon\";\n\nexport { Dock, DockIcon, dockVariants };\n",
"type": "registry:ui",
"target": ""
}
diff --git a/public/r/styles/default/morphing-text.json b/public/r/styles/default/morphing-text.json
index 8d6a296d..f2b1a02b 100644
--- a/public/r/styles/default/morphing-text.json
+++ b/public/r/styles/default/morphing-text.json
@@ -7,7 +7,7 @@
"files": [
{
"path": "magicui/morphing-text.tsx",
- "content": "\"use client\";\n\nimport { useCallback, useEffect, useRef } from \"react\";\n\nimport { cn } from \"@/lib/utils\";\n\nconst morphTime = 1.5;\nconst cooldownTime = 0.5;\n\nconst useMorphingText = (texts: string[]) => {\n const textIndexRef = useRef(0);\n const morphRef = useRef(0);\n const cooldownRef = useRef(0);\n const timeRef = useRef(new Date());\n\n const text1Ref = useRef<HTMLSpanElement>(null);\n const text2Ref = useRef<HTMLSpanElement>(null);\n\n const setStyles = useCallback(\n (fraction: number) => {\n const [current1, current2] = [text1Ref.current, text2Ref.current];\n if (!current1 || !current2) return;\n\n current2.style.filter = `blur(${Math.min(8 / fraction - 8, 100)}px)`;\n current2.style.opacity = `${Math.pow(fraction, 0.4) * 100}%`;\n\n const invertedFraction = 1 - fraction;\n current1.style.filter = `blur(${Math.min(8 / invertedFraction - 8, 100)}px)`;\n current1.style.opacity = `${Math.pow(invertedFraction, 0.4) * 100}%`;\n\n current1.textContent = texts[textIndexRef.current % texts.length];\n current2.textContent = texts[(textIndexRef.current + 1) % texts.length];\n },\n [texts]\n );\n\n const doMorph = useCallback(() => {\n morphRef.current -= cooldownRef.current;\n cooldownRef.current = 0;\n\n let fraction = morphRef.current / morphTime;\n\n if (fraction > 1) {\n cooldownRef.current = cooldownTime;\n fraction = 1;\n }\n\n setStyles(fraction);\n\n if (fraction === 1) {\n textIndexRef.current++;\n }\n }, [setStyles]);\n\n const doCooldown = useCallback(() => {\n morphRef.current = 0;\n const [current1, current2] = [text1Ref.current, text2Ref.current];\n if (current1 && current2) {\n current2.style.filter = \"none\";\n current2.style.opacity = \"100%\";\n current1.style.filter = \"none\";\n current1.style.opacity = \"0%\";\n }\n }, []);\n\n useEffect(() => {\n let animationFrameId: number;\n\n const animate = () => {\n animationFrameId = requestAnimationFrame(animate);\n\n const newTime = new Date();\n const dt = (newTime.getTime() - timeRef.current.getTime()) / 1000;\n timeRef.current = newTime;\n\n cooldownRef.current -= dt;\n\n if (cooldownRef.current <= 0) doMorph();\n else doCooldown();\n };\n\n animate();\n return () => {\n cancelAnimationFrame(animationFrameId);\n };\n }, [doMorph, doCooldown]);\n\n return { text1Ref, text2Ref };\n};\n\ninterface MorphingTextProps {\n className?: string;\n texts: string[];\n}\n\nconst Texts: React.FC<Pick<MorphingTextProps, \"texts\">> = ({ texts }) => {\n const { text1Ref, text2Ref } = useMorphingText(texts);\n return (\n <>\n <span\n className=\"absolute inset-x-0 top-0 m-auto inline-block w-full\"\n ref={text1Ref}\n />\n <span\n className=\"absolute inset-x-0 top-0 m-auto inline-block w-full\"\n ref={text2Ref}\n />\n </>\n );\n};\n\nconst SvgFilters: React.FC = () => (\n <svg id=\"filters\" className=\"hidden\" preserveAspectRatio=\"xMidYMid slice\">\n <defs>\n <filter id=\"threshold\">\n <feColorMatrix\n in=\"SourceGraphic\"\n type=\"matrix\"\n values=\"1 0 0 0 0\n 0 1 0 0 0\n 0 0 1 0 0\n 0 0 0 255 -140\"\n />\n </filter>\n </defs>\n </svg>\n);\n\nconst MorphingText: React.FC<MorphingTextProps> = ({ texts, className }) => (\n <div\n className={cn(\n \"relative mx-auto h-16 w-full max-w-screen-md text-center font-sans text-[40pt] font-bold leading-none [filter:url(#threshold)_blur(0.6px)] md:h-24 lg:text-[6rem]\",\n className\n )}\n >\n <Texts texts={texts} />\n <SvgFilters />\n </div>\n);\n\nexport default MorphingText;\n",
+ "content": "\"use client\";\n\nimport { useCallback, useEffect, useRef } from \"react\";\n\nimport { cn } from \"@/lib/utils\";\n\nconst morphTime = 1.5;\nconst cooldownTime = 0.5;\n\nconst useMorphingText = (texts: string[]) => {\n const textIndexRef = useRef(0);\n const morphRef = useRef(0);\n const cooldownRef = useRef(0);\n const timeRef = useRef(new Date());\n\n const text1Ref = useRef<HTMLSpanElement>(null);\n const text2Ref = useRef<HTMLSpanElement>(null);\n\n const setStyles = useCallback(\n (fraction: number) => {\n const [current1, current2] = [text1Ref.current, text2Ref.current];\n if (!current1 || !current2) return;\n\n current2.style.filter = `blur(${Math.min(8 / fraction - 8, 100)}px)`;\n current2.style.opacity = `${Math.pow(fraction, 0.4) * 100}%`;\n\n const invertedFraction = 1 - fraction;\n current1.style.filter = `blur(${Math.min(8 / invertedFraction - 8, 100)}px)`;\n current1.style.opacity = `${Math.pow(invertedFraction, 0.4) * 100}%`;\n\n current1.textContent = texts[textIndexRef.current % texts.length];\n current2.textContent = texts[(textIndexRef.current + 1) % texts.length];\n },\n [texts],\n );\n\n const doMorph = useCallback(() => {\n morphRef.current -= cooldownRef.current;\n cooldownRef.current = 0;\n\n let fraction = morphRef.current / morphTime;\n\n if (fraction > 1) {\n cooldownRef.current = cooldownTime;\n fraction = 1;\n }\n\n setStyles(fraction);\n\n if (fraction === 1) {\n textIndexRef.current++;\n }\n }, [setStyles]);\n\n const doCooldown = useCallback(() => {\n morphRef.current = 0;\n const [current1, current2] = [text1Ref.current, text2Ref.current];\n if (current1 && current2) {\n current2.style.filter = \"none\";\n current2.style.opacity = \"100%\";\n current1.style.filter = \"none\";\n current1.style.opacity = \"0%\";\n }\n }, []);\n\n useEffect(() => {\n let animationFrameId: number;\n\n const animate = () => {\n animationFrameId = requestAnimationFrame(animate);\n\n const newTime = new Date();\n const dt = (newTime.getTime() - timeRef.current.getTime()) / 1000;\n timeRef.current = newTime;\n\n cooldownRef.current -= dt;\n\n if (cooldownRef.current <= 0) doMorph();\n else doCooldown();\n };\n\n animate();\n return () => {\n cancelAnimationFrame(animationFrameId);\n };\n }, [doMorph, doCooldown]);\n\n return { text1Ref, text2Ref };\n};\n\ninterface MorphingTextProps {\n className?: string;\n texts: string[];\n}\n\nconst Texts: React.FC<Pick<MorphingTextProps, \"texts\">> = ({ texts }) => {\n const { text1Ref, text2Ref } = useMorphingText(texts);\n return (\n <>\n <span\n className=\"absolute inset-x-0 top-0 m-auto inline-block w-full\"\n ref={text1Ref}\n />\n <span\n className=\"absolute inset-x-0 top-0 m-auto inline-block w-full\"\n ref={text2Ref}\n />\n </>\n );\n};\n\nconst SvgFilters: React.FC = () => (\n <svg id=\"filters\" className=\"hidden\" preserveAspectRatio=\"xMidYMid slice\">\n <defs>\n <filter id=\"threshold\">\n <feColorMatrix\n in=\"SourceGraphic\"\n type=\"matrix\"\n values=\"1 0 0 0 0\n 0 1 0 0 0\n 0 0 1 0 0\n 0 0 0 255 -140\"\n />\n </filter>\n </defs>\n </svg>\n);\n\nconst MorphingText: React.FC<MorphingTextProps> = ({ texts, className }) => (\n <div\n className={cn(\n \"relative mx-auto h-16 w-full max-w-screen-md text-center font-sans text-[40pt] font-bold leading-none [filter:url(#threshold)_blur(0.6px)] md:h-24 lg:text-[6rem]\",\n className,\n )}\n >\n <Texts texts={texts} />\n <SvgFilters />\n </div>\n);\n\nexport default MorphingText;\n",
"type": "registry:ui",
"target": ""
}
diff --git a/public/r/styles/default/script-copy-btn.json b/public/r/styles/default/script-copy-btn.json
new file mode 100644
index 00000000..aae3dc83
--- /dev/null
+++ b/public/r/styles/default/script-copy-btn.json
@@ -0,0 +1,17 @@
+{
+ "name": "script-copy-btn",
+ "type": "registry:ui",
+ "dependencies": [
+ "framer-motion",
+ "shiki",
+ "next-themes"
+ ],
+ "files": [
+ {
+ "path": "magicui/script-copy-btn.tsx",
+ "content": "\"use client\";\n\nimport { Button } from \"@/components/ui/button\";\nimport { cn } from \"@/lib/utils\";\nimport { motion } from \"framer-motion\";\nimport { Check, Copy } from \"lucide-react\";\nimport { useTheme } from \"next-themes\";\nimport { HTMLAttributes, useEffect, useState } from \"react\";\nimport { codeToHtml } from \"shiki\";\n\ninterface ScriptCopyBtnProps extends HTMLAttributes<HTMLDivElement> {\n showMultiplePackageOptions?: boolean;\n codeLanguage: string;\n lightTheme: string;\n darkTheme: string;\n commandMap: Record<string, string>;\n className?: string;\n}\n\nexport default function ScriptCopyBtn({\n showMultiplePackageOptions = true,\n codeLanguage,\n lightTheme,\n darkTheme,\n commandMap,\n className,\n}: ScriptCopyBtnProps) {\n const packageManagers = Object.keys(commandMap);\n const [packageManager, setPackageManager] = useState(packageManagers[0]);\n const [copied, setCopied] = useState(false);\n const [highlightedCode, setHighlightedCode] = useState(\"\");\n const { theme } = useTheme();\n const command = commandMap[packageManager];\n\n useEffect(() => {\n async function loadHighlightedCode() {\n try {\n const highlighted = await codeToHtml(command, {\n lang: codeLanguage,\n themes: {\n light: lightTheme,\n dark: darkTheme,\n },\n defaultColor: theme === \"dark\" ? \"dark\" : \"light\",\n });\n setHighlightedCode(highlighted);\n } catch (error) {\n console.error(\"Error highlighting code:\", error);\n setHighlightedCode(`<pre>${command}</pre>`);\n }\n }\n\n loadHighlightedCode();\n }, [command, theme, codeLanguage, lightTheme, darkTheme]);\n\n const copyToClipboard = () => {\n navigator.clipboard.writeText(command);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n };\n\n return (\n <div\n className={cn(\n \"mx-auto flex max-w-md items-center justify-center\",\n className,\n )}\n >\n <div className=\"w-full space-y-2\">\n <div className=\"mb-2 flex items-center justify-between\">\n {showMultiplePackageOptions && (\n <div className=\"relative\">\n <div className=\"inline-flex overflow-hidden rounded-md border border-border text-xs\">\n {packageManagers.map((pm, index) => (\n <div key={pm} className=\"flex items-center\">\n {index > 0 && (\n <div className=\"h-4 w-px bg-border\" aria-hidden=\"true\" />\n )}\n <Button\n variant=\"ghost\"\n size=\"sm\"\n className={`relative rounded-none bg-background px-2 py-1 hover:bg-background ${\n packageManager === pm\n ? \"text-primary\"\n : \"text-muted-foreground\"\n }`}\n onClick={() => setPackageManager(pm)}\n >\n {pm}\n {packageManager === pm && (\n <motion.div\n className=\"absolute inset-x-0 bottom-[1px] mx-auto h-0.5 w-[90%] bg-primary\"\n layoutId=\"activeTab\"\n initial={false}\n transition={{\n type: \"spring\",\n stiffness: 500,\n damping: 30,\n }}\n />\n )}\n </Button>\n </div>\n ))}\n </div>\n </div>\n )}\n </div>\n <div className=\"relative flex items-center\">\n <div className=\"min-w-[300px] grow font-mono\">\n {highlightedCode ? (\n <div\n className={`[&>pre]:overflow-x-auto [&>pre]:rounded-md [&>pre]:p-2 [&>pre]:px-4 [&>pre]:font-mono ${\n theme === \"dark\" ? \"dark\" : \"light\"\n }`}\n dangerouslySetInnerHTML={{ __html: highlightedCode }}\n />\n ) : (\n <pre className=\"rounded-md border border-border bg-white p-2 px-4 font-mono dark:bg-black\">\n {command}\n </pre>\n )}\n </div>\n <Button\n variant=\"outline\"\n size=\"icon\"\n className=\"relative ml-2 rounded-md\"\n onClick={copyToClipboard}\n aria-label={copied ? \"Copied\" : \"Copy to clipboard\"}\n >\n <span className=\"sr-only\">{copied ? \"Copied\" : \"Copy\"}</span>\n <Copy\n className={`h-4 w-4 transition-all duration-300 ${\n copied ? \"scale-0\" : \"scale-100\"\n }`}\n />\n <Check\n className={`absolute inset-0 m-auto h-4 w-4 transition-all duration-300 ${\n copied ? \"scale-100\" : \"scale-0\"\n }`}\n />\n </Button>\n </div>\n </div>\n </div>\n );\n}\n",
+ "type": "registry:ui",
+ "target": ""
+ }
+ ]
+}
\ No newline at end of file
diff --git a/registry/default/example/script-copy-btn-demo.tsx b/registry/default/example/script-copy-btn-demo.tsx
new file mode 100644
index 00000000..5b4da0ad
--- /dev/null
+++ b/registry/default/example/script-copy-btn-demo.tsx
@@ -0,0 +1,21 @@
+import ScriptCopyBtn from "@/registry/default/magicui/script-copy-btn";
+
+export default function ScriptCopyBtnDemo() {
+ const customCommandMap = {
+ npm: "npm run shadcn add button",
+ yarn: "yarn shadcn add button",
+ pnpm: "pnpm dlx shadcn@latest add button",
+ bun: "bun x shadcn@latest add button",
+ };
+ return (
+ <>
+ <ScriptCopyBtn
+ showMultiplePackageOptions={true}
+ codeLanguage="shell"
+ lightTheme="nord"
+ darkTheme="vitesse-dark"
+ commandMap={customCommandMap}
+ />
+ </>
+ );
+}
diff --git a/registry/default/magicui/dock.tsx b/registry/default/magicui/dock.tsx
index 13cd7a07..b712c2ac 100644
--- a/registry/default/magicui/dock.tsx
+++ b/registry/default/magicui/dock.tsx
@@ -1,15 +1,15 @@
"use client";
-import React, { PropsWithChildren, useRef } from "react";
import { cva, type VariantProps } from "class-variance-authority";
import {
motion,
+ MotionProps,
MotionValue,
useMotionValue,
useSpring,
useTransform,
- MotionProps,
} from "framer-motion";
+import React, { PropsWithChildren, useRef } from "react";
import { cn } from "@/lib/utils";
diff --git a/registry/default/magicui/script-copy-btn.tsx b/registry/default/magicui/script-copy-btn.tsx
new file mode 100644
index 00000000..00d30009
--- /dev/null
+++ b/registry/default/magicui/script-copy-btn.tsx
@@ -0,0 +1,147 @@
+"use client";
+
+import { Button } from "@/components/ui/button";
+import { cn } from "@/lib/utils";
+import { motion } from "framer-motion";
+import { Check, Copy } from "lucide-react";
+import { useTheme } from "next-themes";
+import { HTMLAttributes, useEffect, useState } from "react";
+import { codeToHtml } from "shiki";
+
+interface ScriptCopyBtnProps extends HTMLAttributes<HTMLDivElement> {
+ showMultiplePackageOptions?: boolean;
+ codeLanguage: string;
+ lightTheme: string;
+ darkTheme: string;
+ commandMap: Record<string, string>;
+ className?: string;
+}
+
+export default function ScriptCopyBtn({
+ showMultiplePackageOptions = true,
+ codeLanguage,
+ lightTheme,
+ darkTheme,
+ commandMap,
+ className,
+}: ScriptCopyBtnProps) {
+ const packageManagers = Object.keys(commandMap);
+ const [packageManager, setPackageManager] = useState(packageManagers[0]);
+ const [copied, setCopied] = useState(false);
+ const [highlightedCode, setHighlightedCode] = useState("");
+ const { theme } = useTheme();
+ const command = commandMap[packageManager];
+
+ useEffect(() => {
+ async function loadHighlightedCode() {
+ try {
+ const highlighted = await codeToHtml(command, {
+ lang: codeLanguage,
+ themes: {
+ light: lightTheme,
+ dark: darkTheme,
+ },
+ defaultColor: theme === "dark" ? "dark" : "light",
+ });
+ setHighlightedCode(highlighted);
+ } catch (error) {
+ console.error("Error highlighting code:", error);
+ setHighlightedCode(`<pre>${command}</pre>`);
+ }
+ }
+
+ loadHighlightedCode();
+ }, [command, theme, codeLanguage, lightTheme, darkTheme]);
+
+ const copyToClipboard = () => {
+ navigator.clipboard.writeText(command);
+ setCopied(true);
+ setTimeout(() => setCopied(false), 2000);
+ };
+
+ return (
+ <div
+ className={cn(
+ "mx-auto flex max-w-md items-center justify-center",
+ className,
+ )}
+ >
+ <div className="w-full space-y-2">
+ <div className="mb-2 flex items-center justify-between">
+ {showMultiplePackageOptions && (
+ <div className="relative">
+ <div className="inline-flex overflow-hidden rounded-md border border-border text-xs">
+ {packageManagers.map((pm, index) => (
+ <div key={pm} className="flex items-center">
+ {index > 0 && (
+ <div className="h-4 w-px bg-border" aria-hidden="true" />
+ )}
+ <Button
+ variant="ghost"
+ size="sm"
+ className={`relative rounded-none bg-background px-2 py-1 hover:bg-background ${
+ packageManager === pm
+ ? "text-primary"
+ : "text-muted-foreground"
+ }`}
+ onClick={() => setPackageManager(pm)}
+ >
+ {pm}
+ {packageManager === pm && (
+ <motion.div
+ className="absolute inset-x-0 bottom-[1px] mx-auto h-0.5 w-[90%] bg-primary"
+ layoutId="activeTab"
+ initial={false}
+ transition={{
+ type: "spring",
+ stiffness: 500,
+ damping: 30,
+ }}
+ />
+ )}
+ </Button>
+ </div>
+ ))}
+ </div>
+ </div>
+ )}
+ </div>
+ <div className="relative flex items-center">
+ <div className="min-w-[300px] grow font-mono">
+ {highlightedCode ? (
+ <div
+ className={`[&>pre]:overflow-x-auto [&>pre]:rounded-md [&>pre]:p-2 [&>pre]:px-4 [&>pre]:font-mono ${
+ theme === "dark" ? "dark" : "light"
+ }`}
+ dangerouslySetInnerHTML={{ __html: highlightedCode }}
+ />
+ ) : (
+ <pre className="rounded-md border border-border bg-white p-2 px-4 font-mono dark:bg-black">
+ {command}
+ </pre>
+ )}
+ </div>
+ <Button
+ variant="outline"
+ size="icon"
+ className="relative ml-2 rounded-md"
+ onClick={copyToClipboard}
+ aria-label={copied ? "Copied" : "Copy to clipboard"}
+ >
+ <span className="sr-only">{copied ? "Copied" : "Copy"}</span>
+ <Copy
+ className={`h-4 w-4 transition-all duration-300 ${
+ copied ? "scale-0" : "scale-100"
+ }`}
+ />
+ <Check
+ className={`absolute inset-0 m-auto h-4 w-4 transition-all duration-300 ${
+ copied ? "scale-100" : "scale-0"
+ }`}
+ />
+ </Button>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/registry/registry-examples.ts b/registry/registry-examples.ts
index df688a84..ad02fc67 100644
--- a/registry/registry-examples.ts
+++ b/registry/registry-examples.ts
@@ -103,6 +103,11 @@ export const examples: Registry = [
type: "registry:example",
files: ["example/code-comparison-demo.tsx"],
},
+ {
+ name: "script-copy-btn-demo",
+ type: "registry:example",
+ files: ["example/script-copy-btn-demo.tsx"],
+ },
{
name: "marquee-demo",
type: "registry:example",
diff --git a/registry/registry-ui.ts b/registry/registry-ui.ts
index e82a4882..2058894e 100644
--- a/registry/registry-ui.ts
+++ b/registry/registry-ui.ts
@@ -104,6 +104,12 @@ export const ui: Registry = [
dependencies: ["shiki", "next-themes"],
files: ["magicui/code-comparison.tsx"],
},
+ {
+ name: "script-copy-btn",
+ type: "registry:ui",
+ dependencies: ["framer-motion", "shiki", "next-themes"],
+ files: ["magicui/script-copy-btn.tsx"],
+ },
{
name: "marquee",
type: "registry:ui",