intro to montagejs

28
Introduction MontageJS to

Upload: ryan-paul

Post on 06-Nov-2014

134 views

Category:

Technology


0 download

DESCRIPTION

An introductory overview of MontageJS, a modern framework for frontend Web development.

TRANSCRIPT

Page 1: Intro to MontageJS

Introduction

MontageJSto

Page 2: Intro to MontageJS

Ryan Paul

MontageJS Dev Relations

@segphault

Page 3: Intro to MontageJS

The Web

Evolvingis

Page 4: Intro to MontageJS

Hypertext Document

Medium

from

Page 5: Intro to MontageJS

to

Interactive Application

Platform

Page 6: Intro to MontageJS

WE NEED A FRAMEWORK

BRIDGE THE GAP

to

Page 7: Intro to MontageJS

• Framework for frontend web development

• Ideal for building single-page applications

• Best suited for projects that target modern browsers

• Open source, under BSD license

What is MontageJS?

Page 8: Intro to MontageJS

• Component System

• Deferred Drawing

• Functional Reactive Bindings

Key Features

Page 9: Intro to MontageJS

• Component System

• Deferred Drawing

• Functional Reactive Bindings

Key Features

FRB

Page 10: Intro to MontageJS

• Component System

• Deferred Drawing

• Functional Reactive Bindings

Key Features

FRB

Page 11: Intro to MontageJS

Components

HTML Content

CSS Styling

FRB Bindings

JS Code

component.reel

Page 12: Intro to MontageJS

Install MontageJS

$ sudo npm install -gq minit@latest

Page 13: Intro to MontageJS

Create Project

$ minit create:app -n app-name

Create Component

$ minit create:component -n compname

Page 14: Intro to MontageJS

Filesystemassets

images style

node_modules digit montage

ui main.reel welcome.reel

index.html package.json

Page 15: Intro to MontageJS

Filesystemassets

images style

node_modules digit montage

ui main.reel welcome.reel

index.html package.json

!

main.reel

main.html

main.css

main.js

Page 16: Intro to MontageJS

Serialization

• Instantiate components

• Attach components to the page DOM

• Populate component properties — static values or bindings

Page 17: Intro to MontageJS

FRB

Bindings

• Propagate changes between object properties

• Can be 1-way or 2-way

• Bind to other components or regular JS objects

Page 18: Intro to MontageJS

Serialization"number": { "prototype": "digit/ui/number-field.reel", "properties": { "element": {"#": "number"} } }

<input data-montage-id="number" /> HTML

MJS

Page 19: Intro to MontageJS

Serialization"number": { "prototype": "digit/ui/number-field.reel", "properties": { "element": {"#": "number"} } }

<input data-montage-id="number" /> HTML

MJS

Prototype: path to the desired component

Page 20: Intro to MontageJS

Serialization"number": { "prototype": "digit/ui/number-field.reel", "properties": { "element": {"#": "number"} } }

<input data-montage-id="number" /> HTML

MJS

Element: Montage ID of DOM element

Page 21: Intro to MontageJS

"number": { "prototype": "digit/ui/number-field.reel", "properties": { "element": {"#": "number"} } }, "slider": { "prototype": "digit/ui/slider.reel", "properties": { "element": {"#": "slider"} }, "bindings": { "value": {"<->": "@number.value"} } }

Adding a 2nd component

<input data-montage-id="number" /> <input data-montage-id="slider" type="range" />

HTML

MJS

Page 22: Intro to MontageJS

"number": { "prototype": "digit/ui/number-field.reel", "properties": { "element": {"#": "number"} } }, "slider": { "prototype": "digit/ui/slider.reel", "properties": { "element": {"#": "slider"} }, "bindings": { "value": {"<->": "@number.value"} } }

<input data-montage-id="number" /> <input data-montage-id="slider" type="range" />

HTML

MJS

<-> signifies a 2-way binding

Page 23: Intro to MontageJS

"number": { "prototype": "digit/ui/number-field.reel", "properties": { "element": {"#": "number"} } }, "slider": { "prototype": "digit/ui/slider.reel", "properties": { "element": {"#": "slider"} }, "bindings": { "value": {"<->": "@number.value"} } }

<input data-montage-id="number" /> <input data-montage-id="slider" type="range" />

HTML

MJS

@ references an existing component

Page 24: Intro to MontageJS

"celsiusNumber": { "prototype": "digit/ui/number-field.reel", "properties": { "element": {"#": "celsius"} }, "bindings": { "value": {"<->": "([email protected] - 32) / 1.8"} } }

MJS

Complex FRB Expressions

Page 25: Intro to MontageJS

!"sorted": {"<-": “numbers.sorted{}”} !"evens": {"<-": “numbers.filter{!(%2)}”} !"low": {"<-": “numbers.filter{this <= ^maxNumber}”} !"allChecked": {"<-": “options.every{checked}”} !"payroll": {"<-": “departments.map{employees.sum{salary}}.sum()”} !"index": {"<-": “folks.group{id}.sorted{.0}.map{.1.last()}”}

MJS

Fun with FRB

Page 26: Intro to MontageJS

• Command line tool that optimizes apps for production deployment

• Consolidates code into bundles to reduce number of requests

• Minifies code to reduce total download size

MontageJS Optimizer

Page 27: Intro to MontageJS

MontageJS Optimizer

$ sudo npm install -g mop

$ mop

Page 28: Intro to MontageJS

Thank You!

MontageJS.org @MontageJS