Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

demobox

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

demobox

Demo Page Generator & Live Editor Component

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

There are three ways to use demobox, for varying simplicity and flexibility.

  1. demo page generator
  2. drop-in script
  3. react component

Demo Page Generator

The demobox cli tool will turn a regular markdown file with annotated code snippets into a stylish demo page with editable examples. You can look at the markdown source for this page here as an example. Also the source for the demo page (demo.md) showcases a number of features.

$ npm install -g demobox
$ demobox -i demo.md -o demo.html

demo.md (||)


---
title: Demobox
fontPair: Open Sans
colors: light-green
links:
  Home: index.html
  Demos: demos.html
  Themes: themes.html
  Github: https://github.com/jaredly/demobox
---

# First example

``ˋjavascript
// @demobox height=150px
var first = 'javascript code'
  , second = `You can evaluate ${first} with es6 goodness.`;
// the last line must be an expression that results in a react
//  element.
<p>
  <span>{second} </span><br/>
  <strong>JSX is just fine</strong>
</p>
``ˋ

... etc.

demo.html rendered page (||)

demo page

Configuration

Special Headings

There are a few suffixes you can put onto headings that will give them extra properties.

  • (<<) marks the section as collapsed
  • (>>) marks the section as collapsible but expanded
  • (||) makes the section part of a column group. Adjascent sections (of the same heading level) that have this marking will be rendered side-by-side. An example of this is the demo.md and "demo.html rendered page" sections above.

The demobox.js drop-in script

Included in the <head>

<!-- if you want codemirror, that needs to be included separately -->
<script src="https://jaredly.github.io/demobox/demobox.js"></script>
<link rel="stylesheet" href="https://jaredly.github.io/demobox/demobox.css">

Markup in the page

<textarea data-demobox>
// some great code here
var x = <em>element</em>;

<strong>End with a react {x}</strong>
</textarea>

Rendered as a demobox

The demobox.js script finds all textareas with the data-demobox attribute and converts them into demoboxes that look like this:

// @demobox
// some great code here
var x = <em>element</em>;

<strong>End with a react {x}</strong>

Configuration options can be given as data-* attributes on the textarea. Look at the html source of this page (and the demo page) for example usage.

As a react component

If you install the demobox library from npm (npm install -S demobox) then you can use the DemoBox react component in your project.

In this demobox, you can play with the DemoBox component :).

// @demobox
var value = `\
<strong>
  It's demoboxes all the way down...
</strong>
`;

// Try changing position to left, right
// or top, and codeMirror to false
<DemoBox
    position='bottom'
    header={true}
    style={{width: 360}}
    codeMirror={true}
    initialValue={value}/>

Keywords

FAQs

Package last updated on 23 Jan 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc