Skip to content

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

feat: separate away (#35)

Rudy3c5e527a3a55
diff --git a/config/docs.ts b/config/docs.ts
index 94023c24..95d7e006 100644
--- a/config/docs.ts
+++ b/config/docs.ts
@@ -169,6 +169,12 @@ export const docsConfig: DocsConfig = {
items: [],
label: "New",
},
+ {
+ title: "Separate Away",
+ href: `/docs/components/separate-away`,
+ items: [],
+ label: "New",
+ },
],
},
{
diff --git a/content/docs/components/separate-away.mdx b/content/docs/components/separate-away.mdx
new file mode 100644
index 00000000..01859524
--- /dev/null
+++ b/content/docs/components/separate-away.mdx
@@ -0,0 +1,34 @@
+---
+title: Separate Away
+date: 2024-05-22
+description: Vertical separation of words
+author: whyismynamerudy
+published: true
+---
+
+<ComponentPreview name="separate-away-demo" />
+
+<Steps>
+
+### Installation
+
+Copy and paste the following code into your project.
+
+```text
+components/magicui/separate-away.tsx
+```
+
+<ComponentSource name="separate-away" />
+
+</Steps>
+
+## Props
+
+| Prop | Type | Description | Default |
+| -------------- | ------ | --------------------------------------------- | ------- |
+| className | string | The class name to be applied to the component | |
+| upperText | string | The words to be separated upwards | " |
+| lowerText | string | The words to be separated downwards | " |
+| duration | number | Duration of the separation animation | 1.5 |
+| hiddenOpacity | number | Opacity of the text when it's hidden | 0 |
+| visibleOpacity | number | Opacity of the text when it's visible | 1 |
diff --git a/registry/components/example/separate-away-demo.tsx b/registry/components/example/separate-away-demo.tsx
new file mode 100644
index 00000000..6a82a4ed
--- /dev/null
+++ b/registry/components/example/separate-away-demo.tsx
@@ -0,0 +1,14 @@
+import { SeparateAway } from "../magicui/separate-away";
+
+export default async function SeparateAwayDemo() {
+ return (
+ <SeparateAway
+ upper_text="Separate"
+ lower_text="Away"
+ duration={1.5}
+ hidden_opacity={0}
+ visible_opacity={1}
+ className="font-display text-center text-4xl font-bold tracking-[-0.02em] text-black dark:text-white md:text-7xl md:leading-[5rem]"
+ />
+ );
+}
diff --git a/registry/components/magicui/separate-away.tsx b/registry/components/magicui/separate-away.tsx
new file mode 100644
index 00000000..4611c4e2
--- /dev/null
+++ b/registry/components/magicui/separate-away.tsx
@@ -0,0 +1,54 @@
+"use client";
+
+import { cn } from "@/lib/utils";
+import { motion } from "framer-motion";
+
+interface SeparateAwayProps {
+ upper_text: string;
+ lower_text: string;
+ duration?: number;
+ hidden_opacity?: number;
+ visible_opacity?: number;
+ className?: string;
+}
+
+export function SeparateAway({
+ upper_text,
+ lower_text,
+ duration = 1.5,
+ hidden_opacity = 0,
+ visible_opacity = 1,
+ className,
+}: SeparateAwayProps) {
+ const separate = {
+ hidden: { opacity: hidden_opacity, y: 0 },
+ visible: (custom: number) => ({
+ opacity: visible_opacity,
+ y: custom * 5,
+ transition: { duration: duration },
+ }),
+ };
+
+ return (
+ <div>
+ <motion.h1
+ custom={-1}
+ variants={separate}
+ initial="hidden"
+ animate="visible"
+ className={cn(className)}
+ >
+ {upper_text}
+ </motion.h1>
+ <motion.h1
+ custom={1}
+ variants={separate}
+ initial="hidden"
+ animate="visible"
+ className={cn(className)}
+ >
+ {lower_text}
+ </motion.h1>
+ </div>
+ );
+}
diff --git a/registry/index.tsx b/registry/index.tsx
index 72617868..8cd8d108 100644
--- a/registry/index.tsx
+++ b/registry/index.tsx
@@ -157,6 +157,11 @@ const ui: Registry = {
type: "components:ui",
files: ["registry/components/magicui/blur-in.tsx"],
},
+ "separate-away": {
+ name: "separate-away",
+ type: "components:ui",
+ files: ["registry/components/magicui/separate-away.tsx"],
+ },
};
const example: Registry = {
@@ -596,7 +601,6 @@ const example: Registry = {
() => import("@/registry/components/example/wavy-text-demo"),
),
},
-
"blur-in-demo": {
name: "blur-in-demo",
type: "components:example",
@@ -605,6 +609,14 @@ const example: Registry = {
() => import("@/registry/components/example/blur-in-demo"),
),
},
+ "separate-away-demo": {
+ name: "separate-away-demo",
+ type: "components:example",
+ files: ["registry/components/example/separate-away-demo.tsx"],
+ component: React.lazy(
+ () => import("@/registry/components/example/separate-away-demo"),
+ ),
+ },
};
export const registry: Registry = {