1
0

user-text.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { useEffect, useRef } from "react";
  2. export const UserText = ({ message }: { message: string }) => {
  3. const scrollRef = useRef<HTMLDivElement>(null);
  4. // Replace all of the emotion tag in message with ""
  5. message = message.replace(/\[(.*?)\]/g, "");
  6. useEffect(() => {
  7. scrollRef.current?.scrollIntoView({
  8. behavior: "smooth",
  9. block: "center",
  10. });
  11. });
  12. return (
  13. <div className="absolute bottom-0 left-0 mb-5 w-full">
  14. <div className="mx-auto max-w-4xl w-full px-4 md:px-16">
  15. <div className="backdrop-blur-lg rounded-lg">
  16. <div className="bg-white/70 rounded-lg backdrop-blur-lg shadow-lg">
  17. <div className="px-8 pr-1 py-3 bg-rose/90 rounded-t-lg text-white font-bold tracking-wider">
  18. <span className="p-4 bg-cyan-600/80 rounded-lg rounded-tl-none rounded-tr-none shadow-sm">
  19. {"YOU"}
  20. </span>
  21. </div>
  22. <div className="px-8 py-4 max-h-32 overflow-y-auto">
  23. <div className="min-h-8 max-h-full typography-16 font-bold text-gray-600">
  24. {message.replace(/\[([a-zA-Z]*?)\]/g, "")}
  25. <div ref={scrollRef} />
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. );
  33. };