feat(ui): expand layout width to 1640px, fix word breaking, polish buttons and colors, implement 3 horizontal animated processing cards in how section
This commit is contained in:
@@ -79,44 +79,15 @@ export function TextAnimate({
|
||||
hidden: {},
|
||||
show: {
|
||||
transition: {
|
||||
staggerChildren: by === 'character' ? 0.02 : 0.06,
|
||||
staggerChildren: by === 'character' ? 0.015 : 0.05,
|
||||
delayChildren: delay,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// If animating by character, group by words to prevent broken line wrapping!
|
||||
if (by === 'character') {
|
||||
const words = children.split(' ');
|
||||
return (
|
||||
<motion.span
|
||||
variants={containerVariants}
|
||||
initial="hidden"
|
||||
whileInView={startOnView ? 'show' : undefined}
|
||||
animate={!startOnView ? 'show' : undefined}
|
||||
viewport={{ once, margin: '-20px' }}
|
||||
className={`inline-block ${className}`}
|
||||
>
|
||||
{words.map((word, wIdx) => (
|
||||
<span key={wIdx} className="inline-block whitespace-nowrap">
|
||||
{Array.from(word).map((char, cIdx) => (
|
||||
<motion.span
|
||||
key={`${char}-${cIdx}`}
|
||||
variants={itemVariant}
|
||||
className="inline-block"
|
||||
>
|
||||
{char}
|
||||
</motion.span>
|
||||
))}
|
||||
{wIdx < words.length - 1 && <span> </span>}
|
||||
</span>
|
||||
))}
|
||||
</motion.span>
|
||||
);
|
||||
}
|
||||
|
||||
// Word or line animation
|
||||
const segments = by === 'word' ? children.split(' ') : children.split('\n');
|
||||
// Split text into words. Every word is guaranteed to be in an inline-block whitespace-nowrap
|
||||
// wrapper so that NO WORD EVER BREAKS MID-WORD onto two lines.
|
||||
const words = children.split(/\s+/).filter(Boolean);
|
||||
|
||||
return (
|
||||
<motion.span
|
||||
@@ -125,17 +96,32 @@ export function TextAnimate({
|
||||
whileInView={startOnView ? 'show' : undefined}
|
||||
animate={!startOnView ? 'show' : undefined}
|
||||
viewport={{ once, margin: '-20px' }}
|
||||
className={`inline-block ${className}`}
|
||||
className={`inline ${className}`}
|
||||
>
|
||||
{segments.map((segment, index) => (
|
||||
<motion.span
|
||||
key={`${segment}-${index}`}
|
||||
variants={itemVariant}
|
||||
className="inline-block"
|
||||
>
|
||||
{segment}
|
||||
{by === 'word' && index < segments.length - 1 && '\u00A0'}
|
||||
</motion.span>
|
||||
{words.map((word, wIdx) => (
|
||||
<React.Fragment key={wIdx}>
|
||||
<span className="inline-block whitespace-nowrap">
|
||||
{by === 'character' ? (
|
||||
Array.from(word).map((char, cIdx) => (
|
||||
<motion.span
|
||||
key={`${char}-${cIdx}`}
|
||||
variants={itemVariant}
|
||||
className="inline-block"
|
||||
>
|
||||
{char}
|
||||
</motion.span>
|
||||
))
|
||||
) : (
|
||||
<motion.span
|
||||
variants={itemVariant}
|
||||
className="inline-block"
|
||||
>
|
||||
{word}
|
||||
</motion.span>
|
||||
)}
|
||||
</span>
|
||||
{wIdx < words.length - 1 && ' '}
|
||||
</React.Fragment>
|
||||
))}
|
||||
</motion.span>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user