-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SOEOPSFY24-310 | prototype gradient banner (#8)
* SOEOPSFY24-310 | prototype gradient banner * fix lint * switch over to fade out animtion instead of on scroll * lint
- Loading branch information
1 parent
bf98c97
commit 8a07c83
Showing
10 changed files
with
146 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from './AnimateInView'; | ||
export * from './AnimationMap'; | ||
export * from "./AnimateInView"; | ||
export * from "./AnimationMap"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,57 @@ | ||
import { m } from 'framer-motion'; | ||
import { m } from "framer-motion"; | ||
|
||
type AnimatedTextProps = { | ||
text: string; | ||
}; | ||
|
||
export const AnimatedText = ({ text }: AnimatedTextProps) => { | ||
// splitting text into letters | ||
const words = text.split(' '); | ||
// splitting text into letters | ||
const words = text.split(" "); | ||
|
||
// Variants for Container of words. | ||
const container = { | ||
hidden: { opacity: 0 }, | ||
visible: (i = 1) => ({ | ||
opacity: 1, | ||
transition: { staggerChildren: 0.12, delayChildren: 0.04 * i }, | ||
}), | ||
}; | ||
// Variants for Container of words. | ||
const container = { | ||
hidden: { opacity: 0 }, | ||
visible: (i = 1) => ({ | ||
opacity: 1, | ||
transition: { staggerChildren: 0.12, delayChildren: 0.04 * i }, | ||
}), | ||
}; | ||
|
||
// Variants for each word. | ||
// Variants for each word. | ||
|
||
const child = { | ||
visible: { | ||
opacity: 1, | ||
x: 0, | ||
transition: { | ||
type: 'spring', | ||
damping: 12, | ||
stiffness: 100, | ||
const child = { | ||
visible: { | ||
opacity: 1, | ||
x: 0, | ||
transition: { | ||
type: "spring", | ||
damping: 12, | ||
stiffness: 100, | ||
}, | ||
}, | ||
}, | ||
hidden: { | ||
opacity: 0, | ||
x: 20, | ||
transition: { | ||
type: 'spring', | ||
damping: 12, | ||
stiffness: 100, | ||
hidden: { | ||
opacity: 0, | ||
x: 20, | ||
transition: { | ||
type: "spring", | ||
damping: 12, | ||
stiffness: 100, | ||
}, | ||
}, | ||
}, | ||
}; | ||
}; | ||
|
||
return ( | ||
<m.span | ||
className="flex flex-wrap gap-x-[0.3em] w-fit" | ||
variants={container} | ||
initial="hidden" | ||
animate="visible" | ||
> | ||
{words.map((word, index) => ( | ||
<m.span | ||
variants={child} | ||
key={`${word}-${index}`} | ||
> | ||
{word} | ||
</m.span> | ||
))} | ||
</m.span> | ||
); | ||
return ( | ||
<m.span | ||
className="flex flex-wrap gap-x-[0.3em] w-fit" | ||
variants={container} | ||
initial="hidden" | ||
animate="visible" | ||
> | ||
{words.map((word, index) => ( | ||
<m.span variants={child} key={`${word}-${index}`}> | ||
{word} | ||
</m.span> | ||
))} | ||
</m.span> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
export * from "./FeatureHero"; | ||
export * from "./FeatureHero.styles"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"use client"; | ||
|
||
import { HTMLAttributes, useRef } from "react"; | ||
import { Container } from "@/components/Container"; | ||
import { motion, useScroll, useTransform } from "framer-motion"; | ||
|
||
type GradientBannerProps = HTMLAttributes<HTMLDivElement> & { | ||
children: React.ReactNode; | ||
}; | ||
|
||
export const GradientBanner = ({ children, ...props }: GradientBannerProps) => { | ||
const ref = useRef(null); | ||
const { scrollYProgress } = useScroll({ | ||
target: ref, | ||
}); | ||
|
||
const gradientPosition = useTransform( | ||
scrollYProgress, | ||
[0, 1], | ||
[ | ||
"linear-gradient(90deg, #C74632 20%, #610058 100%)", | ||
"linear-gradient(90deg, #610058 20%, #C74632 100%)", | ||
], | ||
); | ||
|
||
return ( | ||
<Container width="full" {...props}> | ||
<motion.div | ||
ref={ref} | ||
style={{ background: gradientPosition }} | ||
className="flex flex-col justify-center text-white w-full h-full rs-py-9 cc *:font-dm-sans" | ||
> | ||
{children} | ||
</motion.div> | ||
</Container> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./GradientBanner"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters