Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ts #78

Open
wants to merge 17 commits into
base: brickjs
Choose a base branch
from
Open

ts #78

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- '0.10'
- '6'
env:
global:
- secure: nQuikGRYucx6RHkG/4oSg7CNmdKHx3+vDWr8YzKBAn+X8lLI8z75vW++gznfXsglGR/9jUjX0tkZ9JADg21IQ8hOpc7+8OhERbnLlDa4LzOO+BVeHIRzy9p7LmYDY18mUWQ5zSiae//J9dvABTYPJegiNIKbalIvJfzqHesYdks=
Expand Down
Empty file removed History.md
Empty file.
11 changes: 0 additions & 11 deletions Makefile

This file was deleted.

161 changes: 37 additions & 124 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,146 +1,59 @@
# Brick
# Legoh

Brick reduces boilerplate by implementing amongst others, reactive one way binding.
[![Build Status](https://travis-ci.org/bredele/legoh.svg?branch=master)](https://travis-ci.org/bredele/legoh)
[![NPM](https://img.shields.io/npm/v/legoh.svg)](https://www.npmjs.com/package/legoh)
[![Downloads](https://img.shields.io/npm/dm/legoh.svg)](http://npm-stat.com/charts.html?package=legoh)
[![pledge](https://bredele.github.io/contributing-guide/community-pledge.svg)](https://github.com/bredele/contributing-guide/blob/master/community.md)

```js
brick('<div>Hello ${ name }</div>', {
name: 'olivier'
}, document.body);
```
see [live example]()

Brick doesn't stop there though. Despite its small size (2kb) it has a fair bit of power under the hood and a ridiculously small learning curve.

## Learn BRICK in 5 minutes

<!-- ## Brick is your living data -->

### brick is a datastore

A brick is a datastore, a bloat-free layer to manipulate your data.

```js
var user = brick();
user.set('name','olivier');
user.set('age', 26);
user.get('name'); // => olivier
user.compute('birthday', function() {
return this.name + 'is ' + this.age;
});
```
see [datastore](http://github.com/bredele/datastore) for full API.

### brick is an emitter

A brick is an observable. it allows you to publish/subscribe events and also to get notified when there has been a change of data or in its [state](#brick-is-a-state-machine).

```js
user.on('change birthday', function(val) {
// => olivier is 27
});
user.set('age', 27);
```

This notifications allows the brick to produce updated output and HTML.

see [emitter](http://github.com/component/emitter) for full API.

<!-- ## Brick is your living dom -->

### brick is reactive

Brick intelligently updates your HTML whenever the underlying data changes.

```js
var user = brick('<div>${name} is ${age}</div>');
user.set('name', 'olivier');
user.set('age', 27);
```
**DEPRECATED** Please use [brickjs branch](https://github.com/bredele/lego/tree/brickjs) or even better, use React or Vue.

It eliminates DOM manipulation from the list of things you have to worry about. Brick will also work with SVG nodes or even server side!

<!--
```html
<div class="twitter ${theme}">
<p>${text}</p>
<span>${ text.length } character${text.length > 0 ? 's' : ''}</span>
</div>
```
-->
### brick is declarative

You also can extend existing DOM attributes or even create new ones with plugins.
## Usage

```js
var user = brick('<a href="bredele"></a>');
link.attr('href', function(node, content) {
node.href = 'http://github.com/' + content;
});
```

See [result on live]().

A plugin is as simple as a function but the possibilities are numerous. There is plugins to listen DOM events, synchronize a brick data with a database and more.
var lego = require('legoh')


### brick is a state machine

Brick will notify you at different step of it's lifecycle.

```js
user.on('mounted', function() {
// do something on mounted
})
```

But that's not all! It is also a [finite state machine](http://en.wikipedia.org/wiki/Finite-state_machine), allowing you to create your own states and sequence of actions.
Check out [examples](/examples) and [docs](/docs) for more information.

```js
user.hook('present', 'sick', function() {
// transition present -> absent on sick condition
}, 'absent');
## Installation

user.emit('sick');
```shell
npm install legoh --save
```

### brick is composable
[![NPM](https://nodei.co/npm/legoh.png)](https://nodei.co/npm/legoh/)

What if developing an application was as easy as putting pieces of Lego together? With brick you can extend or create your own tags.
## Question

```js
var user = brick('<span>${name}</span>', {
name: 'world'
});

var welcome = brick('<h1>Hello <user></user></h1>');
welcome.tag('user', user);
```

It follows the [web component](http://w3c.github.io/webcomponents/spec/custom/) syntax with the power of a simple and concise API.
For questions and feedback please use our [twitter account](https://twitter.com/bredeleca). For support, bug reports and or feature requests please make sure to read our
<a href="https://github.com/bredele/contributing-guide/blob/master/community.md" target="_blank">community guideline</a> and use the issue list of this repo and make sure it's not present yet in our reporting checklist.


### brick is reusable
## Contribution

An application is also made of reusable pieces. It's a bit like assembling Lego bricks of same shapes and colors:

```js
var lego = brick('<span>${color}</span>').mold();

var yellow = lego();
var green = lego();
var blue = lego();
```

No classes. You can create a brick and `mold` it anytime. Calling `mold` freezes a brick as well as its current state and data.
Legoh is an open source project and would not exist without its community. If you want to participate please make sure to read our <a href="https://github.com/bredele/contributing-guide/blob/master/community.md" target="_blank">guideline</a> before making a pull request. If you have any legoh-related project, component or other let everyone know in our wiki.

## License

The MIT License (MIT)

Copyright (c) 2014 Olivier Wietrich <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright (c) 2016 Olivier Wietrich

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
14 changes: 0 additions & 14 deletions component.json

This file was deleted.

Loading