editor icon indicating copy to clipboard operation
editor copied to clipboard

Run button is not present if Preview component is not set.

Open pixeleet opened this issue 2 years ago • 2 comments

image

Given the following sandpackConfig

const sandpackConfig = {
  defaultPreset: "default",
  presets: [
    {
      name: "default",
      meta: "live",
      label: "TypeScript",
      sandpackTemplate: "vanilla-ts",
      sandpackTheme: "light",
      snippetFileName: "/index.ts",
      snippetLanguage: "ts",
      initialSnippetContent: [
        'import "./styles.css";',
        'document.getElementById("app").innerHTML = `<h1>Hello world</h1>`;',
      ].join("\n"),
    },
  ],
  panes: {
    console: true,
    preview: false,
  },
};

I guess the need for the solution where we pass down the Sandpack Panels as components instead of just flags is surfacing, as this setting is something we'd have to change on the SandpackCodeEditor by adding showRunButton prop.

pixeleet avatar Jul 23 '23 10:07 pixeleet

I think it's better to go for a React.ComponentType prop in SandpackConfig that gets rendered so that the developer can adjust the Sandpack configuration up to their needs.

Should not be hard to do so, I think I will be able to get to that this week. Happy to accept a PR as well.

petyosi avatar Jul 23 '23 16:07 petyosi

I'll be fixing up some other personal projects, feel free to wait for a PR from me if it's not urgent and no-one else is bothered by this.

pixeleet avatar Jul 24 '23 12:07 pixeleet