Skip to content
Snippets Groups Projects
Text.tsx 3.27 KiB
Newer Older
tovo's avatar
tovo committed
import React from "react"
Julien MARGAIL's avatar
Julien MARGAIL committed
import { twMerge } from "tailwind-merge"
Julien MARGAIL's avatar
Julien MARGAIL committed
import { InformationCircleIcon } from "@heroicons/react/outline"
import { Button } from "@onegeo-suite/gatsby-theme-onegeo"
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 || {}
Manoa Harinjo's avatar
Manoa Harinjo committed
    const oTooltip = options.tooltip || {}
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
                    )}
                >
Julien MARGAIL's avatar
Julien MARGAIL committed
                    {title}
Manoa Harinjo's avatar
Manoa Harinjo committed
                    {oTooltip.title ? (
Julien MARGAIL's avatar
Julien MARGAIL committed
                        <span
                            className="tooltip tooltip-info text-info ml-2 font-normal"
Manoa Harinjo's avatar
Manoa Harinjo committed
                            data-tip={oTooltip.title}
                        >
Julien MARGAIL's avatar
Julien MARGAIL committed
                            <InformationCircleIcon className=" h-5 w-5 cursor-pointer" />
                        </span>
                    ) : null}
Julien MARGAIL's avatar
Julien MARGAIL committed
                </h2>
            )}
tovo's avatar
tovo committed
            {content && (
Manoa Harinjo's avatar
Manoa Harinjo committed
                <>
                    <span
                        className={twMerge(
                            "pt-10 text-justify text-xl leading-8 ",
                            oClass.content
                        )}
                        dangerouslySetInnerHTML={{ __html: content }}
                    />
                    {oTooltip.content ? (
                        <span
                            className="tooltip tooltip-base-100 tooltip-color:tooltip-base-100!"
                            data-tip={oTooltip.content}
                        >
                            <svg
                                xmlns="http://www.w3.org/2000/svg"
                                fill="none"
                                viewBox="0 0 24 24"
                                stroke="currentColor"
                                strokeWidth={2}
                                className="text-secondary h-5 w-5 cursor-pointer"
                            >
                                <path
                                    strokeLinecap="round"
                                    strokeLinejoin="round"
                                    d="M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"
                                />
                            </svg>
                        </span>
                    ) : (
                        <></>
Julien MARGAIL's avatar
Julien MARGAIL committed
                    )}
Manoa Harinjo's avatar
Manoa Harinjo committed
                </>
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