Giter Club home page Giter Club logo

prodotype's Introduction

Prodotype is used in Silex website builder as a component creation tool. Use it to create components and the UI to edit them out of html templates and yaml files.

Links

Features

  • build components from 1 template file and 1 definition file per component
  • generate a UI to edit each component, which creates a data object
  • render a component given data object
  • manage dependencies for components

Install

Add to your project and build pub/prodotype.js

$ npm install
$ npm run build

Use in your projects

In your HTML page - e.g. see this demo page

  <script type="text/javascript" src="./ejs.min.js"></script>
  <script type="text/javascript" src="./prodotype.js"></script>
  <div id="stage"></div>
  <div id="ui"></div>

In your js file - e.g. see this demo script for a complete / real world example.

// the div where you want your components to be rendered
const stage = document.querySelector('#stage');
// the div where we want the UI to edit the components
const ui = document.querySelector('#ui');
// where prodotype templates are located
const templateFolder = './sample'
// the main Prodotype object
const prodotype = new Prodotype(ui, templateFolder);
prodotype.ready(function(err) {
  // create a slide show in the stage div
  const templateName = 'unslider';
  prodotype.decorate(templateName).then(html => stage.innerHTML = html);
  // display tool boxes to edit the component
  prodotype.edit(data, [{templateName:templateName}], templateName, {
    onChange: function(newData, html) {
      stage.innerHTML = html;
    }
  });
});

Run it with npm start and you should be able to edit the component like this:

sample component edition

create your own templates

Create a folder with a .yaml file and a .ejs file - see the sample/ folder to see examples of templates.

Then build your templates with this command line, which will generate a components.json in the destination folder (pub/sample/ in this example):

$ npm run build:templates

All the types of editors here

Development

Production (uses http-server to serve pub/):

$ npm start

Development (serve, watch, build and live reload):

$ npm run watch
$ npm run reload

Create a new version

$ npm version patch
$ git push origin master --follow-tags
$ npm publish

prodotype's People

Contributors

jbips avatar lexoyo avatar singchan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

prodotype's Issues

the package.json may wrong

"build:editor": "browserify src/Prodotype.js -o pub/prodotype.js -t [ babelify ] && node bin/appendejslib",
and i think it lost node;
npm install was wrong the same reason, and i saw it at silexlabs/Silex#574 . maybe you forget it. my english is poor, whatever im nervous:D

Issue: Font-family

The font family select are empty in my last installation!!!
Embed fonts by hand appears, but not the default one, like in previous versions of silex.
And more about fonts:
When I load a template the embed fonts are not loaded so when we edit text his appearence change if it has a embeb font.
I cannot find the component that controls this. I supposes it's a propopotype component but I cannot find none
Please any help?

Feature request: generate type info

I believe it would be useful - and quite easy, to generate type info for the JSON data created by prodotype's UI, in order to help the developer manipulate the data

Use case: I use prodotype to create a CSS editor, which means that prodotype is used to generate a UI and the CSS edited by the end user. When I use this CSS editor in my app, I will store a JSON object generated by prodotype. This data should be easy to manipulate in JS, so we should generate JSDoc or JSON schema when building the UI from the .yaml files

Some links

Would this be useful to someone else?

Warning message from React

At runtime I have this warning message:

"Warning: Accessing PropTypes via the main React package is deprecated, and will be removed in  React v16.0. Use the latest available v15.* prop-types package from npm instead. For info on usage, compatibility, migration and more, see https://fb.me/prop-types-docs"

screenshot from 2018-01-13 20-30-00

This issue comes from this issue

import existing components

One should be able to provide a web component or a react or preact component instead of the ejs template

We can probably avoid the yaml file if the component has a propTypes attribute, or using observedAttributes of web components

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.