Skip to content

Commit

Permalink
Project skeleton and initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
lettertwo committed Jun 11, 2014
1 parent 0719cef commit 68e7ef3
Show file tree
Hide file tree
Showing 14 changed files with 19,653 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "vendor"
}
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/node_modules/
/test/tests.js
/lib/
/vendor/react/*.json
/vendor/react/*.min.js
/vendor/react/*.min.js
/vendor/react/react.js
/vendor/react/JSXTransformer.js
8 changes: 8 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/node_modules/
/gulpfile.*
/test/
/vendor/
/bower.json
/coffeelint.json
/src/
/standalone/
124 changes: 124 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
react-loadqueueloader
=====================

Sometimes you want to take the decisions about what to load and when from the
browser, but still reap the benefits of queuing and prioritizing that the
browser is capable of. A load queue (such as [queueup.js]) allows you to manage
and prioritize loads in just such a way, and this [React] component allows an
easy way of hooking asset loading for components into a load queue.


Basic Usage
-----------

```javascript
var LoadQueueLoader = require('react-loadqueueloader');

// ...

<LoadQueueLoader
src="/path/to/image.jpg"
priority=1
loader={ React.DOM.img }
/>

```

While the above example nicely illustrates basic usage, it neglects a crucial
piece of the puzzle: the load queue!


Load Queue
----------

When you render the LoadQueueLoader component, you want to do so with a
`loadQueue` (such as [queueup.js]) in context (using `React.withContext`).
For example:

```javascript
var LoadQueueLoader = require('react-loadqueueloader');
var queue = require('queueup')();
var LoadQueue = React.createClass({
render: function() {
React.withContext({loadQueue: queue}, <div>{ this.props.children }</div>);
}
});

// ...

<LoadQueue>
<LoadQueueLoader src="/path/to/image.jpg" loader={ React.DOM.img } />
</LoadQueue>

```


Context
-------

<table>
<thead>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</thead>
<tbody>
<tr>
<td>`loadQueue`</td>
<td>object</td>
<td>An object that manages loads in a queue. It is expected to have an
`enqueue` method that takes a function that performs the load. When
the load queue is ready to load an asset, it should call the provided
function, passing it a callback. That callback will be called when the
load completes (or errors). See [queueup.js] for an implementation of
the expected interface.</td>
</tr>
</tbody>
</table>


Props
-----

<table>
<thead>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</thead>
<tbody>
<tr>
<td>`loader`</td>
<td>function</td>
<td>A React class or other function that returns a component instance
that loads a `src`. The instance should also accept `onLoad`
and `onError` callbacks. Required.</td>
</tr>
<tr>
<td>`src`</td>
<td>string</td>
<td>The URL of the image to be loaded.</td>
</tr>
<tr>
<td>`priority`</td>
<td>number</td>
<td>The priority to assign to this load, relative to other loads in the
queue. This prop has no effect if there is no `loadQueue` in the
component context. Defaults to `0`</td>
</tr>
<tr>
<td>`onLoad`</td>
<td>function</td>
<td>An optional callback to be called when the load finishes.</td>
</tr>
<tr>
<td>`onError`</td>
<td>function</td>
<td>An optional callback to be called if the load fails.</td>
</tr>
</tbody>
</table>


[React]: http://facebook.github.io/react/
[queueup.js]: http://github.com/hzdg/queueup.js/
29 changes: 29 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "react-loadqueueloader",
"version": "0.0.0",
"authors": [
"Eric Eldredge <lettertwo@gmail.com>"
],
"description": "A React component for managing loads with a load queue",
"main": "./standalone/react-loadqueueloader.js",
"keywords": [
"react-component",
"react",
"loader",
"load",
"queue",
"queueup",
"component"
],
"license": "MIT",
"homepage": "https://github.com/hzdg/react-loadqueueloader",
"ignore": [
"**/.*",
"node_modules",
"vendor",
"test"
],
"devDependencies": {
"react": "~0.10.0"
}
}
114 changes: 114 additions & 0 deletions coffeelint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{
"coffeescript_error": {
"level": "error"
},
"arrow_spacing": {
"name": "arrow_spacing",
"level": "error"
},
"no_tabs": {
"name": "no_tabs",
"level": "error"
},
"no_trailing_whitespace": {
"name": "no_trailing_whitespace",
"level": "error",
"allowed_in_comments": false,
"allowed_in_empty_lines": false
},
"max_line_length": {
"name": "max_line_length",
"value": 80,
"level": "ignore",
"limitComments": true
},
"line_endings": {
"name": "line_endings",
"level": "error",
"value": "unix"
},
"no_trailing_semicolons": {
"name": "no_trailing_semicolons",
"level": "error"
},
"indentation": {
"name": "indentation",
"value": 2,
"level": "error"
},
"camel_case_classes": {
"name": "camel_case_classes",
"level": "error"
},
"colon_assignment_spacing": {
"name": "colon_assignment_spacing",
"level": "error",
"spacing": {
"left": 0,
"right": 1
}
},
"no_implicit_braces": {
"name": "no_implicit_braces",
"level": "ignore",
"strict": true
},
"no_plusplus": {
"name": "no_plusplus",
"level": "error"
},
"no_throwing_strings": {
"name": "no_throwing_strings",
"level": "error"
},
"no_backticks": {
"name": "no_backticks",
"level": "error"
},
"no_implicit_parens": {
"name": "no_implicit_parens",
"level": "ignore"
},
"no_empty_param_list": {
"name": "no_empty_param_list",
"level": "error"
},
"no_stand_alone_at": {
"name": "no_stand_alone_at",
"level": "error"
},
"space_operators": {
"name": "space_operators",
"level": "error"
},
"duplicate_key": {
"name": "duplicate_key",
"level": "error"
},
"empty_constructor_needs_parens": {
"name": "empty_constructor_needs_parens",
"level": "ignore"
},
"cyclomatic_complexity": {
"name": "cyclomatic_complexity",
"value": 10,
"level": "ignore"
},
"newlines_after_classes": {
"name": "newlines_after_classes",
"value": 2,
"level": "warn"
},
"no_unnecessary_fat_arrows": {
"name": "no_unnecessary_fat_arrows",
"level": "error"
},
"missing_fat_arrows": {
"name": "missing_fat_arrows",
"level": "ignore"
},
"non_empty_constructor_needs_parens": {
"name": "non_empty_constructor_needs_parens",
"level": "ignore"
}
}
Loading

0 comments on commit 68e7ef3

Please sign in to comment.