canvas-lms/app/jsx
Clay Diffrient dcae1b8d58 Convert FlashMessageHolder to a dumb component with tests
closes CNVS-23614

Test Plan:
  - Setup a moderated grading environment
  - Use the + Reviewers button
  - You should see the flash message show
  - Use the publish button
  - You should also see that flash message

Change-Id: I350fba7bc0dd964f35df9aaf5f51224424182bb8
Reviewed-on: https://gerrit.instructure.com/64104
Tested-by: Jenkins
Reviewed-by: Sterling Cobb <sterling@instructure.com>
QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com>
Product-Review: Clay Diffrient <cdiffrient@instructure.com>
2015-09-30 21:32:14 +00:00
..
assignments Convert FlashMessageHolder to a dumb component with tests 2015-09-30 21:32:14 +00:00
authentication_providers fix auth selector for AACs 2015-06-16 15:49:24 +00:00
context_modules improve module item file selector performance 2015-06-23 12:46:07 +00:00
course_wizard remove ic-Expand-link--Secondary since the default is already a 2015-09-10 21:41:26 +00:00
dashboard_card Dashboard badges: discussions and announcements 2015-09-24 18:39:45 +00:00
due_dates a11y workaround assignment "assign to" 2015-09-30 21:31:59 +00:00
epub_exports adds UI & backend for offline content 2015-09-30 16:22:18 +00:00
external_apps Fix suboptimal corners in React modal 2015-08-10 13:25:08 +00:00
files edit access restrictions from usage rights modal 2015-09-29 17:27:45 +00:00
gradebook Removed secondary id column 2015-09-24 18:09:29 +00:00
grading end date datepicker defaults to 11:59 pm 2015-09-11 23:23:48 +00:00
groups Converts some of new Files to Render Using JSX 2015-08-11 15:55:30 +00:00
navigation_header don't render headers when they'll just be hidden anyway 2015-09-28 02:44:08 +00:00
outcomes allows deletion of alignments from outcomes/show 2015-02-19 23:14:06 +00:00
shared adds UI & backend for offline content 2015-09-30 16:22:18 +00:00
styleguide Fix suboptimal corners in React modal 2015-08-10 13:25:08 +00:00
theme_editor mobile css and js overrides 2015-09-28 19:24:55 +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}.`);