import { TinaMarkdown } from 'tinacms/dist/rich-text';
import { motion } from 'framer-motion';
import './BlockTextBlock.css';

interface Props {
  content?: unknown;
  width?: 'full' | 'narrow';
}

const BlockTextBlock: React.FC<Props> = ({ content, width = 'full' }) => {
  if (!content) return null;

  return (
    <motion.section
      className={`block-text-block block-text-block--${width}`}
      initial={{ opacity: 0, y: 30 }}
      whileInView={{ opacity: 1, y: 0 }}
      viewport={{ once: true }}
      transition={{ duration: 0.5 }}
    >
      <div className="block-text-block-inner">
        <TinaMarkdown content={content as any} />
      </div>
    </motion.section>
  );
};

export default BlockTextBlock;
