RichSlideSection.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import type { JSX, ReactNode } from 'react';
  2. import React from 'react';
  3. type RichSlideSectionProps = {
  4. children?: ReactNode;
  5. presentation?: boolean;
  6. };
  7. const OriginalRichSlideSection = React.memo(
  8. (props: RichSlideSectionProps): JSX.Element => {
  9. const { children, presentation } = props;
  10. return (
  11. <section className={presentation ? 'm-2' : 'shadow rounded m-2'}>
  12. <svg data-marpit-svg="" viewBox="0 0 1280 720">
  13. <title>Rich Slide Section</title>
  14. <foreignObject width="1280" height="720">
  15. <section>{children}</section>
  16. </foreignObject>
  17. </svg>
  18. </section>
  19. );
  20. },
  21. );
  22. const RichSlideSectionNoMemorized = (
  23. props: RichSlideSectionProps,
  24. ): JSX.Element => {
  25. const { children } = props;
  26. return <OriginalRichSlideSection>{children}</OriginalRichSlideSection>;
  27. };
  28. export const RichSlideSection = React.memo(
  29. RichSlideSectionNoMemorized,
  30. ) as typeof RichSlideSectionNoMemorized;
  31. const PresentationRichSlideSectionNoMemorized = (
  32. props: RichSlideSectionProps,
  33. ): JSX.Element => {
  34. const { children } = props;
  35. return (
  36. <OriginalRichSlideSection presentation>{children}</OriginalRichSlideSection>
  37. );
  38. };
  39. export const PresentationRichSlideSection = React.memo(
  40. PresentationRichSlideSectionNoMemorized,
  41. ) as typeof PresentationRichSlideSectionNoMemorized;