-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add states as sample data, add filtering and demo, update readme, add…
… animation prop
- Loading branch information
Showing
11 changed files
with
722 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,35 @@ | ||
'use strict'; | ||
|
||
import React from 'react'; | ||
import AbsoluteGrid from './lib/AbsoluteGrid.jsx'; | ||
import AbsoluteGrid from './index.js'; | ||
import TestDisplay from './demo/TestDisplay.jsx'; | ||
import * as data from './demo/sampleData.js'; | ||
|
||
main(); | ||
demo(); | ||
|
||
function main() { | ||
function demo() { | ||
|
||
/* | ||
The data structure is pretty strict, we require a unique identifier (in this case key) and a sort | ||
key and sort are required, but configureable with keyProp and sortProp. | ||
*/ | ||
var sampleItems = [ | ||
{key: 1, name: 'Test', sort: 0, filtered: 0}, | ||
{key: 2, name: 'Test 1', sort: 2, filtered: 0}, | ||
{key: 3, name: 'Test 2', sort: 2, filtered: 0}, | ||
{key: 4, name: 'Test 3', sort: 3, filtered: 0}, | ||
{key: 5, name: 'Test 4', sort: 4, filtered: 0}, | ||
{key: 6, name: 'Test 5', sort: 5, filtered: 0}, | ||
{key: 7, name: 'Test 6', sort: 5, filtered: 0}, | ||
{key: 8, name: 'Test 7', sort: 6, filtered: 0}, | ||
{key: 9, name: 'Test 8', sort: 7, filtered: 0}, | ||
{key: 10, name: 'Test 9', sort: 8, filtered: 0}, | ||
{key: 11, name: 'Test 10', sort: 9, filtered: 0}, | ||
{key: 12, name: 'Test 11', sort: 10, filtered: 0} | ||
]; | ||
var sampleItems = data.states; | ||
|
||
var testDisplay = (<TestDisplay />); | ||
|
||
React.render(<AbsoluteGrid items={sampleItems} />, document.getElementById('BasicDemo')); | ||
React.render(<AbsoluteGrid items={sampleItems} displayObject={testDisplay}/>, document.getElementById('DisplayObjectDemo')); | ||
//Most Basic Demo | ||
React.render(<AbsoluteGrid items={sampleItems} keyProp="abbreviation"/>, document.getElementById('BasicDemo')); | ||
|
||
//Using Custom Display | ||
React.render(<AbsoluteGrid items={sampleItems} keyProp="abbreviation" displayObject={testDisplay}/>, document.getElementById('DisplayObjectDemo')); | ||
|
||
//Using Custom Display and Filtering | ||
var onFilter = function(event){ | ||
var search = new RegExp(event.target.value, 'i'); | ||
sampleItems.forEach(function(item){ | ||
item.filtered = !item.name.match(search); | ||
}); | ||
React.render(<AbsoluteGrid items={sampleItems} displayObject={testDisplay} keyProp="abbreviation"/>, document.getElementById('FilterDemo')); | ||
}; | ||
React.render(<input onChange={onFilter} type='text'/>, document.getElementById('Filter')); | ||
React.render(<AbsoluteGrid items={sampleItems} displayObject={testDisplay} keyProp="abbreviation"/>, document.getElementById('FilterDemo')); | ||
|
||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.