Git Product home page Git Product logo

pidgin's Introduction

pidgin

pidgin is a prototype widget based system for Dojo 2. It relies upon another key technology:

The main design goals of this prototype are:

  • Leverage the next generation browser technologies
  • Leverage AMD
  • Fit well into Dojo 2

pidgin/_Widget

_Widget is very roughly a Dijit like AMD abstract class Widget that leverages the next generation of browser technologies, including Custom Elements, Pointer Events and Model Driven Views. While it tries to be like Dijit where it can, there are some fundamental concept shifts:

  • The node is the widget and the widget is the node. By using Custom Elements, the constructor for all widgets is based off of the HTMLElement DOM object.This has several advantages, in that as you manipulate the DOM nodes, you are also dealing with the widget instances.This also means there is no widget registry, because the document is effectively the registry. You can use whatever DOM manipulation API you want to move the widget around.

  • One of the benefits of Custom Elements is that the specification allows you to create your own "valid" attributes. A developer can specify attributes to be copied to properties during initialisation of the widget. Combined with the ability to declare an instance of a widget via its custom tag, this effectively means there is no need for a dojo/parser to be able to provide the "declarative syntax".

  • It leverages ES5 accessor properties instead of using the discreet accessors. This means there is no widget.get() and widget.set(). You can affect the widget directly.

  • It directly supports reactive templating (based on pidgin/tmpl and MDV) directly in the base Widget.

For more information on _Widget see the _Widget documentation.

pidgin/Button

This is a widget that extends the HTMLButtonElement interface. Its custom tag is pd-button. To instantiate it declaratively, you would do this:

<pd-button>Click Me!</pd-button>
<!-- or -->
<pd-button label="Click Me!"></pd-button>

Do instantiate it programmatically you would do something like this:

require(['pidgin/Button'], function (Button) {
	var button1 = new Button();
	button1.label = 'Click Me!';
	button1.place(document.body);

	/* Or create it via its tag */
	var button2 = document.createElement('pd-button');
	button2.label = 'Click me Instead!';
	document.body.appendNode(button2);
});

pidgin/widgets

widgets is the utility module of pidgin. Currently its only purpose is to register widgets with the current document.

For example, to create and register a new type of widget you would do something like:

require(['pidgin/widgets', 'pidgin/_Widget'], function (widgets, _Widget) {
	var MyWidget = widget.register('x-my-widget', HTMLElement, _Widget, {
		foo: 'bar'
	});

	// new works
	var myWidget1 = new MyWidget();

	// creation by tag works
	var myWidget2 = document.createElement('x-my-widget');
});

pidgin/tmpl

tmpl is an AMD plugin for loading and referencing MDV templates. It is specifically designed to work well with Widget.

pidgin's People

Contributors

kitsonk avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pidgin's Issues

dojo and Custom Elements

Hi I sent an email to your discussion (http://grokbase.com/t/dojo/dojo-contributors/136qdq7mzg/prototype-polymer-platform-widgets) on this but wasn't sure it got thru so I'm writing this here.

I was happy to know that you are trying this out for dojo 2. I feel dojo can greatly benefit from Custom Elements. apart from the reasons you listed in your discussion, i felt that Custom Elements would allow us to declaratively define views that would work across many platforms.

example: <dojo-menu></dojo-menu>

in order to display the menu above in desktop, we could load code that defines dojo-menu as a tree widget. then, in order to display it in a tablet, we could load code that defines dojo-menu as a mobile list.

this provides a whole level of power for working with dojo. we don't have to define separate HTML files just to serve both desktop and mobile platforms, unless absolutely necessary. a lot of the content we define in HTML are usually the same across both, why not DRY them up?

I'm working on getting something like this up and working, but so far am having issues with platform.js and xstyle (using this because of dgrid). Assertion failed is what i'm getting. will keep working on tho.

hope to hear your opinion on this.

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.