quote-block.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import React from "react";
  2. import { useCurrentFrame, interpolate, Easing } from "remotion";
  3. interface QuoteBlockProps {
  4. quote: string;
  5. author?: string;
  6. color?: string;
  7. }
  8. export const QuoteBlock: React.FC<QuoteBlockProps> = ({
  9. quote,
  10. author,
  11. color = "#f97316",
  12. }) => {
  13. const frame = useCurrentFrame();
  14. const opacity = interpolate(frame, [0, 15], [0, 1], {
  15. extrapolateRight: "clamp",
  16. });
  17. const scale = interpolate(frame, [0, 12], [0.95, 1], {
  18. extrapolateRight: "clamp",
  19. easing: Easing.out(Easing.cubic),
  20. });
  21. // Typewriter effect for quote text
  22. const charsVisible = Math.floor(
  23. interpolate(frame, [5, 5 + quote.length * 1.5], [0, quote.length], {
  24. extrapolateRight: "clamp",
  25. })
  26. );
  27. const displayText = quote.slice(0, charsVisible);
  28. return (
  29. <div
  30. style={{
  31. opacity,
  32. transform: `scale(${scale})`,
  33. position: "relative",
  34. paddingLeft: 40,
  35. }}
  36. >
  37. {/* Quote mark */}
  38. <div
  39. style={{
  40. position: "absolute",
  41. top: -20,
  42. left: 0,
  43. fontSize: 80,
  44. lineHeight: 1,
  45. color,
  46. fontFamily: "Georgia, serif",
  47. fontWeight: 700,
  48. }}
  49. >
  50. "
  51. </div>
  52. <div
  53. style={{
  54. fontSize: 36,
  55. fontStyle: "italic",
  56. color: "white",
  57. fontFamily: "Georgia, serif",
  58. lineHeight: 1.6,
  59. maxWidth: "90%",
  60. }}
  61. >
  62. {displayText}
  63. <span
  64. style={{
  65. display: "inline-block",
  66. width: 2,
  67. height: 36,
  68. backgroundColor: color,
  69. marginLeft: 2,
  70. animation: "blink 0.8s infinite",
  71. }}
  72. />
  73. </div>
  74. {author && (
  75. <div
  76. style={{
  77. marginTop: 20,
  78. fontSize: 22,
  79. color: "#9ca3af",
  80. fontFamily: "sans-serif",
  81. }}
  82. >
  83. — {author}
  84. </div>
  85. )}
  86. </div>
  87. );
  88. };