canvas-lms/app/jsx
Ryan Shaw 8530998c7d Add ability to close out the Theme Editor
fixes: CNVS-21433

test plan:
* open theme editor
* make a change, hit preview,
* notice how colors look different for you now
* click "cancel changes" in the top left
* it should take you to whatever page was open in the
  preview iframe
* you should not see the theme editor, and canvas
  should use the colors it had before you opened
  the theme editor

Change-Id: I47d4b1c736e3d7d4767151c1b17a3075ec822f07
Reviewed-on: https://gerrit.instructure.com/57559
Reviewed-by: Jennifer Stern <jstern@instructure.com>
Product-Review: Jennifer Stern <jstern@instructure.com>
Tested-by: Jenkins
QA-Review: Ryan Shaw <ryan@instructure.com>
2015-07-15 18:07:31 +00:00
..
authentication_providers fix auth selector for AACs 2015-06-16 15:49:24 +00:00
calendar Adds a calendar color picker to canvas 2015-05-08 22:13:34 +00:00
context_modules improve module item file selector performance 2015-06-23 12:46:07 +00:00
course_wizard Upgrades Course Wizard to use newest React 2015-03-19 20:25:21 +00:00
dashboard_card Update dashboard toggle to new ic-Super-Toggle 2015-07-13 22:36:58 +00:00
due_dates Assignment Create Page: Fix missing I18n.t 2015-06-19 18:33:08 +00:00
external_apps Remove Link to Community in Apps Page 2015-07-08 13:46:10 +00:00
files create a modal for canvas from react-modal 2015-05-20 16:49:52 +00:00
gradebook gradebook csv: support excused assignments 2015-07-15 03:41:23 +00:00
grading MGP periods go through the minute 2015-06-18 21:52:19 +00:00
groups a11y: Moves add group set to a better place in the tab order 2015-03-20 16:46:43 +00:00
navigation_header (NUI) Make "logout" link log you out w/out taking you to /logout page 2015-07-13 14:57:30 +00:00
outcomes allows deletion of alignments from outcomes/show 2015-02-19 23:14:06 +00:00
shared localize datepicker UI 2015-06-18 17:46:27 +00:00
styleguide upgrade styleguide to current react and react-modal 2015-02-11 19:42:55 +00:00
theme_editor Add ability to close out the Theme Editor 2015-07-15 18:07:31 +00:00
README.md add unit tests for grading period react components 2015-04-23 17:50:51 +00:00

README.md

This directory is temporary until we rework the front-end build This is where we are headed.

Stuff you can do in Canvas JSX files

BUT WAIT!

Your file needs to:

  1. Have a file name with the .jsx extension.
  2. Start with /** @jsx React.DOM */

JSX

function foo(paths) {
  return <svg>{paths}</svg>;
}

Arrow Functions

Arrow Function Reference

var arr = ['hydrogen', 'helium', 'lithium'];

// es5
var a = arr.map(function(s){ return s.length });

// es6
var b = arr.map( s => s.length );

// with curlies requires normal return
var b = arr.map( (s) => {
  return s.length
});

// lexical `this`
var obj = {
  multiplier: 3,

  multiplyStuff (stuff) {
    return stuff.map((x) =>
      // no bind!
      return this.multiplier * x;
    )
  }
};

Classes

Class Reference

class EventEmitter {
  constructor() {
    // called when created
  }
  emit() {
    // ...
  }
  on() {
    // ...
  }
  once() {
    // ...
  }
  removeListener() {
    // ...
  }
  removeAllListeners() {
    // ...
  }
}

Extending and calling super.

class Domain extends EventEmitter {
  constructor() {
    super();
    this.members = [];
  }
}

Creating instances

var domain = new Domain();

Destructuring

// es5
var map = _.map;
var each = _.each;

// es6
var {map, each} = _;

Concise Object Methods

// es5
var obj = {
  foo: function() {}
  bar: function() {}
};

// es6
var obj = {
  foo() {}
  bar() {}
};

Object Short Notation

// es5
function() {
  // ...
  return {foo: foo, bar: bar, x: 10};
}

// es6
function() {
  // ...
  return {foo, bar, x: 10};
}

Rest Parameters

Rest Parameters Reference

// es5
function multiply(multiplier) {
  var numbers = Array.prototype.slice.call(arguments, 0);
  return number.map(function(n) { return multiplier * n; });
}

// es6
function multiply(multiplier, ...numbers) {
  return numbers.map( n => multiplier * n);
}

String Templates

String Template Reference

Multiline strings:

// es5
console.log("string text line 1" +
"string text line 2");

// es6
console.log(`string text line 1
string text line 2`);

Interpolated strings

var a = 5;
var b = 10;

// es5
console.log("Fifteen is " + (a + b) + " and not " + (2 * a + b) + ".");

// es6
console.log(`Fifteen is ${a + b} and not ${2 * a + b}.`);