canvas-lms/app/jsx
Clay Diffrient e702f9c26a [New UI] Modifies rendering of global nav
Makes it so that the global nav is rendered in a 'static' form by
the server via application.html.erb but is then replaced by the React
component once JavaScript has come onto the page.

It also makes it so the API calls don't take place until the
relevant button on the sidebar is hovered over.

closes CNVS-19257
closes CNVS-19199
closes CNVS-18822
closes CNVS-17911
closes CNVS-18489
closes CNVS-18351
closes CNVS-20214
closes CNVS-20507

Test Plan:
  - You should see a server rendered version of the bar on the page
  - It should be rendered by React once JS loads
  - Hovering over the courses/groups/accounts should cause an API
    call the first time.
  - Courses/Groups/Accounts should only show if the user you are using
    has access to those things.
  - Make sure the help link opens up the normal help modal.
  - When on the courses page make sure at smaller resolutions that the
    hamburger menu successfully opens and closes.
  - If Commons is enabled, that link should show in the global nav.
  - The active link should show as being highlighted white.
  * Please also test this with multiple screen sizes (tablets/desktop).
    It should be responsive
Change-Id: If27c9f07e6eea662909790fb09d6ada254b8009c
Reviewed-on: https://gerrit.instructure.com/54703
Reviewed-by: Ryan Shaw <ryan@instructure.com>
Tested-by: Jenkins
QA-Review: Matt Fairbourn <mfairbourn@instructure.com>
Product-Review: Clay Diffrient <cdiffrient@instructure.com>
2015-06-04 20:21:53 +00:00
..
calendar Adds a calendar color picker to canvas 2015-05-08 22:13:34 +00:00
context_modules Increases page size for loading files and folders in modules 2015-04-29 22:28:35 +00:00
course_wizard Upgrades Course Wizard to use newest React 2015-03-19 20:25:21 +00:00
due_dates added semicolons to jsx to fix minification bug 2015-06-01 17:55:00 +00:00
external_apps Improve accessibility on newly added cog menu for app placements 2015-06-01 21:19:43 +00:00
files create a modal for canvas from react-modal 2015-05-20 16:49:52 +00:00
gradebook Fix styles for Post Grades button in gradebook toolbar 2015-06-04 16:29:29 +00:00
grading remove some datetime cruft, refactor parseDatetime 2015-05-20 20:21:00 +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 [New UI] Modifies rendering of global nav 2015-06-04 20:21:53 +00:00
outcomes allows deletion of alignments from outcomes/show 2015-02-19 23:14:06 +00:00
shared Converts new styles navigation to React 2015-05-29 18:35:59 +00:00
styleguide upgrade styleguide to current react and react-modal 2015-02-11 19:42: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}.`);