Skip to content
Snippets Groups Projects
Text.tsx 1.54 KiB
Newer Older
tovo's avatar
tovo committed
import React from "react"
import Button from "./core/Button"
Julien MARGAIL's avatar
Julien MARGAIL committed
import { twMerge } from "tailwind-merge"
tovo's avatar
tovo committed

interface IText {
    title?: string
    content?: string
    className?: string
    action?: {
        name?: string
        url?: string
        className?: string
    }
Julien MARGAIL's avatar
Julien MARGAIL committed
    options?: any
tovo's avatar
tovo committed
}

const Text = (props: IText) => {
    const { title, content, className = "", action } = props
Julien MARGAIL's avatar
Julien MARGAIL committed
    const options = props.options ?? {}
    const oClass = options.class || {}

tovo's avatar
tovo committed
    return (
Julien MARGAIL's avatar
Julien MARGAIL committed
        <div className={twMerge(oClass.main, className)}>
            {title && (
                <h2
                    className={twMerge(
                        "font-extrabold sm:text-4xl",
                        oClass.title
                    )}
                >
                    {title}
                </h2>
            )}
tovo's avatar
tovo committed
            {content && (
Tovo Ramontalambo's avatar
Tovo Ramontalambo committed
                <div
Julien MARGAIL's avatar
Julien MARGAIL committed
                    className={twMerge(
                        "pt-10 text-justify text-xl leading-8",
                        oClass.content
                    )}
Tovo Ramontalambo's avatar
Tovo Ramontalambo committed
                    dangerouslySetInnerHTML={{ __html: content }}
                ></div>
tovo's avatar
tovo committed
            )}
Julien MARGAIL's avatar
Julien MARGAIL committed
            {action && action.name !== "" ? (
                <Button
                    {...action}
                    className={twMerge(
                        "mt-10",
                        action.className,
                        oClass.action
                    )}
                    {...options.action}
                />
            ) : (
                <></>
tovo's avatar
tovo committed
            )}
        </div>
    )
}

export default Text