Coder Social home page Coder Social logo

wangsai / demoit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from krasimir/demoit

0.0 2.0 0.0 26.21 MB

Demoit is a small tool for live coding exercises.

Home Page: https://krasimir.github.io/demoit/dist/?state=../samples/React.json,../samples/Vue.json,../samples/HTML+CSS.json

License: MIT License

JavaScript 77.19% HTML 5.12% CSS 17.70%

demoit's Introduction

demoit

Demoit is a interactive JavaScript playground

  • No installation.
  • No server needed. It works offline.
  • No building process needed. Built-in Babel support. It translates your code at runtime.
  • Supports external libraries and styles. Like React for example.
  • Persistent via localStorage
  • Easy export of the current code
  • Supports import statement (between the files of app)
  • Supports importing of CSS and HTML files

Demo ๐Ÿš€


Usage

Configuration

When you open the app and start writing code you progress gets saved to the local storage. You can grab it by clicking on the gear icon in the lower right corner of the screen (check section "Local storage"). The JSON there contains all the configuration that Demoit needs. You can save this configuration to an external file and let Demoit knows the path to it via the state GET parameter (for example http://localhost/demoit?state=./mycode.json).

Here is what the configuration may contain:

{
  "editor": {
    "theme": "material",
    "layout": {
      "direction": "vertical",
      "sizes": [
        30,
        70
      ],
      "elements": [
        {
          "direction": "horizontal",
          "sizes": [
            50,
            50
          ],
          "elements": [
            "output",
            "log"
          ]
        },
        "editor"
      ]
    }
  },
  "dependencies": [
    "./resources/react-16.7.0-alpha.0.js",
    "./resources/react-dom.16.7.0-alpha.0.js",
    "./resources/styles.css"
  ],
  "files": [
    {
      "filename": "script.js",
      "content": "const message = 'Hello world';\nconsole.log(message);"
    }
  ]
}
  • editor
    • theme - Demoit uses CodeMirror as an editor so here you can place some of its build-in themes. Check them out here.
    • layout - this field defines how the app looks like. Which of the sections are displayed and what's their size.
  • dependencies - an array of files that your demo needs. This could be JavaScript or CSS files. They may be local or not. Demoit will fetch those resources before running your code files.
  • files - It contains an array of items representing your scripts.

GET Params

  • ?state= - relative path to a JSON file

Continuing your work offline

  • You have to download Demoit.zip
  • You need to transfer your progress to a JSON file and pass it to the app via state GET param
  • If you use external dependencies make sure that they are also saved locally and the path to the files is properly set (check the gear icon in the lower right corner of the screen)

Keyboard shortcuts

  • Ctrl + S and Cmd + S which is basically triggering a new run of your current file.

Editing filenames and deleting files

Right mouse click on the file's tab.

Troubleshooting

Error URL scheme must be "http" or "https" for CORS request.

It means that the browser doesn't load the files that the tool needs because the protocol is file://. That's a problem in Chrome at the moment. Everything works fine in Firefox. To fix the problem in Chrome you have to run it like so:

open /Applications/Google\ Chrome.app/ --args --disable-web-security

or under Windows:

chrome.exe --disable-web-security

Of course Demoit works just fine if you open index.html via http protocol but to do that you need a server.

demoit's People

Watchers

 avatar  avatar

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.