canvas-lms/app/jsx
Clay Diffrient ae57b0609d Make column headers sort properly in files
This also converts the column header spec from
coffeescript to javascript (JSX)

fixes CNVS-29308

Test Plan:
  - Go to files
  - Click the various column headers across the top
    of the files area
  - The files should sort as expected

Change-Id: Ib8bd0040c06b45a095bce3960c6ff1cc4d39a99b
Reviewed-on: https://gerrit.instructure.com/79358
Tested-by: Jenkins
Reviewed-by: Steven Burnett <sburnett@instructure.com>
QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com>
Product-Review: Clay Diffrient <cdiffrient@instructure.com>
2016-05-12 16:27:37 +00:00
..
account_course_user_search remove errors shown in console 2016-05-11 18:33:05 +00:00
assignments disable Add Reviewer button when no students selected to moderate 2016-04-29 19:28:19 +00:00
authentication_providers Update AuthenticationTypePicker to work with React 0.13.3 2015-11-19 00:32:45 +00:00
context_modules Start using Babel to compile files in the JSX folder 2015-10-23 20:54:35 +00:00
course_link_validator improve course link validator handling with head requests 2016-04-29 17:26:20 +00:00
course_settings Add change image link to course settings 2016-04-20 20:58:51 +00:00
course_wizard fix a11y issues with course setup checklist 2016-04-25 16:16:37 +00:00
dashboard_card use 'dashboard cards' over 'dashcards' in user strings 2016-05-06 22:49:08 +00:00
discussion_topics Reactify discussion keyboard shortcut modal 2016-01-12 17:41:26 +00:00
due_dates don't show inactive students in assignment override dropdown 2016-02-26 01:24:57 +00:00
editor clean up RCE abstraction layer and service sidebar 2016-03-30 18:03:24 +00:00
epub_exports Update FriendlyDatetime component to work with React 0.13.3 2015-11-19 00:33:37 +00:00
external_apps Make app center link work properly in external apps 2016-04-27 17:16:42 +00:00
files Make column headers sort properly in files 2016-05-12 16:27:37 +00:00
gradebook update student name link in react gradebook 2016-05-02 18:31:01 +00:00
gradebook2 gradebook: incrementally load users 2016-03-30 19:54:44 +00:00
grading grading schemes page: fix a11y issues 2016-02-01 18:29:56 +00:00
groups prevent users from double-joining groups 2016-03-10 17:13:22 +00:00
navigation_header (NUI) Only show ePortfolios in nav when feature is on 2016-05-05 21:00:16 +00:00
outcomes Start using Babel to compile files in the JSX folder 2015-10-23 20:54:35 +00:00
shared add temporary conditional release popup to assignments 2016-05-03 16:00:24 +00:00
styleguide Update react-modals in Canvas 2015-12-15 13:52:34 +00:00
theme_editor Add Theme Editor high contrast alert 2016-03-01 22:20:43 +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}.`);