canvas-lms/app/jsx
Sterling Cobb 80fd9ebcb9 convert toolbar to jsx
refs CNVS-22335

This needs to be QA'd really well because we don't have any regular
test around this.

Test Plan
- Go to the files page
- Test everything around the top toolbar
- Everything should still be working

Change-Id: I4e3760e75d2e44c6d5f53bc60841294152f3edd2
Reviewed-on: https://gerrit.instructure.com/61667
Tested-by: Jenkins
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
QA-Review: Ryan Allen <rallen@instructure.com>
Product-Review: Clay Diffrient <cdiffrient@instructure.com>
2015-11-05 22:23:42 +00:00
..
assignments Make the select all checkbox work with moderated grading 2015-10-30 17:23:09 +00:00
authentication_providers Start using Babel to compile files in the JSX folder 2015-10-23 20:54:35 +00:00
context_modules Start using Babel to compile files in the JSX folder 2015-10-23 20:54:35 +00:00
course_wizard [a11y] Make course wizard better for screenreaders 2015-11-04 18:00:19 +00:00
dashboard_card Start using Babel to compile files in the JSX folder 2015-10-23 20:54:35 +00:00
due_dates handle focus when adding/removing due date sets 2015-10-28 18:29:34 +00:00
epub_exports show OC failures in UI 2015-10-30 19:46:02 +00:00
external_apps Start using Babel to compile files in the JSX folder 2015-10-23 20:54:35 +00:00
files convert toolbar to jsx 2015-11-05 22:23:42 +00:00
gradebook remove attendance column logic from react-gb 2015-11-05 17:15:55 +00:00
grading remove colon from 'Name:' and 'Range:' 2015-10-28 21:46:36 +00:00
groups Start using Babel to compile files in the JSX folder 2015-10-23 20:54:35 +00:00
navigation_header Add class for groups subpanel so spacing is better 2015-11-04 20:39:13 +00:00
outcomes Start using Babel to compile files in the JSX folder 2015-10-23 20:54:35 +00:00
shared add date format tooltip back to DA date fields 2015-10-27 22:54:10 +00:00
styleguide Start using Babel to compile files in the JSX folder 2015-10-23 20:54:35 +00:00
theme_editor Start using Babel to compile files in the JSX folder 2015-10-23 20:54:35 +00:00
README.md Start using Babel to compile files in the JSX folder 2015-10-23 20:54:35 +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.

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}.`);