Skip to content

Commit 98be812

Browse files
author
jfusco
committed
Major changes to build process and documentation. Adding examples and docs directory. See release notes for more details
1 parent bcd5a8f commit 98be812

55 files changed

Lines changed: 23525 additions & 715 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.babelrc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"presets": [
33
"react",
4-
"es2015",
5-
"stage-2"
4+
"es2015"
65
],
76
"plugins": [
8-
"transform-class-properties"
7+
"transform-function-bind",
8+
"transform-class-properties",
9+
"transform-object-rest-spread"
910
]
1011
}

.npmignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
/.idea/
22
/__tests__/
33
/gulp/
4-
/src/
4+
/src/example/
5+
/src/component/js/
56
/coverage/
7+
/docs/
8+
/webpack/
9+
/src/component/index.html
10+
/src/component/index.js
11+
demo.gif
612
.editorconfig
713
.babelrc
814
.eslintignore
@@ -13,3 +19,4 @@
1319
config.json
1420
gulpfile.babel.js
1521
webpack.config.babel.js
22+
webpack.config.example.babel.js

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ node_js:
44
before_install:
55
- npm install -g gulp
66
- npm install -g eslint
7+
- npm install -g babel-eslint
78
script:
8-
- "gulp eslint && npm test"
9+
- "npm run lint && npm test"

README.md

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,35 @@
1010

1111
> WAI-ARIA compliant React autocomplete component
1212
13+
### Demo
14+
https://jfusco.github.io/react-predictive-input
15+
16+
## Getting Started ##
17+
18+
#### Installation
19+
From the root of your project.
20+
```sh
21+
npm install react-predictive-input --save
22+
```
23+
1324
## Usage
1425
Implementation of autocomplete. See [available options](#options) below.
1526
```js
1627
import React, { Component } from 'react';
1728
import { render } from 'react-dom';
18-
import Autocomplete from 'react-autocomplete';
29+
import Autocomplete from 'react-predictive-input';
1930

2031
class Application extends Component{
32+
static defaultProps = {
33+
fruit: ['bananas', 'strawberries', 'blueberries', 'pineapples', 'apples', 'tomatos', 'mangos', 'oranges', 'grapes', 'Rasberries', 'Blackberries', 'starfruit']
34+
};
35+
36+
static propTypes = {
37+
fruit: PropTypes.arrayOf(PropTypes.string)
38+
};
39+
2140
constructor(props){
2241
super(props);
23-
24-
this.fruit = ['bananas', 'strawberries', 'blueberries', 'pineapples', 'apples', 'tomatos', 'mangos', 'oranges', 'grapes', 'Rasberries', 'Blackberries', 'starfruit'];
2542
}
2643

2744
onItemSelected(value){
@@ -32,9 +49,10 @@ class Application extends Component{
3249
return (
3350
<div>
3451
<Autocomplete
35-
id="1"
36-
placeholder="Fruits"
37-
onSelected={this.onItemSelected.bind(this)} />
52+
id="fruit"
53+
placeholder="Search a type of fruit"
54+
data={this.props.fruit}
55+
onSelected={::this.onItemSelected)} />
3856
</div>
3957
);
4058
}
@@ -59,14 +77,14 @@ render(<Application />, document.getElementById('application'));
5977
##### id ~ required
6078
The unique `id` of the component - used for setting up accessibility
6179
```js
62-
<Autocomplete id="1" />
80+
<Autocomplete id="fruit" />
6381
```
6482

6583
<a name="placeholder"></a>
6684
##### placeholder ~ optional ~ default `null`
6785
A `string` used as placeholder text in the tags input field
6886
```js
69-
<Autocomplete placeholder="Fruits" />
87+
<Autocomplete placeholder="Search a type of fruit" />
7088
```
7189

7290
<a name="data"></a>
@@ -130,7 +148,7 @@ onItemSelected(value) {
130148
#### Installation
131149
Import the main SCSS file in to your application SCSS files
132150
```scss
133-
@import "src/scss/components/react-autocomplete";
151+
@import "node_modules/react-predictive-input/src/component/scss/styles.scss";
134152
```
135153

136154
There are a few variables set to `!default` that can be overriden. If you need to change it more just override the actual styles.
@@ -176,7 +194,7 @@ $ac-s-padding
176194

177195
If you don't care to override variables and just want to override actual styles you may choose to import the minified compiled version of the css instead
178196
```scss
179-
@import "dist/react-autocomplete.min.css";
197+
@import "node_modules/react-predictive-input/dist/styles.css";
180198
```
181199

182200
## Tests ##

__tests__/Suggestion-test.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@ jest.disableAutomock();
55
import React from 'react';
66
import { findDOMNode } from 'react-dom';
77
import { createRenderer, Simulate, renderIntoDocument } from 'react-addons-test-utils';
8-
import Suggestion from '../src/js/Suggestion';
8+
import Suggestion from '../src/component/js/Suggestion';
99

1010
describe('Suggestion', () => {
1111
it('should render', () => {
1212
const renderer = createRenderer();
13+
const onMouseOver = jest.genMockFunction();
14+
const onMouseDown = jest.genMockFunction();
1315

1416
renderer.render(
15-
<Suggestion />
17+
<Suggestion
18+
className=""
19+
onMouseOver={onMouseOver}
20+
onMouseDown={onMouseDown} />
1621
);
1722

1823
const suggestion = renderer.getRenderOutput();

config.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
{
2-
"css": {
3-
"fileName": "react-autocomplete"
4-
},
52
"scripts": {
63
"fileName": "react-autocomplete",
74
"entry": "Autocomplete",

0 commit comments

Comments
 (0)