import XNode from "@web-atoms/core/dist/core/XNode";

export interface IStackBlitzView {
    stackBlitzUrl: string;
    file?: string;
    embed?: number;
    hideExplorer?:number;
    initialPath?: string;
    minHeight?: number;
}

export default function StackBlitzView({
    stackBlitzUrl,
    file,
    initialPath = "/index.html",
    embed = 1,
    hideExplorer = 0,
    minHeight = 800
}: IStackBlitzView) {
    const url = new URL(stackBlitzUrl);
    url.searchParams.append("embed", embed.toString());
    url.searchParams.append("hideExplorer", hideExplorer.toString());
    url.searchParams.append("file", file.toString());
    url.searchParams.append("initialPath", initialPath.toString());
    return <iframe
        src={url.toString()}
        style-min-height={`${minHeight}px`}
        />
}