Giter Club home page Giter Club logo

react-stackblitz's Introduction

React StackBlitz

Build & Deploy Issues Forks Stars Release npm version

A React component is provided that allows you to programmatically generate stackblitz projects from code samples on the fly.

Install

npm install @uiw/react-stackblitz --save

Usage

import React from 'react';
import StackBlitz from '@uiw/react-stackblitz';

const code = `import React from "react";
import ReactDOM from "react-dom";
import Avatar from '@uiw/react-avatar';
import "@uiw/react-avatar/lib/esm/style/index.css";

ReactDOM.render(
  <div>
    <div style={{ paddingBottom: 20 }}>
      <Avatar icon="user" />
      <Avatar size="small" icon="user" />
    </div>
    <div>
      <Avatar shape="square" size="large" icon="user" />
      <Avatar shape="square" icon="user" />
      <Avatar shape="square" size="small" icon="user" />
      <Avatar shape="square" size="mini" icon="user" />
    </div>
  </div>,
  document.getElementById("root")
);`;

const Example = () => {
  return (
    <StackBlitz
      template="create-react-app"
      title="uiw"
      description="uiw v4.7.2 - demo"
      tags={["stackblitz", "uiw", "react"]}
      dependencies={{
        "react": "17.0.1",
        "react-dom": "17.0.1",
        "@uiw/react-avatar": "4.7.2",
        "@babel/runtime": "7.12.5",
      }}
      files={{
        "index.html": `<div id="root"></div>`,
        "index.js": code,
      }}
    >
      Basic Example Open in StackBlitz
    </StackBlitz>
  )
}

Props

type StackBlitzProps = Project & React.ButtonHTMLAttributes<HTMLButtonElement> & {
  /**
   * String of the Github username, repo and optionally branch/tag/commit.
   * https://developer.stackblitz.com/docs/platform/javascript-sdk#sdkopengithubprojectreposlug-opts
   */
  repoSlug?: string;
  projectId?: string;
  embedOpts?: EmbedOpts;
  openOpts?: OpenOptions;
};

Development

Runs the project in development mode.

# Step 1, run first, listen to the component compile and output the .js file
# listen for compilation output type .d.ts file
npm run watch
# Step 2, development mode, listen to compile preview website instance
npm run start

production

Builds the app for production to the build folder.

npm run build

The build is minified and the filenames include the hashes. Your app is ready to be deployed!

Related

Contributors

As always, thanks to our amazing contributors!

Made with github-action-contributors.

License

Licensed under the MIT License.

react-stackblitz's People

Contributors

jaywcjlove avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-stackblitz's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Other Branches

These updates are pending. To force PRs open, click the checkbox below.

  • chore(deps): update actions/checkout action to v4
  • chore(deps): update actions/setup-node action to v4
  • chore(deps): update peaceiris/actions-gh-pages action to v4

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/ci.yml
  • actions/checkout v3
  • actions/setup-node v3
  • peaceiris/actions-gh-pages v3
  • ncipollo/release-action v1
npm
package.json
  • @stackblitz/sdk ~1.9.0
  • @kkt/less-modules ^7.4.9
  • @kkt/raw-modules ^7.4.9
  • @kkt/scope-plugin-options ^7.4.9
  • @types/react ^18.0.33
  • @types/react-dom ^18.0.11
  • @uiw/react-github-corners ~1.5.3
  • @uiw/react-markdown-preview ^4.1.10
  • react ^18.2.0
  • react-dom ^18.2.0
  • kkt ^7.4.9
  • tsbb ^4.1.4
  • react >=16.9.0
  • react-dom >=16.9.0
  • @babel/runtime >=7.10.0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.