import React from "react";
import { Container } from "../util/container";
import { Section } from "../util/section";
import type { Template } from "tinacms";
import { PageBlocksMainTitle } from "../../tina/__generated__/types";
import { tinaField } from "tinacms/dist/react";
import { PageBlockFunction } from "../blocks-renderer";

export const MainTitle: PageBlockFunction<PageBlocksMainTitle> = ({ data }) => {
    return (
        <Section>
            <Container
                className={ "prose default-text-color my-2 main-title" }

                size="custom"
                width="large"
            >
                <div className={ "main-title" }
                    data-tina-field={ tinaField(data, "title") }>
                    { data.title }
                </div>
            </Container>
        </Section>
    );
};

export const mainTitleBlockSchema: Template = {
    name: "mainTitle",
    label: "Main title",
    ui: {
        previewSrc: "/blocks/content.png",
        defaultItem: {
            title: "Lorem ipsum"
        }
    },
    fields: [
        {
            type: "string",
            label: "Title",
            name: "title"
        }
    ]
};
